From 1cd0e0e1f8ba0824f4513a0bbb62da6dc44d2789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Wed, 29 Jan 2025 11:29:29 +0100 Subject: [PATCH 1/5] ci: run build tests against different rust versions relevant to us MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have recently noticed that a feature (C-String literals) that has been stabilized just recently is being used in rsinit. The feature is however still considered unstable in some of the embedded distributions we use. Make sure no too new features are being used in rsinit by running build tests against older rust versions as well. Signed-off-by: Leonard Göhrs --- .github/workflows/rust.yml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3874441..26582c2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,14 +9,25 @@ on: env: CARGO_TERM_COLOR: always -jobs: - build: + # Make sure cargo commands not only fail on hard errors but also on warnings + # so we do not accidentally miss newly introduced warnings. + RUSTFLAGS: -D warnings +jobs: + build-and-test: + strategy: + fail-fast: false # Run against all versions even if one fails + matrix: + version: + - "1.75" # Yocto scarthgap + - "1.79" # Yocto styhead + - "1.81" # OSELAS.Toolchain v2024.11.0 + - "stable" + - "nightly" + name: cargo build && cargo test runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - uses: actions/checkout@v4 + - run: rustup toolchain install ${{ matrix.version }} + - run: rustup run ${{ matrix.version }} cargo build --verbose + - run: rustup run ${{ matrix.version }} cargo test --verbose From 67b19fbe34520476d5cace31ff2ec19d8e46d92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Wed, 29 Jan 2025 11:36:05 +0100 Subject: [PATCH 2/5] ci: run the clippy linter against the code and testsuite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The clippy linter often has useful tips on how to improce the code. Having these tips show up for pull requests reduces the amount of back-and-forth communication maintainers have to do. Signed-off-by: Leonard Göhrs --- .github/workflows/rust.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 26582c2..4345d08 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -31,3 +31,16 @@ jobs: - run: rustup toolchain install ${{ matrix.version }} - run: rustup run ${{ matrix.version }} cargo build --verbose - run: rustup run ${{ matrix.version }} cargo test --verbose + + clippy: + strategy: + matrix: + features: + - "" + - "--tests" + name: cargo clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: rustup toolchain install stable + - run: cargo clippy ${{ matrix.features }} From b860974a8a3bfde514b45e3776b87c2b9bd94125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Wed, 29 Jan 2025 11:37:46 +0100 Subject: [PATCH 3/5] ci: add a job to check formatting with cargo fmt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Discussing code formatting is tedious. Leave this job to the computers. Signed-off-by: Leonard Göhrs --- .github/workflows/rust.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4345d08..1911c4a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -44,3 +44,11 @@ jobs: - uses: actions/checkout@v4 - run: rustup toolchain install stable - run: cargo clippy ${{ matrix.features }} + + fmt: + name: cargo fmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: rustup toolchain install stable + - run: cargo fmt --all -- --check From 766455f994522e2a7993a5cc007f527777382d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Wed, 29 Jan 2025 11:38:29 +0100 Subject: [PATCH 4/5] ci: run the CI jobs on a schedule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are periodic updates to the stable and nightly compiler, linter and sometimes even the formatter. Make sure the existing codebase stays compatible with those by running the CI pipeline on a regular basis. Signed-off-by: Leonard Göhrs --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1911c4a..6f0c445 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -5,6 +5,8 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] + schedule: + - cron: '34 11 * * 2' env: CARGO_TERM_COLOR: always From b8d795d7d6e148118e0d9907bf6127a5dc4a102e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Wed, 29 Jan 2025 11:41:45 +0100 Subject: [PATCH 5/5] ci: enable running the pipeline manually using workflow_dispatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pipelines with `on: workflow_dispatch` can be executed using a button in the web interface or the API. This can come in handy every then and now. Signed-off-by: Leonard Göhrs --- .github/workflows/rust.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6f0c445..e669740 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -7,6 +7,7 @@ on: branches: [ "main" ] schedule: - cron: '34 11 * * 2' + workflow_dispatch: env: CARGO_TERM_COLOR: always