Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip tests when merging an up-to-date branch #112

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,37 @@ env:
CARGO_TERM_COLOR: always

jobs:
maybe-expedite:
outputs:
value: ${{ steps.expedite.outputs.value }}

runs-on: ubuntu-latest

steps:
- name: Log github refs
run: |
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo 'github.ref: ${{ github.ref }}' >> "$GITHUB_STEP_SUMMARY"
echo 'github.sha: ${{ github.sha }}' >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check if merging an up-to-date branch
if: ${{ github.event_name == 'merge_group' }}
id: expedite
run: |
if git merge-base --is-ancestor origin/master ${{ github.sha }}; then
echo "value=1" >> "$GITHUB_OUTPUT"
fi

test:
needs: [maybe-expedite]

if: ${{ ! needs.maybe-expedite.outputs.value }}

strategy:
fail-fast: ${{ github.event_name == 'merge_group' }}
matrix:
Expand All @@ -32,13 +62,6 @@ jobs:
GROUP_RUNNER: target.'cfg(all())'.runner = 'group-runner'

steps:
- name: Log github refs
run: |
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo 'github.ref: ${{ github.ref }}' >> "$GITHUB_STEP_SUMMARY"
echo 'github.sha: ${{ github.sha }}' >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"

- uses: actions/checkout@v4

- uses: actions/cache@v4
Expand Down Expand Up @@ -94,14 +117,14 @@ jobs:
all-checks:
needs: [test]

runs-on: ubuntu-latest

# smoelius: From "Defining prerequisite jobs"
# (https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs):
# > If you would like a job to run even if a job it is dependent on did not succeed, use the
# > `always()` conditional expression in `jobs.<job_id>.if`.
if: ${{ always() }}

runs-on: ubuntu-latest

steps:
- name: Check results
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
Expand Down