Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 6ebd620

Browse files
authored
change eslint workflow to use different method and action (#3693)
Our existing worfklow was giving a cryptic error that I couldn’t troubleshoot so decided to just switch to a different method
1 parent 8d63f7f commit 6ebd620

File tree

3 files changed

+67
-28
lines changed

3 files changed

+67
-28
lines changed

.github/workflows/js-css-linting.yml

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,74 @@ on:
66
branches: [trunk]
77

88
jobs:
9-
check:
10-
name: All
9+
Setup:
10+
name: Setup for Jobs
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Cache node modules
16+
uses: actions/cache@v2
17+
with:
18+
path: node_modules
19+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
20+
restore-keys: |
21+
${{ runner.OS }}-build-${{ env.cache-name }}-
22+
${{ runner.OS }}-build-
23+
${{ runner.OS }}-
24+
- name: Install Node Dependencies
25+
run: npm install
1126

27+
JSLintingCheck:
28+
name: Lint JavaScript
29+
needs: Setup
1230
runs-on: ubuntu-latest
1331

1432
steps:
15-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v2
34+
- name: Cache node modules
35+
uses: actions/cache@v2
36+
with:
37+
path: node_modules
38+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
39+
restore-keys: |
40+
${{ runner.OS }}-build-${{ env.cache-name }}-
41+
${{ runner.OS }}-build-
42+
${{ runner.OS }}-
43+
- name: Install Node Dependencies
44+
run: npm install
45+
- name: Save Code Linting Report JSON
46+
run: npm run lint:js:report
47+
# Continue to the next step even if this fails
48+
continue-on-error: true
49+
- name: Upload ESLint report
50+
uses: actions/upload-artifact@v2
51+
with:
52+
name: eslint_report.json
53+
path: eslint_report.json
54+
- name: Annotate Code Linting Results
55+
uses: ataylorme/[email protected]
56+
with:
57+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
58+
report-json: "eslint_report.json"
1659

17-
- name: Cache node modules
18-
uses: actions/cache@v2
19-
env:
20-
cache-name: cache-node-modules
21-
with:
22-
# npm cache files are stored in `~/.npm` on Linux/macOS
23-
path: ~/.npm
24-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
25-
restore-keys: |
26-
${{ runner.os }}-build-${{ env.cache-name }}-
27-
${{ runner.os }}-build-
28-
${{ runner.os }}-
29-
- name: Use Node.js 12.x
30-
uses: actions/setup-node@v1
31-
with:
32-
node-version: 12.x
33-
- name: Npm install
34-
run: |
35-
npm install
36-
- name: Lint JavaScript
37-
uses: bradennapier/[email protected]
38-
with:
39-
issueSummaryOnlyOnEvent: true
40-
- name: Lint CSS
41-
run: npm run lint:css
60+
CSSLintingCheck:
61+
name: Lint CSS
62+
needs: Setup
63+
runs-on: ubuntu-latest
4264

65+
steps:
66+
- uses: actions/checkout@v2
67+
- name: Cache node modules
68+
uses: actions/cache@v2
69+
with:
70+
path: node_modules
71+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
72+
restore-keys: |
73+
${{ runner.OS }}-build-${{ env.cache-name }}-
74+
${{ runner.OS }}-build-
75+
${{ runner.OS }}-
76+
- name: Install Node Dependencies
77+
run: npm install
78+
- name: Lint CSS
79+
run: npm run lint:css

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ storybook-static/
5353
blocks.ini
5454
/wp-content/
5555
/.wp-env.override.json
56+
/eslint_report.json

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"lint:css": "stylelint 'assets/**/*.scss'",
4242
"lint:css-fix": "stylelint 'assets/**/*.scss' --fix",
4343
"lint:js": "wp-scripts lint-js",
44+
"lint:js:report": "npm run lint:js -- --output-file eslint_report.json --format json",
4445
"lint:js-fix": "eslint assets/js --ext=js,jsx --fix",
4546
"lint:php": "composer run-script phpcs ./src",
4647
"package-plugin": "rimraf woocommerce-gutenberg-products-block.zip && ./bin/build-plugin-zip.sh",

0 commit comments

Comments
 (0)