-
Notifications
You must be signed in to change notification settings - Fork 92
60 lines (48 loc) · 1.74 KB
/
build-and-test.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
# 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: Build and Test
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
node-version: ['16', '18']
# OS-specific commands/variables
include:
- os: ubuntu-latest
cmd_build: npm run build
- os: windows-latest
cmd_build: node .\scripts\package.js
runs-on: ${{matrix.os}}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# https://github.com/actions/setup-node/issues/280#issuecomment-1139455898
- name: Update node-gyp (windows only)
if: startsWith(matrix.os, 'windows')
run: |
$WhereNode = Get-Command node | Select-Object -ExpandProperty Definition
$NodeDirPath = Split-Path $WhereNode -Parent
$NodeModulesPath = $NodeDirPath + "\node_modules\npm\node_modules\@npmcli\run-script"
cd $NodeModulesPath
npm install node-gyp@latest
- name: Install dependencies (linux only)
if: matrix.os == 'ubuntu-latest'
run: sudo apt update && sudo apt install libudev-dev libusb-1.0-0-dev -y
- name: Install npm packages
run: npm i
- name: Build
run: ${{ matrix.cmd_build }}
- name: Test
run: npm test