Skip to content

Commit 8e797ae

Browse files
authored
ci: run semver-checks on a pull_request_target trigger (#1661)
Fixes the errors we've seen with dependabot PRs (and fork PRs) failing the checks. See CQCL/hugrverse-actions#20 drive-by: Trigger the normal CI checks on any pull request, not only the ones targeting `main`
1 parent 953df6b commit 8e797ae

File tree

3 files changed

+50
-10
lines changed

3 files changed

+50
-10
lines changed

.github/workflows/ci-py.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77
pull_request:
88
branches:
9-
- main
9+
- '*'
1010
merge_group:
1111
types: [checks_requested]
1212
workflow_dispatch: {}

.github/workflows/ci-rs.yml

-9
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,6 @@ jobs:
279279
- name: Tests with no features
280280
run: cargo test -p hugr-llvm --verbose --features llvm${{ matrix.llvm-version[1] }}
281281

282-
rs-semver-checks:
283-
needs: [changes, check]
284-
if: ${{ needs.changes.outputs.rust == 'true' && github.event_name == 'pull_request' }}
285-
uses: CQCL/hugrverse-actions/.github/workflows/rs-semver-checks.yml@main
286-
with:
287-
apt-dependencies: capnproto
288-
secrets:
289-
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
290-
291282
# This is a meta job to mark successful completion of the required checks,
292283
# even if they are skipped due to no changes in the relevant files.
293284
required-checks:

.github/workflows/semver-checks.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Rust Semver Checks
2+
on:
3+
pull_request_target:
4+
branches:
5+
- main
6+
7+
jobs:
8+
# Check if changes were made to the relevant files.
9+
# Always returns true if running on the default branch, to ensure all changes are throughly checked.
10+
changes:
11+
name: Check for changes
12+
runs-on: ubuntu-latest
13+
# Required permissions
14+
permissions:
15+
pull-requests: read
16+
# Set job outputs to values from filter step
17+
# These outputs are always true when running after a merge to main, or if the PR has a `run-ci-checks` label.
18+
outputs:
19+
rust: ${{ steps.filter.outputs.rust == 'true' || steps.override.outputs.out == 'true' }}
20+
python: ${{ steps.filter.outputs.python == 'true' || steps.override.outputs.out == 'true' }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Override label
24+
id: override
25+
run: |
26+
echo "Label contains run-ci-checks: $OVERRIDE_LABEL"
27+
if [ "$OVERRIDE_LABEL" == "true" ]; then
28+
echo "Overriding due to label 'run-ci-checks'"
29+
echo "out=true" >> $GITHUB_OUTPUT
30+
elif [ "$DEFAULT_BRANCH" == "true" ]; then
31+
echo "Overriding due to running on the default branch"
32+
echo "out=true" >> $GITHUB_OUTPUT
33+
fi
34+
env:
35+
OVERRIDE_LABEL: ${{ github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'run-ci-checks') }}
36+
DEFAULT_BRANCH: ${{ github.ref_name == github.event.repository.default_branch }}
37+
- uses: dorny/paths-filter@v3
38+
id: filter
39+
with:
40+
filters: .github/change-filters.yml
41+
42+
rs-semver-checks:
43+
needs: [changes]
44+
if: ${{ needs.changes.outputs.rust == 'true' }}
45+
uses: CQCL/hugrverse-actions/.github/workflows/rs-semver-checks.yml@main
46+
with:
47+
apt-dependencies: capnproto
48+
secrets:
49+
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}

0 commit comments

Comments
 (0)