-
Notifications
You must be signed in to change notification settings - Fork 10
81 lines (68 loc) · 2.25 KB
/
test-wasm.reusable.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
# SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
# SPDX-License-Identifier: MIT
name: Test WASM (reusable)
on:
workflow_call:
inputs:
go-version:
required: true
type: string
permissions:
contents: read
jobs:
test-wasm:
runs-on: ubuntu-24.04
name: WASM
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache
key: ${{ runner.os }}-wasm-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-wasm-go-
- name: Download Go
run: |
version=$(
curl -s 'https://go.dev/dl/?mode=json&include=all' \
| jq -r '.[].version | select(startswith("go${{ inputs.go-version }}."))' \
| sort -V \
| tail -n 1
)
curl -sSfL https://dl.google.com/go/${version}.linux-amd64.tar.gz | tar -C ~ -xzf -
- name: Node version
id: node-version
run: |
if [ '${{ inputs.go-version }}' = '1.20' ]; then
# Go 1.20's wasm_exec_node.js doesn't work with Node v20
# This can be removed once all pion repositories are switched to use Go 1.22
echo 'version=16' | tee -a ${GITHUB_OUTPUT}
fi
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '${{ steps.node-version.outputs.version || 20 }}.x'
- name: Set Go Root
run: echo "GOROOT=${HOME}/go" >> $GITHUB_ENV
- name: Set Go Path
run: echo "GOPATH=${HOME}/go" >> $GITHUB_ENV
- name: Set Go Path
run: echo "GO_JS_WASM_EXEC=${GOROOT}/misc/wasm/go_js_wasm_exec" >> $GITHUB_ENV
- name: Install NPM modules
run: yarn install
- name: Run Tests
run: |
if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi
GOOS=js GOARCH=wasm \
${GOPATH}/bin/go test \
-coverprofile=cover.out \
-covermode=atomic \
-exec="${GO_JS_WASM_EXEC}" \
-v ./...
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
flags: wasm
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }}