-
Notifications
You must be signed in to change notification settings - Fork 28
146 lines (135 loc) · 4.75 KB
/
prebuild-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
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
name: prebuild-test
run-name: Prebuild tests (${{ inputs.runtime }} [${{ inputs.targets }}])
on:
workflow_dispatch:
inputs:
runtime:
description: 'Prebuild runtime'
type: choice
required: true
default: node
options:
- node
- electron
targets:
description: 'Runtime versions (targets)'
required: true
default: -t 18.0.0
ubuntu-20.04:
description: 'Test on ubuntu-20.04'
type: boolean
default: true
windows-2019:
description: 'Test on windows-2019'
type: boolean
default: true
macos-13:
description: 'Test on macos-13'
type: boolean
default: true
alpine:
description: 'Test on Alpine-Linux'
type: boolean
arm:
description: 'Test on ARM(v7/64) architectures'
type: boolean
env:
TEST_COMMAND: npx --no-install prebuild -r ${{ inputs.runtime }} ${{ inputs.targets }} --include-regex 'better_sqlite3.node$'
jobs:
input-setup:
if: inputs['ubuntu-20.04'] == true || inputs['windows-2019'] == true || inputs['macos-13'] == true
name: Preparing tests
runs-on: ubuntu-latest
outputs:
platforms: ${{ steps.set-platforms.outputs.platforms }}
steps:
- name: Setting up platform matrix
id: set-platforms
run: |
INPUTS='${{ toJSON(inputs) }}'
PLATFORMS='{"os":[]}'
for os in 'ubuntu-20.04' 'windows-2019' 'macos-13'
do
if [ "$(jq ".[\"$os\"]" <<< "$INPUTS")" = "true" ]; then PLATFORMS=$(jq -c ".os += [\"$os\"]" <<< "$PLATFORMS"); fi
done
echo "platforms=$PLATFORMS" >> $GITHUB_OUTPUT
prebuild-test:
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.input-setup.outputs.platforms) }}
name: Testing prebuild on ${{ matrix.os }}
needs: input-setup
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- if: ${{ startsWith(matrix.os, 'windows') }}
run: pip.exe install setuptools
- if: ${{ startsWith(matrix.os, 'macos') }}
run: brew install python-setuptools
- if: ${{ !startsWith(matrix.os, 'windows') && !startsWith(matrix.os, 'macos') }}
run: python3 -m pip install setuptools
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install gcc-10 g++-10 -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
- run: npm install --ignore-scripts
- run: ${{ env.TEST_COMMAND }}
- if: matrix.os == 'windows-2019' && inputs.arm == true
run: ${{ env.TEST_COMMAND }} --arch arm64
prebuild-test-mac-arm64:
if: inputs.macos-13 == true && inputs.arm == true
name: Testing prebuild on M1 macOS (arm64)
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: brew install python-setuptools
- run: npm install --ignore-scripts
- run: ${{ env.TEST_COMMAND }}
prebuild-test-alpine-linux:
if: inputs.alpine == true
name: Testing prebuild on Alpine-Linux (x64)
runs-on: ubuntu-latest
container: node:18-alpine
steps:
- uses: actions/checkout@v4
- run: apk add build-base git python3 py3-setuptools --update-cache
- run: npm install --ignore-scripts
- run: ${{ env.TEST_COMMAND }}
prebuild-test-alpine-linux-arm64:
if: inputs.alpine == true && inputs.arm == true
name: Testing prebuild on Alpine-Linux (arm64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- run: |
docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/arm64 node:18-alpine -c "\
apk add build-base git python3 py3-setuptools --update-cache && \
cd /tmp/project && \
npm install --ignore-scripts && \
${{ env.TEST_COMMAND }}"
prebuild-test-linux-arm:
if: inputs['ubuntu-20.04'] == true && inputs.arm == true
strategy:
fail-fast: false
matrix:
arch:
- arm/v7
- arm64
name: Testing prebuild on Linux (${{ matrix.arch }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- run: |
docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch }} node:18-bullseye -c "\
cd /tmp/project && \
npm install --ignore-scripts && \
${{ env.TEST_COMMAND }}"