mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 14:28:42 +00:00
Speedup ci: Only run tests on change (#1729)
* Fix unit test for `GhApiClient` Set client-side rate limit to 1 request per 200 ms Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Only run `detect-targets` test if changed Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Only run unit tests for crates that are changed Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix job `changed-files` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix job `changed-files` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix shell error in job `changed-files` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * FIx separator for `changed-files` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix passning of craetes to run Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix passing of `CARGO_NEXTEST_ADDITIONAL_ARGS` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix deciding which crates to test on windows Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix just recipe `unit-tests` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Split test into two jobs so that they will have they own cache (since different feature flags are used). Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --------- Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
9a0367b3ec
commit
2feac66e14
3 changed files with 105 additions and 10 deletions
108
.github/workflows/ci.yml
vendored
108
.github/workflows/ci.yml
vendored
|
@ -34,7 +34,43 @@ env:
|
|||
CARGO_PROFILE_CHECK_ONLY_CODEGEN_UNITS: 4
|
||||
|
||||
jobs:
|
||||
test:
|
||||
changed-files:
|
||||
runs-on: ubuntu-latest
|
||||
name: Test changed-files
|
||||
permissions:
|
||||
pull-requests: read
|
||||
|
||||
outputs:
|
||||
crates_changed: ${{ steps.list-changed-files.outputs.crates_changed }}
|
||||
has_detect_target_changed: ${{ steps.list-changed-files.outputs.has_detect_target_changed }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
dir_names: true
|
||||
dir_names_exclude_current_dir: true
|
||||
dir_names_max_depth: 2
|
||||
separator: "\n"
|
||||
|
||||
- name: List all changed files
|
||||
id: list-changed-files
|
||||
env:
|
||||
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
crates_changed="$(echo "$ALL_CHANGED_FILES" | grep crates | cut -d / -f 2)"
|
||||
has_detect_target_changed="$(echo "$crates_changed" | grep -q detect-targets && echo true || echo false)"
|
||||
echo "crates_changed=$crates_changed" | tee -a "$GITHUB_OUTPUT"
|
||||
echo "has_detect_target_changed=$has_detect_target_changed" | tee -a "$GITHUB_OUTPUT"
|
||||
|
||||
unit-tests:
|
||||
needs: changed-files
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -60,11 +96,52 @@ jobs:
|
|||
with:
|
||||
tools: cargo-nextest
|
||||
|
||||
- run: just test
|
||||
- name: Decide crates to test
|
||||
shell: bash
|
||||
env:
|
||||
CRATES_CHANGED: ${{ needs.changed-files.outputs.crates_changed }}
|
||||
run: |
|
||||
ARGS=""
|
||||
for crate in $CRATES_CHANGED; do
|
||||
ARGS="$ARGS -p $crate"
|
||||
done
|
||||
echo "CARGO_NEXTEST_ADDITIONAL_ARGS=$ARGS" | tee -a "$GITHUB_ENV"
|
||||
|
||||
- run: just unit-tests
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.CI_TEST_GITHUB_TOKEN }}
|
||||
CI_UNIT_TEST_GITHUB_TOKEN: ${{ secrets.CI_UNIT_TEST_GITHUB_TOKEN }}
|
||||
|
||||
e2e-tests:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- target: x86_64-apple-darwin
|
||||
os: macos-14
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
os: ubuntu-latest
|
||||
- target: x86_64-pc-windows-msvc
|
||||
os: windows-latest
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
CARGO_BUILD_TARGET: ${{ matrix.target }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/just-setup
|
||||
env:
|
||||
# just-setup use binstall to install sccache,
|
||||
# which works better when we provide it with GITHUB_TOKEN.
|
||||
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||
|
||||
- run: |
|
||||
just build
|
||||
just e2e-tests
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.CI_TEST_GITHUB_TOKEN }}
|
||||
|
||||
cross-check:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
@ -161,6 +238,8 @@ jobs:
|
|||
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 4
|
||||
|
||||
detect-targets-build:
|
||||
needs: changed-files
|
||||
if: needs.changed-files.outputs.has_detect_target_changed == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
|
||||
|
@ -186,7 +265,10 @@ jobs:
|
|||
|
||||
detect-targets-alpine-test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: detect-targets-build
|
||||
needs:
|
||||
- detect-targets-build
|
||||
- changed-files
|
||||
if: needs.changed-files.outputs.has_detect_target_changed == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
@ -203,7 +285,10 @@ jobs:
|
|||
alpine /bin/ash -c "apk update && apk add bash && test.sh x86_64-unknown-linux-musl"
|
||||
|
||||
detect-targets-ubuntu-test:
|
||||
needs: detect-targets-build
|
||||
needs:
|
||||
- detect-targets-build
|
||||
- changed-files
|
||||
if: needs.changed-files.outputs.has_detect_target_changed == 'true'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -223,7 +308,10 @@ jobs:
|
|||
[ "$(./detect-targets)" = "$(printf 'x86_64-unknown-linux-gnu\nx86_64-unknown-linux-musl')" ]
|
||||
|
||||
detect-targets-more-glibc-test:
|
||||
needs: detect-targets-build
|
||||
needs:
|
||||
- detect-targets-build
|
||||
- changed-files
|
||||
if: needs.changed-files.outputs.has_detect_target_changed == 'true'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -248,7 +336,10 @@ jobs:
|
|||
${{ matrix.container }} detect-targets )" = "$(printf 'x86_64-unknown-linux-gnu\nx86_64-unknown-linux-musl')" ]
|
||||
|
||||
detect-targets-nix-test:
|
||||
needs: detect-targets-build
|
||||
needs:
|
||||
- detect-targets-build
|
||||
- changed-files
|
||||
if: needs.changed-files.outputs.has_detect_target_changed == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
|
@ -264,6 +355,8 @@ jobs:
|
|||
nixos/nix /detect-targets )" = x86_64-unknown-linux-musl ]
|
||||
|
||||
detect-targets-android-check:
|
||||
needs: changed-files
|
||||
if: needs.changed-files.outputs.has_detect_target_changed == 'true'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -294,7 +387,8 @@ jobs:
|
|||
tests-pass:
|
||||
name: Tests pass
|
||||
needs:
|
||||
- test
|
||||
- unit-tests
|
||||
- e2e-tests
|
||||
- cross-check
|
||||
- lint
|
||||
- release-dry-run
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue