Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit 1f0804c

Browse files
committed
ci: Update validate CI workflow
1 parent 8a4bc83 commit 1f0804c

File tree

4 files changed

+248
-77
lines changed

4 files changed

+248
-77
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/validate.yml

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
# PR's only
2+
3+
name: Validate
4+
5+
on:
6+
pull_request:
7+
branches: [master]
8+
9+
env:
10+
FORCE_COLOR: 1
11+
12+
jobs:
13+
linuxNode16:
14+
name: '[Linux] Node.js v16: Lint, Formatting & Unit tests'
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [2.7, 3.6]
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
22+
with:
23+
# For commitlint purpose ensure to have complete list of PR commits
24+
# It's loose and imperfect assumption that PR has no more than 30 commits
25+
fetch-depth: 30
26+
27+
- name: Retrieve last master commit (for `git diff` purposes)
28+
run: |
29+
git checkout -b pr
30+
git fetch --prune --depth=30 origin +refs/heads/master:refs/remotes/origin/master
31+
git checkout master
32+
git checkout pr
33+
34+
- name: Retrieve dependencies from cache
35+
id: cacheNpm
36+
uses: actions/cache@v2
37+
with:
38+
path: |
39+
~/.npm
40+
node_modules
41+
key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
42+
restore-keys: |
43+
npm-v16-${{ runner.os }}-${{ github.ref }}-
44+
npm-v16-${{ runner.os }}-refs/heads/master-
45+
46+
- name: Set up Python ${{ matrix.python-version }}
47+
uses: actions/setup-python@v1
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
51+
- name: Install Node.js and npm
52+
uses: actions/setup-node@v1
53+
with:
54+
node-version: 16.x
55+
56+
- name: Check python version
57+
run: |
58+
python --version
59+
60+
- name: Install setuptools
61+
run: python -m pip install --force setuptools wheel
62+
63+
- name: Install pipenv / poetry
64+
run: python -m pip install pipenv poetry
65+
66+
- name: Install serverless
67+
run: npm install -g serverless@2
68+
69+
- name: Install dependencies
70+
if: steps.cacheNpm.outputs.cache-hit != 'true'
71+
run: |
72+
npm update --no-save
73+
npm update --save-dev --no-save
74+
- name: Validate Prettier formatting
75+
run: npm run prettier-check:updated
76+
- name: Validate ESLint rules
77+
run: npm run lint:updated
78+
- name: Unit tests
79+
run: script -e -c "npm test"
80+
81+
windowsNode16:
82+
name: '[Windows] Node.js v16: Unit tests'
83+
runs-on: windows-latest
84+
strategy:
85+
matrix:
86+
python-version: [2.7, 3.6]
87+
steps:
88+
- name: Checkout repository
89+
uses: actions/checkout@v2
90+
91+
- name: Retrieve dependencies from cache
92+
id: cacheNpm
93+
uses: actions/cache@v2
94+
with:
95+
path: |
96+
~/.npm
97+
node_modules
98+
key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
99+
restore-keys: |
100+
npm-v16-${{ runner.os }}-${{ github.ref }}-
101+
npm-v16-${{ runner.os }}-refs/heads/master-
102+
103+
- name: Set up Python ${{ matrix.python-version }}
104+
uses: actions/setup-python@v1
105+
with:
106+
python-version: ${{ matrix.python-version }}
107+
108+
- name: Install Node.js and npm
109+
uses: actions/setup-node@v1
110+
with:
111+
node-version: 16.x
112+
113+
- name: Check python version
114+
run: |
115+
python --version
116+
117+
- name: Install setuptools
118+
run: python -m pip install --force setuptools wheel
119+
120+
- name: Install pipenv / poetry
121+
run: python -m pip install pipenv poetry
122+
123+
- name: Install serverless
124+
run: npm install -g serverless@2
125+
126+
- name: Install dependencies
127+
if: steps.cacheNpm.outputs.cache-hit != 'true'
128+
run: |
129+
npm update --no-save
130+
npm update --save-dev --no-save
131+
- name: Unit tests
132+
run: npm test
133+
134+
linuxNode14:
135+
name: '[Linux] Node.js 14: Unit tests'
136+
runs-on: ubuntu-latest
137+
strategy:
138+
matrix:
139+
python-version: [2.7, 3.6]
140+
steps:
141+
- name: Checkout repository
142+
uses: actions/checkout@v2
143+
144+
- name: Retrieve dependencies from cache
145+
id: cacheNpm
146+
uses: actions/cache@v2
147+
with:
148+
path: |
149+
~/.npm
150+
node_modules
151+
key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
152+
restore-keys: |
153+
npm-v14-${{ runner.os }}-${{ github.ref }}-
154+
npm-v14-${{ runner.os }}-refs/heads/master-
155+
156+
- name: Set up Python ${{ matrix.python-version }}
157+
uses: actions/setup-python@v1
158+
with:
159+
python-version: ${{ matrix.python-version }}
160+
161+
- name: Install Node.js and npm
162+
uses: actions/setup-node@v1
163+
with:
164+
node-version: 14.x
165+
166+
- name: Check python version
167+
run: |
168+
python --version
169+
170+
- name: Install setuptools
171+
run: python -m pip install --force setuptools wheel
172+
173+
- name: Install pipenv / poetry
174+
run: python -m pip install pipenv poetry
175+
176+
- name: Install serverless
177+
run: npm install -g serverless@2
178+
179+
- name: Install dependencies
180+
if: steps.cacheNpm.outputs.cache-hit != 'true'
181+
run: |
182+
npm update --no-save
183+
npm update --save-dev --no-save
184+
- name: Unit tests
185+
# Some tests depend on TTY support, which is missing in GA runner
186+
# Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161
187+
run: script -e -c "npm test"
188+
189+
linuxNode12:
190+
name: '[Linux] Node.js v12: Unit tests'
191+
runs-on: ubuntu-latest
192+
strategy:
193+
matrix:
194+
python-version: [2.7, 3.6]
195+
steps:
196+
- name: Checkout repository
197+
uses: actions/checkout@v2
198+
199+
- name: Retrieve dependencies from cache
200+
id: cacheNpm
201+
uses: actions/cache@v2
202+
with:
203+
path: |
204+
~/.npm
205+
node_modules
206+
key: npm-v12-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
207+
restore-keys: |
208+
npm-v12-${{ runner.os }}-${{ github.ref }}-
209+
npm-v12-${{ runner.os }}-refs/heads/master-
210+
211+
- name: Set up Python ${{ matrix.python-version }}
212+
uses: actions/setup-python@v1
213+
with:
214+
python-version: ${{ matrix.python-version }}
215+
216+
- name: Install Node.js and npm
217+
uses: actions/setup-node@v1
218+
with:
219+
node-version: 12.x
220+
221+
- name: Check python version
222+
run: |
223+
python --version
224+
225+
- name: Install setuptools
226+
run: python -m pip install --force setuptools wheel
227+
228+
- name: Install pipenv / poetry
229+
run: python -m pip install pipenv poetry
230+
231+
- name: Install serverless
232+
run: npm install -g serverless@2
233+
234+
- name: Install dependencies
235+
if: steps.cacheNpm.outputs.cache-hit != 'true'
236+
run: |
237+
npm update --no-save
238+
npm update --save-dev --no-save
239+
- name: Unit tests
240+
run: script -e -c "npm test"

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,19 @@
3838
"main": "index.js",
3939
"bin": {},
4040
"scripts": {
41-
"ci:lint": "eslint *.js lib/*.js --format junit --output-file ~/reports/eslint.xml && prettier -c '{.,lib}/*.{js,md}'",
42-
"test": "node test.js",
41+
"format": "prettier --write '{.,lib}/*.{js,md}'",
4342
"lint": "eslint *.js lib/*.js && prettier -c '{.,lib}/*.{js,md}'",
44-
"format": "prettier --write '{.,lib}/*.{js,md}'"
43+
"lint:updated": "pipe-git-updated --ext=js -- eslint",
44+
"prettier-check": "prettier -c --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
45+
"prettier-check:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
46+
"prettify": "prettier --write --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
47+
"prettify:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write",
48+
"test": "node test.js"
4549
},
4650
"devDependencies": {
4751
"cross-spawn": "*",
4852
"eslint": "^7.32.0",
53+
"git-list-updated": "^1.2.1",
4954
"lodash": "^4.17.21",
5055
"prettier": "^2",
5156
"tape": "*",

0 commit comments

Comments
 (0)