From f94208694971a568fe3eb89c95f97f85f125ba18 Mon Sep 17 00:00:00 2001 From: Solomon Jacobs Date: Tue, 7 Nov 2023 14:41:04 +0100 Subject: [PATCH] Add Windows compilation target Previously, the ci steps were skipped for the Windows compilation target. This new approach runs the ci steps on a Windows machine. This is suboptimal for multiple reasons: * the `ci` script does not work on a machine. Thus, calls to the script are removed by this change. * our local workflow involves cross-compilation, and thus it is slightly different from github workflow * the release builds are currently built via cross-compilation The reason we can't use `ubuntu-latest` as a build machine is that the `cargo test` requires an interpreter for a `.exe` file. --- .github/workflows/ci.yaml | 50 +++++++++++++++------------------------ ci | 5 ++-- setup | 5 ---- 3 files changed, 22 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a7093d48..c6c13c72 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,41 +3,29 @@ name: CI on: [push, pull_request] jobs: - linux: - runs-on: ubuntu-latest - + ci: + runs-on: ${{ matrix.type.os }} + name: ${{ matrix.type.target }} (${{ matrix.type.os }}) strategy: matrix: - include: - - name: Rust formatting - step: cargo-fmt-check - - name: Rust linting - step: cargo-clippy - - name: Rust tests - step: cargo-test - + type: + - { os: windows-latest, target: x86_64-pc-windows-gnu } + - { os: ubuntu-latest, target: x86_64-unknown-linux-gnu } steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup environment - run: ./setup + - name: Checkout repository + uses: actions/checkout@v4 - - name: ${{ matrix.name }} - env: - STEP: ${{ matrix.step }} - run: ./ci "${STEP}" + - name: "Setup Rust" + uses: actions-rust-lang/setup-rust-toolchain@v1.5.0 + with: + components: rustfmt, clippy + target: ${{ matrix.type.target }} - check_success: - if: always() + - run: cargo fmt -- --check + working-directory: ${{ github.workspace }}/v2/robotmk/ - needs: - - linux + - run: cargo test --all-targets --target ${{ matrix.type.target }} + working-directory: ${{ github.workspace }}/v2/robotmk/ - runs-on: ubuntu-latest - - steps: - - name: Decide whether the needed jobs succeeded or failed - uses: re-actors/alls-green@release/v1 - with: - jobs: ${{ toJSON(needs) }} + - run: cargo clippy --all-targets --target ${{ matrix.type.target }} -- --deny warnings + working-directory: ${{ github.workspace }}/v2/robotmk/ diff --git a/ci b/ci index 78348248..632b8c16 100755 --- a/ci +++ b/ci @@ -5,6 +5,7 @@ main() { self="${topdir}/ci" cargo_toml_path="${topdir}/v2/robotmk/Cargo.toml" mode="${1}" + target="${2:-x86_64-unknown-linux-gnu}" shift case "${mode}" in @@ -13,11 +14,11 @@ main() { ;; 'cargo-clippy') - cargo clippy --manifest-path "${cargo_toml_path}" --all-targets -- --deny warnings + cargo clippy --manifest-path "${cargo_toml_path}" --all-targets --target "${target}" -- --deny warnings ;; 'cargo-test') - cargo test --manifest-path "${cargo_toml_path}" --all-targets + cargo test --manifest-path "${cargo_toml_path}" --all-targets --target "${target}" ;; 'check-all') diff --git a/setup b/setup index f9b23e02..b64689da 100755 --- a/setup +++ b/setup @@ -3,12 +3,7 @@ set -e main() { - setup_rust git config core.hooksPath .githooks } -setup_rust() { - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s - -y -} - main