forked from ipfs/ipfs-webui
-
Notifications
You must be signed in to change notification settings - Fork 3
101 lines (87 loc) · 3.46 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
93
94
95
96
97
98
99
100
101
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@v2
- name: Use Node.js ${{ inputs.gh-node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ inputs.gh-node-version }}
- name: Remove .npmrc to allow non-strict engines
run: |
rm .npmrc
- name: Get exact nodejs version
id: node_version
run: |
echo "::set-output name=version::$(node --version)"
- name: Cache bigger downloads
uses: actions/cache@v2
id: cache
with:
path: ${{ github.workspace }}/.cache
key: ${{ runner.os }}-${{ inputs.gh-node-version }}-${{ hashFiles('package.json', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-${{ inputs.gh-node-version }}-${{ hashFiles('package.json', 'package-lock.json') }}
${{ runner.os }}-${{ inputs.gh-node-version }}
- name: Install node-pre-gyp
run: |
npm install node-pre-gyp --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm
- name: Install dependencies
run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm
- 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 }}