Skip to content

Commit fd94b0d

Browse files
authored
chore(ci): Add required checks job for lint shellcheck (#6005)
1 parent d1c0538 commit fd94b0d

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

.github/file-filters.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ run_lint_swift_formatting_for_prs: &run_lint_swift_formatting_for_prs # Swift fo
180180
# Scripts
181181
- "scripts/ci-diagnostics.sh"
182182

183+
run_lint_shellcheck_for_prs: &run_lint_shellcheck_for_prs # Shell scripts
184+
- "**/*.sh"
185+
186+
# GH Actions
187+
- ".github/workflows/lint-shellcheck-formatting.yml"
188+
- ".github/file-filters.yml"
189+
183190
run_lint_dprint_for_prs: &run_lint_dprint_for_prs # dprint formatting
184191
- "**/*.yml"
185192
- "**/*.yaml"

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

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,8 @@ on:
88
push:
99
branches:
1010
- main
11-
paths:
12-
- ".github/workflows/lint-shellcheck-formatting.yml"
13-
- "**/*.sh"
1411

1512
pull_request:
16-
paths:
17-
- ".github/workflows/lint-shellcheck-formatting.yml"
18-
- "**/*.sh"
1913

2014
# Concurrency configuration:
2115
# - We use workflow-specific concurrency groups to prevent multiple lint runs on the same code,
@@ -29,9 +23,44 @@ concurrency:
2923
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
3024

3125
jobs:
26+
files-changed:
27+
name: Detect File Changes
28+
runs-on: ubuntu-latest
29+
outputs:
30+
run_lint_shellcheck_for_prs: ${{ steps.changes.outputs.run_lint_shellcheck_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+
3240
lint:
3341
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_shellcheck_for_prs == 'true'
44+
needs: files-changed
3445
runs-on: ubuntu-latest
3546
steps:
3647
- uses: actions/checkout@v5
3748
- run: shellcheck **/*.sh
49+
50+
lint-shellcheck-required-check:
51+
needs:
52+
[
53+
files-changed,
54+
lint,
55+
]
56+
name: Lint Shellcheck
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 shellcheck jobs has failed." && exit 1

0 commit comments

Comments
 (0)