-
-
Notifications
You must be signed in to change notification settings - Fork 11
153 lines (148 loc) · 4.75 KB
/
nodejs.yml
File metadata and controls
153 lines (148 loc) · 4.75 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
# For details of what checks are run for PRs please refer below
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Node CI
on:
push:
branches: [ "master" ]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REPORTS_DIR: CI_reports
NODE_ACTIVE_LTS: "20" # https://nodejs.org/en/about/releases/
jobs:
build:
name: build ${{ matrix.target }}
runs-on: "ubuntu-latest"
timeout-minutes: 30
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v3
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_ACTIVE_LTS }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: setup project
run: npm ci --ignore-scripts
- name: build ${{ matrix.target }}
run: npm run build
- name: artifact build result
# see https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
if-no-files-found: error
test-standard:
name: test standard
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v3
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_ACTIVE_LTS }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: setup project
run: npm ci --ignore-scripts
- name: test
run: npm run test:standard
test-jest:
needs: [ 'build' ]
name: test:Jest (node${{ matrix.node-version }}, ${{ matrix.os }})
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
node-version:
# action based on https://github.com/actions/node-versions/releases
# see also: https://nodejs.org/en/about/releases/
- "20" # current
- "18" # active LTS
- '16'
- "14"
env:
REPORTS_ARTIFACT: tests-reports
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- # some integration tests require a certain npm version to be installable
name: update npm
run: npm i -g npm@^8
- name: display version
run: |-
node --version
npm --version
- name: install project
shell: bash
run: |
set -ex
npm ci --ignore-scripts --loglevel=silly
## rebuild deps for which scripts were ignored, or partially installed - since "ignore-scripts" was used
npm rebuild --loglevel=silly libxmljs2 || npm uninstall --no-save libxmljs2
- name: fetch build artifact
# see https://github.com/actions/download-artifact
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: setup test beds
run: npm run -- setup-tests --install-links
- name: test
run: npm run test:jest
test-examples:
needs: [ 'build' ]
name: Example ${{ matrix.scope }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
scope:
- simple
env:
EXAMPLE_DIR: examples/${{ matrix.scope }}
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v3
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_ACTIVE_LTS }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: fetch build artifact
# see https://github.com/actions/download-artifact
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: setup example
working-directory: ${{ env.EXAMPLE_DIR }}
run: npm i --install-links --loglevel=silly
- name: build example
working-directory: ${{ env.EXAMPLE_DIR }}
run: npm run build