forked from mdaines/viz-js
-
-
Notifications
You must be signed in to change notification settings - Fork 8
167 lines (152 loc) · 5.5 KB
/
ci.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# 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: [main]
pull_request:
branches: [main]
env:
EM_CACHE_FOLDER: "emsdk-cache"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run:
echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: sudo apt update
- name: Install utilities
run: sudo apt install -y automake build-essential git pkg-config unzip
- name: Read emsdk version from Makefile
id: makefile-decipher
run:
awk '$1 ~ /_VERSION$/ { print $1 "=" $3 }' >> "$GITHUB_OUTPUT"
Makefile
- name: Cache emsdk and build dependencies
id: cache-system-libraries
uses: actions/cache@v3
with:
path: |
${{env.EM_CACHE_FOLDER}}
build-deps/**
prefix-full/**
key:
${{ steps.makefile-decipher.outputs.EMSCRIPTEN_VERSION }}-${{
runner.os }}-${{ steps.makefile-decipher.outputs.EXPAT_VERSION
}}-${{ steps.makefile-decipher.outputs.GRAPHVIZ_VERSION }}
- name: Setup emsdk (use cache if found, create otherwise)
uses: mymindstorm/setup-emsdk@v11
with:
version: ${{ steps.makefile-decipher.outputs.EMSCRIPTEN_VERSION }}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
- name: Download and build dependencies
if: steps.cache-system-libraries.outputs.cache-hit != 'true'
run: NODE=$(echo "$EMSDK_NODE") make deps -j2
env:
RUNNER_TEMP: /tmp
CI: true
- name: Build and pack Viz.js
run: NODE=$(echo "$EMSDK_NODE") emmake make pack -j2
env:
VIZ_VERSION: unreleased+${{ github.sha }}
- name: Run tests
run: NODE=$(echo "$EMSDK_NODE") emmake make test -j2
env:
DENO:
VIZ_VERSION: unreleased+${{ github.sha }}
- name: Upload artifact if tests are green
if: success()
uses: actions/upload-artifact@v1
with:
name: viz.js-vunreleased+${{ github.sha }}.tar.gz
path: sources/viz.js-vunreleased+${{ github.sha }}.tar.gz
test-node:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node: [14.x, 16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run:
echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Download tarball from build job
uses: actions/download-artifact@v3
with:
name: viz.js-vunreleased+${{ github.sha }}.tar.gz
- name: Install Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Run tests
run: make test-node -j2
env:
USE_TARBALL: viz.js-vunreleased+${{ github.sha }}.tar.gz
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
test-node-legacy:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node: [v10.x, v12.x]
steps:
- uses: actions/checkout@v3
- name: Download tarball from build job
uses: actions/download-artifact@v3
with:
name: viz.js-vunreleased+${{ github.sha }}.tar.gz
- name: Install Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
env:
RUNNER_TEMP: /tmp
with:
node-version: ${{ matrix.node }}
- name: Prepare tests
run:
rm package.json && npm i mocha@9 && npm i viz.js-vunreleased+${{
github.sha }}.tar.gz && echo 'const assert=require("assert");' >
test/node.cjs && awk '/^describe\(/{o=1} { if (o==1) { print } }'
test/node.js >> test/node.cjs
- name: Run CJS tests
run:
node ./node_modules/.bin/mocha test/node.cjs -f "should render a graph
using sync version"
test-deno:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
deno: [v1.32.5]
steps:
- uses: actions/checkout@v3
- name: Download tarball from build job
uses: actions/download-artifact@v3
with:
name: viz.js-vunreleased+${{ github.sha }}.tar.gz
- name: Install Deno ${{ matrix.deno }}
run:
curl -fsSL https://deno.land/x/install/install.sh | sudo
DENO_INSTALL=/usr/local sh -s ${{ matrix.deno }}
- name: Run tests
run: make test-deno -j2
env:
USE_TARBALL: viz.js-vunreleased+${{ github.sha }}.tar.gz