-
-
Notifications
You must be signed in to change notification settings - Fork 13
110 lines (104 loc) · 3.3 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
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Node CI
on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:
env:
NODE_ACTIVE_LTS: "16" # see https://nodejs.org/en/about/releases/
jobs:
build:
name: build ${{ matrix.target }}
runs-on: "ubuntu-latest"
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
target:
- node
- web
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:${{ matrix.target }}
- name: artifact build result
# see https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v3
with:
name: dist.${{ matrix.target }}
path: dist.${{ matrix.target }}
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-node:
needs: [ 'build' ]
name: test node (${{ matrix.node-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version:
# action based on https://github.com/actions/node-versions/releases
# see also: https://nodejs.org/en/about/releases/
- "18" # current
- "16" # active LTS
- "14"
- "14.0.0" # lowest supported
os:
- ubuntu-latest
- macos-latest
- windows-latest
timeout-minutes: 30
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"
- name: setup project
run: npm ci --ignore-scripts
- name: fetch build artifact
# see https://github.com/actions/download-artifact
uses: actions/download-artifact@v3
with:
name: dist.node
path: dist.node
- name: test
run: npm run test:node
# test-web:
# TODO via https://github.com/CycloneDX/cyclonedx-javascript-library/issues/51
# TODO test for packages - maybe just `npm ci && npm test` in a matrix?