-
-
Notifications
You must be signed in to change notification settings - Fork 383
72 lines (66 loc) · 2.54 KB
/
lint-swiftlint-formatting.yml
File metadata and controls
72 lines (66 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Lint SwiftLint
on:
push:
branches:
- main
- v8.x
pull_request:
# Concurrency configuration:
# - We use workflow-specific concurrency groups to prevent multiple lint runs on the same code,
# as linting checks are deterministic and don't require parallel validation.
# - For pull requests, we cancel in-progress runs when new commits are pushed since only the latest
# linting matters for merge decisions.
# - For main branch pushes, we never cancel formatting checks to ensure our code maintains consistent
# style standards across the entire project.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
files-changed:
name: Detect File Changes
runs-on: ubuntu-latest
outputs:
run_lint_swiftlint_for_prs: ${{ steps.changes.outputs.run_lint_swiftlint_for_prs }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Get changed files
id: changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
lint:
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_lint_swiftlint_for_prs == 'true'
needs: files-changed
name: Lint
runs-on: macos-15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install tooling
run: make init-ci-format
- run: swiftlint --version
- name: Run SwiftLint
run: swiftlint --strict
- name: Run CI Diagnostics
if: failure()
run: ./scripts/ci-diagnostics.sh
# This check validates that either lint passed or was skipped, which allows us
# to make lint-swiftlint a required check with only running the lint when required.
# So, we don't have to run lint-swiftlint, for example, for unrelated changes.
lint_swiftlint-required-check:
needs:
[
files-changed,
lint,
]
name: Lint SwiftLint
# This is necessary since a failed/skipped dependent job would cause this job to be skipped
if: always()
runs-on: ubuntu-latest
steps:
# If any jobs we depend on fails gets cancelled or times out, this job will fail.
# Skipped jobs are not considered failures.
- name: Check for failures
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "One of the lint-swiftlint jobs has failed." && exit 1