-
Notifications
You must be signed in to change notification settings - Fork 244
140 lines (123 loc) · 4.4 KB
/
lint.yml
File metadata and controls
140 lines (123 loc) · 4.4 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
name: Lint
#
# This workflow lints the library and reports back suggested fixes
#
on:
push:
branches:
- main
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- auto_merge_enabled
permissions:
contents: read
pull-requests: write
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
# -------------------------------------------------------------
# Returns all changed pull request files.
# --------------------------------------------------------------
changed_files:
runs-on: ubuntu-latest
name: Capture changed-files
outputs:
styles_added_files: ${{ steps.changed-files.outputs.styles_added_files }}
styles_modified_files: ${{ steps.changed-files.outputs.styles_modified_files }}
eslint_added_files: ${{ steps.changed-files.outputs.eslint_added_files }}
eslint_modified_files: ${{ steps.changed-files.outputs.eslint_modified_files }}
prettier_added_files: ${{ steps.changed-files.outputs.prettier_added_files }}
prettier_modified_files: ${{ steps.changed-files.outputs.prettier_modified_files }}
permissions:
pull-requests: read
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: step-security/changed-files@v46
with:
files_yaml: |
styles:
- '*.css'
- '**/*.css'
eslint:
- '*.{js,json,ts}'
- '**/*.{js,json,ts}'
- '!*.d.ts'
- '!**/*.d.ts'
prettier:
- '*.{js,json,ts,css,md,mdx,yaml,yml,html}'
- '**/*.{js,json,ts,css,md,mdx,yaml,yml,html}'
- '!*.d.ts'
- '!**/*.d.ts'
# --- Lint pre-compiled assets for consistency --- #
lint:
name: Lint
runs-on: ubuntu-latest
needs: [changed_files]
timeout-minutes: 5
steps:
# install but don't build - we're linting pre-compiled assets
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node LTS version
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- name: Enable Corepack
run: corepack enable
## --- YARN CACHE --- ##
- name: Check for cached dependencies
continue-on-error: true
id: cache-dependencies
uses: actions/cache@v4
with:
path: |
.cache/yarn
node_modules
key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }}
## --- INSTALL --- ##
# If statement isn't needed here b/c yarn will leverage the cache if it exists
- name: Install dependencies
shell: bash
run: yarn install --immutable
- name: Lint styles
# if: ${{ needs.changed_files.outputs.styles_added_files != '' || needs.changed_files.outputs.styles_modified_files != '' }}
uses: reviewdog/action-stylelint@v1.30.2
with:
fail_level: error
filter_mode: diff_context
level: error
reporter: github-pr-review
stylelint_input: '${{ needs.changed_files.outputs.styles_added_files }} ${{ needs.changed_files.outputs.styles_modified_files }} --allow-empty-input --quiet'
- name: ESLint
uses: reviewdog/action-eslint@v1.33.2
# if: ${{ needs.changed_files.outputs.eslint_added_files != '' || needs.changed_files.outputs.eslint_modified_files != '' }}
with:
fail_level: error
level: error
reporter: github-pr-review
filter_mode: diff_context
eslint_flags: '${{ needs.changed_files.outputs.eslint_added_files }} ${{ needs.changed_files.outputs.eslint_modified_files }} --quiet'
- name: Prettier
if: ${{ needs.changed_files.outputs.prettier_added_files != '' || needs.changed_files.outputs.prettier_modified_files != '' }}
run: |
FILES="${{ needs.changed_files.outputs.prettier_added_files }} ${{ needs.changed_files.outputs.prettier_modified_files }}"
# Trim whitespace and skip if only whitespace remains
FILES=$(echo "$FILES" | xargs)
if [ -n "$FILES" ]; then
yarn prettier --check $FILES
fi