From dce672a925c0b5a37601b914d4250ddf5d8b027e Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 26 Mar 2023 14:49:08 +0200 Subject: [PATCH] ci: also build on Windows Test that we can also be built on Windows. This test ensures that developers using a Windows machine can build everything. --- .github/workflows/_build-rust.yml | 40 ++++++++++++++++++++++++------- .github/workflows/rust.yml | 14 +++++++++++ 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/.github/workflows/_build-rust.yml b/.github/workflows/_build-rust.yml index f30cc0cc..78ec5852 100644 --- a/.github/workflows/_build-rust.yml +++ b/.github/workflows/_build-rust.yml @@ -2,11 +2,21 @@ # More info: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iduses # Common Rust CI setup that checkout the repo, installs the common toolchain -# and set's up the cargo cache. It builds, tests, and lints the code. +# and set's up the cargo cache. It builds, tests, and lints the code, but is +# configurable. This way, the same workflow can be used to build, test, and lint +# all in different steps, but with the same cache. on: workflow_call: inputs: + runs-on: + type: string + required: false + default: ubuntu-latest + description: | + The value for the "runs-on" property: e.g. + - ubuntu-latest + - windows-latest rust-version: type: string required: false @@ -22,7 +32,14 @@ on: required: false # Make sure we always an empty string to "--features " default: '""' - description: Comma-separated String with additional Rust features relevant for a certain job. + description: > + Comma-separated string with additional crate features. Empty string by + default. CAUTION: For Windows CI runners, this must be '""' as is, + i.e., the string itself must be "". This is a limitation of the + Windows power shell. This might be configured like this: + + features: > + '""' do-style-check: type: boolean required: false @@ -35,8 +52,8 @@ on: description: Execute tests. jobs: - check_rust: - runs-on: ubuntu-latest + rust: + runs-on: ${{ inputs.runs-on }} steps: - name: Check out uses: actions/checkout@v3 @@ -67,16 +84,23 @@ jobs: - name: Build (all targets) run: cargo build --all-targets --features ${{ inputs.features }} - name: Code Formatting - if: ${{ inputs.do-style-check }} + if: inputs.do-style-check run: cargo fmt --all -- --check - name: Code Style and Doc Style - if: ${{ inputs.do-style-check }} + if: inputs.do-style-check run: | cargo doc --document-private-items --features ${{ inputs.features }} cargo clippy --all-targets --features ${{ inputs.features }} - - name: Unit Test - if: ${{ inputs.do-test }} + - name: Unit Test (UNIX) + if: inputs.do-test && runner.os != 'Windows' run: | curl -LsSf https://get.nexte.st/latest/linux | tar zxf - chmod u+x cargo-nextest ./cargo-nextest nextest run --features ${{ inputs.features }} + - name: Unit Test (Windows) + if: inputs.do-test && runner.os == 'Windows' + run: | + Invoke-WebRequest https://get.nexte.st/latest/windows -OutFile cargo-nextest.zip + Expand-Archive .\cargo-nextest.zip + cp .\cargo-nextest/cargo-nextest.exe . + .\cargo-nextest.exe nextest run --features ${{ inputs.features }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 49b08025..7641e7ca 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -57,6 +57,20 @@ jobs: do-style-check: false rust-target: thumbv7em-none-eabihf + # We perform one single run also in Windows. This should be sufficient to + # check that devs can also use this on Windows. + build_nostd_stable_windows: + name: build no_std (stable) [Windows] + uses: ./.github/workflows/_build-rust.yml + with: + runs-on: windows-latest + # Quirk for the Windows powershell and its handling of empty arguments. + features: > + '""' + rust-version: stable + do-style-check: false + rust-target: thumbv7em-none-eabihf + build_nostd_nightly: name: build no_std (nightly) needs: build_nightly