From 8dc7480ce35b5233f0b5082546b7ca2f7ecbd38e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 25 Jun 2024 10:11:12 +0200 Subject: [PATCH] Add CI --- .github/workflows/ci.yml | 52 ++++++++++++++++++++++++++++++++++++++++ README.md | 15 ++++++++---- automation/Dockerfile | 13 ++++++++++ automation/Jenkinsfile | 43 +++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 automation/Dockerfile create mode 100644 automation/Jenkinsfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9bf8d2b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,52 @@ +name: ci +on: [push, pull_request] + +jobs: + check: + name: Check build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: "thumbv7em-none-eabihf" + - run: cargo check --target thumbv7em-none-eabihf --release + - run: cargo check --target thumbv7em-none-eabihf --examples --release + + test: + name: Run Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Install nextest + uses: taiki-e/install-action@nextest + - run: cargo nextest run --all-features -p va416xx-hal + # I think we can skip those on an embedded crate.. + # - run: cargo test --doc -p va108xx-hal + + fmt: + name: Check formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo fmt --all -- --check + + docs: + name: Check Documentation Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + - run: cargo +nightly doc --all-features --config 'build.rustdocflags=["--cfg", "docs_rs"]' + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: "thumbv7em-none-eabihf" + - run: cargo clippy --target thumbv7em-none-eabihf -- -D warnings diff --git a/README.md b/README.md index c7eff53..dab6726 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,16 @@ of devices. This workspace contains the following crates: -- The `va416xx` PAC crate containing basic low-level register definition -- The `va416xx-hal` HAL crate containing higher-level abstractions on top of - the PAC register crate. -- The `vorago-peb1` BSP crate containing support for the PEB1 development - board. +- The [`va416xx`](https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/src/branch/main/va416xx) + PAC crate containing basic low-level register definition +- The [`va416xx-hal`](https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/src/branch/main/va416xx-hal) + HAL crate containing higher-level abstractions on top of the PAC register crate. +- The [`vorago-peb1`](https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/src/branch/main/vorago-peb1) + BSP crate containing support for the PEB1 development board. + +It also contains the following helper crates: + +- The `examples` crates contains various example applications for the HAL and the PAC. ## Using the `.cargo/config.toml` file diff --git a/automation/Dockerfile b/automation/Dockerfile new file mode 100644 index 0000000..48c8e1d --- /dev/null +++ b/automation/Dockerfile @@ -0,0 +1,13 @@ +# Run the following commands from root directory to build and run locally +# docker build -f automation/Dockerfile -t . +# docker run -it +FROM rust:latest +RUN apt-get update +RUN apt-get --yes upgrade +# tzdata is a dependency, won't install otherwise +ARG DEBIAN_FRONTEND=noninteractive + +RUN rustup install nightly && \ + rustup target add thumbv7em-none-eabihf && \ + rustup +nightly target add thumbv7em-none-eabihf && \ + rustup component add rustfmt clippy diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile new file mode 100644 index 0000000..4da4a47 --- /dev/null +++ b/automation/Jenkinsfile @@ -0,0 +1,43 @@ +pipeline { + agent { + dockerfile { + dir 'automation' + reuseNode true + } + } + + stages { + stage('Rust Toolchain Info') { + steps { + sh 'rustc --version' + } + } + stage('Clippy') { + steps { + sh 'cargo clippy --target thumbv7em-none-eabihf' + } + } + stage('Rustfmt') { + steps { + sh 'cargo fmt' + } + } + stage('Docs') { + steps { + sh """ + cargo +nightly doc --all-features --config 'build.rustdocflags=["--cfg", "docs_rs"]' + """ + } + } + stage('Check') { + steps { + sh 'cargo check --target thumbv7em-none-eabihf' + } + } + stage('Check Examples') { + steps { + sh 'cargo check --target thumbv7em-none-eabihf --examples' + } + } + } +} -- 2.43.0