From ef2752cd426f5e869d8f36d0fc00d6d718ca3f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Saparelli?= Date: Sun, 24 Jul 2022 15:37:41 +1200 Subject: [PATCH] Stop using actions-rs (#239) --- .../workflows/build-and-integration-tests.yml | 50 +++++++++---------- .github/workflows/unit-tests.yml | 12 ++--- ci-scripts/compile-settings.jq | 17 +++++++ 3 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 ci-scripts/compile-settings.jq diff --git a/.github/workflows/build-and-integration-tests.yml b/.github/workflows/build-and-integration-tests.yml index c06931ab..b814a19b 100644 --- a/.github/workflows/build-and-integration-tests.yml +++ b/.github/workflows/build-and-integration-tests.yml @@ -77,14 +77,30 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - - uses: FranzDiebold/github-env-vars-action@v1.2.1 - name: Configure toolchain - uses: actions-rs/toolchain@v1 + run: | + rustup toolchain install --profile minimal nightly + rustup default nightly + + - name: Install cross + if: matrix.use-cross + uses: taiki-e/install-action@v1 with: - toolchain: nightly - target: ${{ matrix.target }} - override: true + tool: cross + + - name: Install host target + if: "!matrix.use-cross" + run: rustup target add ${{ matrix.target }} + + - name: Select compile settings + shell: bash + run: | + jq \ + --arg ref '${{ github.ref }}' \ + --argjson matrix '${{ toJSON(matrix) }}' \ + -nrf ci-scripts/compile-settings.jq \ + | tee -a $GITHUB_ENV - name: Configure caching uses: actions/cache@v2 @@ -103,29 +119,11 @@ jobs: if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' && !startsWith(github.ref, 'refs/tags/v') }} run: sudo ./ci-scripts/install-deps.sh - - name: Build release - uses: actions-rs/cargo@v1 - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - with: - command: build - args: --target ${{ matrix.target }} --release ${{ matrix.release_build_args }} - use-cross: ${{ matrix.use-cross }} - - - name: Build debug - uses: actions-rs/cargo@v1 - if: ${{ ! startsWith(github.ref, 'refs/tags/v') }} - with: - command: build - args: --target ${{ matrix.target }} ${{ matrix.debug_build_args }} - use-cross: ${{ matrix.use-cross }} + - name: Build + run: ${{ env.CTOOL }} build ${{ env.CARGS }} - name: Copy and rename utility - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} - - - name: Copy and rename utility - if: ${{ ! startsWith(github.ref, 'refs/tags/v') }} - run: cp target/${{ matrix.target }}/debug/${{ matrix.output }} ${{ matrix.output }} + run: cp target/${{ matrix.target }}/${{ env.COUTPUT }}/${{ matrix.output }} ${{ matrix.output }} - name: Test (Unix) if: ${{ matrix.test && matrix.os != 'windows-latest' }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index f385c1a4..7300234e 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -15,10 +15,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Configure toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true + run: rustup default stable - name: Configure caching uses: actions/cache@v2 with: @@ -26,10 +23,7 @@ jobs: path: | ${{ env.HOME }}/.cargo target - - name: Install deps + - name: Install deps run: sudo ./ci-scripts/install-deps.sh - name: test - uses: actions-rs/cargo@v1 - with: - command: test - args: --no-default-features --features pkg-config,native-tls + run: cargo test --no-default-features --features pkg-config,native-tls diff --git a/ci-scripts/compile-settings.jq b/ci-scripts/compile-settings.jq new file mode 100644 index 00000000..933d1d6e --- /dev/null +++ b/ci-scripts/compile-settings.jq @@ -0,0 +1,17 @@ +if ($ref | startswith("refs/tags/v")) then { + output: "release", + profile: "release", + args: ($matrix.release_build_args // ""), +} else { + output: "debug", + profile: "dev", + args: ($matrix.debug_build_args // ""), +} end +| +{ + CTOOL: (if $matrix."use-cross" then "cross" else "cargo" end), + COUTPUT: .output, + CARGS: "--target \($matrix.target) --profile \(.profile) \(.args)", +} +| +to_entries[] | "\(.key)=\(.value)"