92 lines (79 loc) · 2.94 KB
/
node-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
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
name: Test NodeJS
on:
workflow_call:
inputs:
gh-node-version:
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.gh-node-version }}
cancel-in-progress: true
jobs:
reset-badge:
runs-on: ubuntu-latest
steps:
- name: "Reset ${{ inputs.gh-node-version }} badge"
if: github.ref == 'refs/heads/main'
uses: RubbaBoy/BYOB@24f464284c1fd32028524b59607d417a2e36fee7
with:
icon: https://raw.githubusercontent.com/devicons/devicon/master/icons/nodejs/nodejs-original.svg
name: "node-${{ inputs.gh-node-version }}"
label: "${{ inputs.gh-node-version }}"
status: "Building..."
color: grey
github_token: ${{ secrets.GITHUB_TOKEN }}
test-node:
needs: [reset-badge]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
outputs:
node-version: ${{ steps.node_version.outputs.version }}
steps:
- uses: actions/checkout@v4.1.2
- name: Use Node.js ${{ inputs.gh-node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.gh-node-version }}
cache: 'npm'
- name: Remove .npmrc to allow non-strict engines
run: |
rm .npmrc
- name: Get exact nodejs version
id: node_version
run: |
echo "version=$(node --version)" >> $GITHUB_OUTPUT
- name: Install node-pre-gyp
run: |
npm install node-pre-gyp --prefer-offline --no-audit --progress=false
- name: Install dependencies
run: npm install --progress=false
- name: Confirm build works with Node.js ${{ inputs.gh-node-version }} on ${{ matrix.os }}
run: npm run build
create-badges:
needs: [test-node]
runs-on: ubuntu-latest
if: always()
steps:
- name: Create success badge
if: ${{ needs.test-node.result == 'success' && github.ref == 'refs/heads/main' }}
uses: RubbaBoy/BYOB@24f464284c1fd32028524b59607d417a2e36fee7
with:
icon: https://raw.githubusercontent.com/devicons/devicon/master/icons/nodejs/nodejs-original.svg
name: "node-${{ inputs.gh-node-version }}"
label: "${{ needs.test-node.outputs.node-version }}"
status: ${{needs.test-node.result}}
color: green
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create failure badge
if: ${{ needs.test-node.result != 'success' && github.ref == 'refs/heads/main' }}
uses: RubbaBoy/BYOB@24f464284c1fd32028524b59607d417a2e36fee7
with:
icon: https://raw.githubusercontent.com/devicons/devicon/master/icons/nodejs/nodejs-original.svg
name: "node-${{ inputs.gh-node-version }}"
label: "${{ needs.test-node.outputs.node-version }}"
status: ${{needs.test-node.result}}
color: red
github_token: ${{ secrets.GITHUB_TOKEN }}