Skip to content

Commit

Permalink
Fix ci and improve efficiency (#1744)
Browse files Browse the repository at this point in the history
* Fix job changed-file in ci.yml

* Do not run job e2e-tests on PR

which might not have access to GitHub Token in secrets, if opened by non-maintainer

* Provide GITHUB_TOKEN fallback if the secrets is not accessible

* Fix regex expression passed to sed
  • Loading branch information
NobodyXu authored Jun 13, 2024
1 parent 250814f commit d524db3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
set -euxo pipefail
crates_changed="$(for file in $ALL_CHANGED_FILES; do echo $file; done | grep crates | cut -d / -f 2 || echo)"
crates_changed="$(for file in $ALL_CHANGED_FILES; do echo $file; done | grep crates | cut -d / -f 2 | sed 's/bin/cargo-binstall/' || echo)"
has_detect_target_changed="$(echo "$crates_changed" | grep -q detect-targets && echo true || echo false)"
echo "crates_changed=${crates_changed//$'\n'/ }" | tee -a "$GITHUB_OUTPUT"
echo "has_detect_target_changed=$has_detect_target_changed" | tee -a "$GITHUB_OUTPUT"
Expand All @@ -80,7 +80,7 @@ jobs:
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 }}
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
with:
tools: cargo-nextest

Expand All @@ -98,10 +98,11 @@ jobs:
- run: just unit-tests
if: env.CARGO_NEXTEST_ADDITIONAL_ARGS != ''
env:
GITHUB_TOKEN: ${{ secrets.CI_TEST_GITHUB_TOKEN }}
CI_UNIT_TEST_GITHUB_TOKEN: ${{ secrets.CI_UNIT_TEST_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.CI_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
CI_UNIT_TEST_GITHUB_TOKEN: ${{ secrets.CI_UNIT_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}

e2e-tests:
if: github.event_name != 'pull_request'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -165,7 +166,7 @@ jobs:
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 }}
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}

- run: just avoid-dev-deps
- run: just check
Expand All @@ -189,7 +190,7 @@ jobs:
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 }}
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}

- run: just toolchain rustfmt,clippy
- run: just avoid-dev-deps
Expand Down

0 comments on commit d524db3

Please sign in to comment.