-
Notifications
You must be signed in to change notification settings - Fork 761
118 lines (102 loc) · 3.21 KB
/
nodejs.yml
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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Update npm
if: startsWith(matrix.node-version, '14')
run: npm install -g npm@9
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Lint commit message
if: github.ref != 'refs/heads/master' && github.actor != 'dependabot[bot]'
run: git log -1 --pretty=format:"%s" | npx commitlint
- name: Lint code
run: npm run lint
- name: Run all tests
run: npm test
env:
CI: true
- name: Build swagger-js
run: npm run build
- name: Upload commonjs build artifacts
if: startsWith(matrix.node-version, '20')
uses: actions/upload-artifact@v4
with:
name: commonjs
path: ./lib/
commonjs-artifacts-test:
name: commonjs-artifacts-test
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Download commonjs build artifacts
uses: actions/download-artifact@v4
with:
name: commonjs
- name: Use Node 12.20.0
uses: actions/setup-node@v4
with:
node-version: 12.20.0
- name: Run commonjs build artifacts on Node.js 12.20.0
run: node -p "require('./commonjs')"
- name: Use Node 14.x
uses: actions/setup-node@v4
with:
node-version: 14.x
- name: Run commonjs build artifacts on Node.js 14.x
run: node -p "require('./commonjs')"
- name: Use Node 16.x
uses: actions/setup-node@v4
with:
node-version: 16.x
- name: Run commonjs build artifacts on Node.js 16.x
run: node -p "require('./commonjs')"
- name: Use Node 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Run commonjs build artifacts on Node.js 18.x
run: node -p "require('./commonjs')"
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Run commonjs build artifacts on Node.js 20.x
run: node -p "require('./commonjs')"