Skip to content

Commit 777925f

Browse files
authored
ci: update lint-and-test.yml (#272)
This pull request updates the `lint-and-test.yml` GitHub Actions workflow to improve how changes are detected and handled for different event types. The workflow now better supports merge queue events and manual runs, ensuring that the correct set of checks is triggered in each scenario. Key improvements include: **Workflow event handling:** * Added support for the `merge_group` event, enabling the workflow to run when merge queue checks are requested. **Change detection logic:** * Updated the "Detect Changes" job to use different strategies based on the event type: - For `merge_group` events, it compares the merge-group head and base SHAs to detect changes using the `dorny/paths-filter` action. - For manual (`workflow_dispatch`) runs, it marks all change categories (`services`, `libs`, `frontend`, `infrastructure`) as changed to ensure all checks run. * Modified job outputs to prioritize results from the appropriate detection step (`filter` or `manual`). **Minor cleanup:** * Removed an unnecessary blank line in the `libs` linting job for clarity.
1 parent fd773a4 commit 777925f

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

.github/workflows/lint-and-test.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: lint-and-test
22

33
on:
4+
merge_group:
5+
types: [checks_requested]
46
workflow_dispatch:
57

68
env:
@@ -12,20 +14,24 @@ jobs:
1214
name: Detect Changes
1315
runs-on: ubuntu-latest
1416
outputs:
15-
services: ${{ steps.changes.outputs.services }}
16-
libs: ${{ steps.changes.outputs.libs }}
17-
frontend: ${{ steps.changes.outputs.frontend }}
18-
infrastructure: ${{ steps.changes.outputs.infrastructure }}
17+
services: ${{ steps.filter.outputs.services || steps.manual.outputs.services }}
18+
libs: ${{ steps.filter.outputs.libs || steps.manual.outputs.libs }}
19+
frontend: ${{ steps.filter.outputs.frontend || steps.manual.outputs.frontend }}
20+
infrastructure: ${{ steps.filter.outputs.infrastructure || steps.manual.outputs.infrastructure }}
1921
steps:
2022
- name: Checkout
2123
uses: actions/checkout@v4
2224
with:
2325
fetch-depth: 0
2426

25-
- name: Detect changes
26-
id: changes
27+
# When running via merge queue, diff the merge-group head vs its base
28+
- name: Detect changes (merge queue)
29+
id: filter
30+
if: github.event_name == 'merge_group'
2731
uses: dorny/paths-filter@v3
2832
with:
33+
base: ${{ github.event.merge_group.base_sha }}
34+
ref: ${{ github.event.merge_group.head_sha }}
2935
filters: |
3036
services:
3137
- 'services/admin-backend/**'
@@ -40,6 +46,16 @@ jobs:
4046
- 'infrastructure/**'
4147
- 'Tiltfile'
4248
49+
# When run manually, just run everything
50+
- name: Mark all as changed (manual run)
51+
id: manual
52+
if: github.event_name == 'workflow_dispatch'
53+
run: |
54+
echo "services=true" >> "$GITHUB_OUTPUT"
55+
echo "libs=true" >> "$GITHUB_OUTPUT"
56+
echo "frontend=true" >> "$GITHUB_OUTPUT"
57+
echo "infrastructure=true" >> "$GITHUB_OUTPUT"
58+
4359
sanitize-branch-name:
4460
runs-on: ubuntu-latest
4561
outputs:
@@ -111,7 +127,6 @@ jobs:
111127
run: |
112128
docker build -t $LINT_IMAGE_NAME --build-arg DIRECTORY=${{ matrix.library }} --build-arg TEST=0 -f libs/Dockerfile libs
113129
114-
115130
- name: Run linting
116131
run: |
117132
docker run --rm $LINT_IMAGE_NAME make lint

0 commit comments

Comments
 (0)