Skip to content

Commit c6c1cb7

Browse files
authored
chore(ci): Add required checks job for lint dprint (#6002)
1 parent 2675d3c commit c6c1cb7

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
lines changed

.github/file-filters.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,16 @@ run_lint_swift_formatting_for_prs: &run_lint_swift_formatting_for_prs # Swift fo
131131

132132
# Scripts
133133
- "scripts/ci-diagnostics.sh"
134+
135+
run_lint_dprint_for_prs: &run_lint_dprint_for_prs # dprint formatting
136+
- "**/*.yml"
137+
- "**/*.yaml"
138+
- "**/*.json"
139+
- "**/*.md"
140+
141+
# Formatting
142+
- "dprint.json"
143+
144+
# GH Actions
145+
- ".github/workflows/lint-dprint-formatting.yml"
146+
- ".github/file-filters.yml"

.github/workflows/lint-dprint-formatting.yml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,8 @@ on:
88
push:
99
branches:
1010
- main
11-
paths:
12-
- "**/*.yml"
13-
- "**/*.yaml"
14-
- "**/*.json"
15-
- "**/*.md"
16-
- ".github/workflows/lint-dprint-formatting.yml"
17-
- "dprint.json"
1811

1912
pull_request:
20-
paths:
21-
- "**/*.yml"
22-
- "**/*.yaml"
23-
- "**/*.json"
24-
- "**/*.md"
25-
- ".github/workflows/lint-dprint-formatting.yml"
26-
- "dprint.json"
2713

2814
# Concurrency configuration:
2915
# - We use workflow-specific concurrency groups to prevent multiple lint runs on the same code,
@@ -37,9 +23,44 @@ concurrency:
3723
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
3824

3925
jobs:
26+
files-changed:
27+
name: Detect File Changes
28+
runs-on: ubuntu-latest
29+
outputs:
30+
run_lint_dprint_for_prs: ${{ steps.changes.outputs.run_lint_dprint_for_prs }}
31+
steps:
32+
- uses: actions/checkout@v5
33+
- name: Get changed files
34+
id: changes
35+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
36+
with:
37+
token: ${{ github.token }}
38+
filters: .github/file-filters.yml
39+
4040
lint:
4141
name: Lint
42+
# Run the job only for PRs with related changes or non-PR events.
43+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_lint_dprint_for_prs == 'true'
44+
needs: files-changed
4245
runs-on: ubuntu-latest
4346
steps:
4447
- uses: actions/checkout@v5
4548
- uses: dprint/[email protected]
49+
50+
lint-dprint-required-check:
51+
needs:
52+
[
53+
files-changed,
54+
lint,
55+
]
56+
name: Lint dprint
57+
# This is necessary since a failed/skipped dependent job would cause this job to be skipped
58+
if: always()
59+
runs-on: ubuntu-latest
60+
steps:
61+
# If any jobs we depend on fails gets cancelled or times out, this job will fail.
62+
# Skipped jobs are not considered failures.
63+
- name: Check for failures
64+
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
65+
run: |
66+
echo "One of the lint dprint jobs has failed." && exit 1

0 commit comments

Comments
 (0)