Skip to content

Commit

Permalink
Merge pull request #1 from Infineon/add_ci
Browse files Browse the repository at this point in the history
Add initial CI
  • Loading branch information
andreasWallnerIFX authored Apr 9, 2024
2 parents 35380ae + 2db2d37 commit 40f12e5
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 6 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/check-and-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Check and Lint

on:
push:
branches:
- main
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: Cargo check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: cargo check
- run: cargo check --all-features

clippy:
name: Lint with Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
override: true
- run: cargo clippy --all-features -- -D warnings

format:
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- run: cargo fmt --all -- --check

doc:
name: Lint Documentation
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -D warnings
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Check documentation
run: cargo doc --no-deps --all-features --document-private-items

cargo-deny:
runs-on: ubuntu-latest
strategy:
matrix:
checks:
- advisories
- bans licenses sources

# Prevent sudden announcement of a new advisory from failing ci:
continue-on-error: ${{ matrix.checks == 'advisories' }}

steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}
38 changes: 38 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test

on:
push:
branches:
- main
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cache dependencies
uses: actions/cache@v2
env:
cache-name: cache-dependencies
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
- run: cargo test --verbose --all -- --nocapture
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! - Support [tracing](#tracing) of register accesses and additionally mocking of registers on non-embedded devices through
//! external libraries. This allows the execution unit tests for code that uses the generated libraries on non-embedded devices.
//! - PAC shall have ideally 0 dependencies to any other crates.
//!
//!
//! # chiptool features implemented by `svd2pac`
//!
//! - No owned data structure -> unsafe api that can be used from any interrupts or thread.
Expand All @@ -33,10 +33,10 @@
//! - Support also for 8,16,64 bit size registers.
//! - Avoid long type and bitfield names (chiptool concatenates identifiers) by generating modules for registers and svd clusters.
//! - No support for SVD transformation.
//!
//!
//! # Limitations
//!
//! * Inheritance via `derivedFrom` attribute is supported only in `cluster` declaration and requires
//! * Inheritance via `derivedFrom` attribute is supported only in `cluster` declaration and requires
//! that child is not overriding anything except `name`, `description` and `offset`
//! * `headerStructName` tag is considered only in `cluster`` tag
//! * `resetMask` tag is ignored
Expand Down
6 changes: 3 additions & 3 deletions src/rust_gen/xml2ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn get_cluster<T: PeripheralClusterT>(
if !registers.is_empty() || !clusters.is_empty() {
error!("Cluster with derivedFrom attributes are supported only if they doesn't contains registers and/or clusters. Included registers and clusters are ignored")
}
get_parent_struct_name_cluster(device, container, &derived_path)
get_parent_struct_name_cluster(device, container, derived_path)
} else {
let mut struct_name = cluster.struct_name().to_sanitized_struct_ident();
struct_name.insert_str(0, "self::");
Expand Down Expand Up @@ -367,7 +367,7 @@ fn get_peripherals_types(
/// # Result
///
/// Device containing all information of svd file
fn parse_xml(xml: &mut String, svd_validation_level: SvdValidationLevel) -> Result<svd::Device> {
fn parse_xml(xml: &mut str, svd_validation_level: SvdValidationLevel) -> Result<svd::Device> {
let mut parser_config = svd_parser::Config::default();
parser_config.expand_properties = true;
parser_config.ignore_enums = false;
Expand Down Expand Up @@ -412,7 +412,7 @@ fn get_interrupt_table(
}

pub(super) fn parse_xml2ir(
xml: &mut String,
xml: &mut str,
svd_validation_level: SvdValidationLevel,
custom_license_text: &Option<String>,
) -> Result<IR> {
Expand Down

0 comments on commit 40f12e5

Please sign in to comment.