This repository was archived by the owner on May 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (129 loc) · 4.34 KB
/
Copy pathnode.js.yml
File metadata and controls
140 lines (129 loc) · 4.34 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
# SPDX-FileCopyrightText: 2021 Anders Rune Jensen
#
# SPDX-License-Identifier: Unlicense
# 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: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
licenses:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
test:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- name: npm test
run: DEBUG=jitdb npm test
prepare_for_benchmarks:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm install
- id: set-matrix
run: |
echo "getting benchmark matrix"
BENCHMARKS=$(npm run --silent get-benchmark-matrix)
echo "checking benchmark matrix"
if [ -z "$BENCHMARKS" ]; then
echo "Failed to generate benchmarks"
exit 1
else
echo $BENCHMARKS
echo "::set-output name=matrix::{\"benchmark\":$BENCHMARKS}"
fi
- name: Restore Benchmark Fixture Cache
id: benchmark-fixture-cache
uses: actions/cache@v2
env:
cache-name: cache-benchmark-fixture
with:
path: /tmp/jitdb-benchmark
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json','**/package.json','**/benchmark/**/*.js','**/.github/**/*') }}
- name: Generate Benchmark Fixture
if: steps.benchmark-fixture-cache.outputs.cache-hit != 'true'
run: npm run benchmark-only-create
- name: Upload Benchmark Fixture
uses: actions/upload-artifact@v2
with:
name: benchmark-fixture
path: /tmp/jitdb-benchmark
retention-days: 1
benchmark:
needs:
- test
- prepare_for_benchmarks
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare_for_benchmarks.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm install
- name: Download Benchmark Fixture
uses: actions/download-artifact@v2
with:
name: benchmark-fixture
path: /tmp/jitdb-benchmark
- name: Benchmark
run: BENCHMARK_DURATION_MS=60000 CURRENT_BENCHMARK="${{matrix.benchmark}}" npm run benchmark
- name: Upload Result
uses: actions/upload-artifact@v2
with:
name: ${{matrix.benchmark}}-md
path: /tmp/jitdb-benchmark/benchmark.md
retention-days: 1
benchmark_results:
needs: benchmark
runs-on: ubuntu-latest
steps:
- name: Download Results
uses: actions/download-artifact@v2
with:
path: /tmp/artifacts
- id: get-comment-body
name: Gather results
run: |
body=$(cat /tmp/artifacts/*-md/* | awk '!x[$0]++')
headLineCount=$(printf "$body" | grep -hn '\--' | cut -f1 -d:)
totalLineCount=$(printf "$body" | wc -l | cut -f1 -d" ")
headLines=$(printf "$body" | head -n $headLineCount)
sortedTailLines=$(printf "$body" | tail -n $(($totalLineCount - $headLineCount + 1)) | sort)
body=$(printf "$headLines\n$sortedTailLines")
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Publish comment
uses: mshick/add-pr-comment@v1
continue-on-error: true
with:
message: ${{ steps.get-comment-body.outputs.body }}
repo-token: ${{ secrets.GITHUB_TOKEN }}