-
-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (134 loc) · 5.88 KB
/
lint.yml
File metadata and controls
153 lines (134 loc) · 5.88 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: "Lint"
on: # yamllint disable-line rule:truthy
push:
branches:
- "main"
pull_request: # yamllint disable-line rule:empty-values
concurrency:
group: "ci-lint-${{ github.ref }}-1"
cancel-in-progress: true
permissions:
contents: "read" # to fetch code (actions/checkout)
jobs:
files-changed:
name: "Detect what files changed"
runs-on: "ubuntu-latest"
timeout-minutes: 3
# Map a step output to a job output
outputs:
frontend_lintable: "${{ steps.changes.outputs.frontend_lintable }}"
markdown_lintable: "${{ steps.changes.outputs.markdown_lintable }}"
yaml_lintable: "${{ steps.changes.outputs.yaml_lintable }}"
steps:
- name: "Git checkout"
uses: "actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8" # v6.0.1
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
- name: "Check for file changes"
uses: "dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36" # v3.0.2
id: "changes"
with:
token: "${{ github.token }}"
filters: ".github/file-filters.yml"
eslint:
if: "needs.files-changed.outputs.frontend_lintable == 'true'"
needs: "files-changed"
name: "Lint (eslint)"
runs-on: "ubuntu-latest"
steps:
- name: "Harden Runner"
uses: "step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76" # v2.14.0
with:
egress-policy: "audit"
- name: "Git checkout ${{ env.HEAD_REPOSITORY }}:${{ env.HEAD_REF }}"
uses: "actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8" # v6.0.1
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
with:
fetch-depth: 0
- name: "Setup resources and environment"
id: "setup"
uses: "anolilab/workflows/step/setup@main"
with:
node-version: "20.x"
cache-prefix: "lint"
- name: "lint"
run: "pnpm run lint:eslint"
yaml-lint:
if: "needs.files-changed.outputs.yaml_lintable == 'true'"
needs: "files-changed"
name: "Lint (yaml)"
runs-on: "ubuntu-latest"
steps:
- name: "Harden Runner"
uses: "step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76" # v2.14.0
with:
egress-policy: "audit"
- name: "Git checkout"
uses: "actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8" # v6.0.1
with:
fetch-depth: 0
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
- name: "Lint YAML files"
uses: "ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c" # v3.1.1
with:
config_file: ".yamllint.yaml"
file_or_dir: "."
strict: true
markdown-lint:
if: "needs.files-changed.outputs.markdown_lintable == 'true'"
needs: "files-changed"
name: "Lint (markdown)"
runs-on: "ubuntu-latest"
steps:
- name: "Harden Runner"
uses: "step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76" # v2.14.0
with:
egress-policy: "audit"
- name: "Git checkout ${{ env.HEAD_REPOSITORY }}:${{ env.HEAD_REF }}"
uses: "actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8" # v6.0.1
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
with:
fetch-depth: 0
- name: "Setup resources and environment"
id: "setup"
uses: "anolilab/workflows/step/setup@main"
with:
node-version: "20.x"
cache-prefix: "lint"
- name: "lint"
run: "pnpm run lint:text"
continue-on-error: true
- name: "skipping markdown lint for now"
run: "exit 0"
# This check runs once all dependant jobs have passed
# It symbolizes that all required checks have successfully passed (Or skipped)
# This check is the only required GitHub check
test-required-check:
needs: ["files-changed", "eslint", "yaml-lint", "markdown-lint"] # TODO add "package-json-lint"
name: "Check Lint Run"
# 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 fail, we will fail since this is a required check
# NOTE: A timeout is considered a failure
- name: "Harden Runner"
uses: "step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76" # v2.14.0
with:
egress-policy: "audit"
- name: "Check for failures"
if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')"
run: |
echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1