-
Notifications
You must be signed in to change notification settings - Fork 2
116 lines (101 loc) · 3.73 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
111
112
113
114
115
116
# 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: Node.js CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.2.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Install LLVM 16 and lcov
run: |
rm -rf build
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key 2>/dev/null | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' -y
sudo apt-get update -q
sudo apt-get install -y clang-16 llvm-16 lld-16 libc++-16-dev libc++abi-16-dev clang-tools-16 clang-16-doc wasi-libc llvm-16-doc binutils ninja-build
wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1-linux-x86_64.sh
sudo chmod +x cmake-3.24.1-linux-x86_64.sh
sudo ./cmake-3.24.1-linux-x86_64.sh --prefix=/usr --skip-license
shell: bash
- name: Gtest C++ Test
run: yarn test
env:
CI: true
NODE_ENV: test
CC: clang-16
CXX: clang++-16
- name: Generate coverage
run: yarn coverage lcov
env:
CI: true
NODE_ENV: test
CC: clang-16
CXX: clang++-16
- name: Publish Test Results
id: test-results
run: node scripts/ci-test-result-parse.cjs
if: always()
- name: Set badge color
shell: bash
run: |
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
success)
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
;;
failure)
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
;;
neutral)
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
;;
esac
- name: Create badge
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
with:
label: Tests
status: '${{ fromJSON( steps.test-results.outputs.json ).stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}'
color: ${{ env.BADGE_COLOR }}
style: flat
path: badge.svg
- name: Upload badge to Gist
# Upload only for main branch
if: >
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' ||
github.event_name != 'workflow_run' && github.ref == 'refs/heads/main'
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/yi-ge/cfafaf2ba23090ed9f8aa8fc875c9ce5
file: badge.svg
- name: Coveralls
uses: coverallsapp/[email protected]
env:
NODE_COVERALLS_DEBUG: 1
with:
github-token: ${{ secrets.github_token }}
parallel: true
flag-name: Unit
finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true