-
-
Notifications
You must be signed in to change notification settings - Fork 45
175 lines (163 loc) · 6.39 KB
/
pr-build.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
168
169
170
171
172
173
174
175
name: PR Build
on:
workflow_dispatch:
inputs:
deps_rev_override:
description: 'Deps Revision Override'
type: string
default: ''
required: false
pull_request:
paths:
- '**'
- '!.github/**'
- '!**.md'
concurrency:
group: pr-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: PR Build host=${{ matrix.config.host }} cmd=${{ matrix.config.cmd }} target=${{ matrix.config.target }} mode=${{ matrix.config.mode }}
runs-on: ${{ matrix.config.host }}
strategy:
fail-fast: false
matrix:
config:
- host: ubuntu-22.04
target: x86_64-linux-gnu
mode: release
cmd: cli
- host: ubuntu-22.04
target: x86_64-selinux-gnu
mode: release
cmd: cli
- host: macos-12
target: x86_64-macos-none
mode: release
cmd: cli
- host: macos-14
target: aarch64-macos-none
mode: release
cmd: cli
- host: windows-2022
target: x86_64-windows-gnu
mode: release
cmd: cli
- host: ubuntu-22.04
target: wasm32-freestanding
mode: release
cmd: web-lib
- host: ubuntu-22.04
target: wasm32-wasi
mode: release
cmd: cli
- host: windows-2022
target: x86_64-windows-gnu
mode: release
cmd: lib
- host: windows-2022
target: x86_64-windows-msvc
mode: release
cmd: lib
- host: ubuntu-22.04
target: x86_64-linux-gnu
mode: release
cmd: lib
- host: macos-12
target: x86_64-macos-none
mode: release
cmd: lib
- host: macos-14
target: aarch64-macos-none
mode: release
cmd: lib
env:
ZIG_TARGET_FLAG: >-
${{ fromJson('{
"x86_64-windows-gnu": "-Dtarget=x86_64-windows-gnu -Dcpu=baseline",
"x86_64-windows-msvc": "-Dtarget=x86_64-windows-msvc -Dcpu=baseline",
"x86_64-linux-gnu": "-Dtarget=x86_64-linux-gnu -Dcpu=baseline",
"x86_64-selinux-gnu": "-Dtarget=x86_64-linux-gnu -Dcpu=baseline -Dselinux",
"x86_64-macos-none": "-Dtarget=x86_64-macos-none -Dcpu=baseline",
"aarch64-macos-none": "-Dtarget=aarch64-macos-none -Dcpu=baseline",
"wasm32-freestanding": "-Dtarget=wasm32-freestanding",
"wasm32-wasi": "-Dtarget=wasm32-wasi",
}')[matrix.config.target] }}
BUILD_HOST: ${{ matrix.config.host }}
BUILD_TARGET: ${{ matrix.config.target }}
BUILD_CMD: ${{ matrix.config.cmd }}
BUILD_MODE: ${{ matrix.config.mode }}
BIN_EXT: ${{ contains(matrix.config.target, 'windows') && '.exe' || '' }}
ZIG_MODE_FLAG: ${{ (matrix.config.mode == 'release' && '-Doptimize=ReleaseFast') || '' }}
ZIG_VERSION: 0.12.0
steps:
- name: Install Linux deps.
if: env.BUILD_HOST == 'ubuntu-22.04' && env.BUILD_TARGET == 'x86_64-linux-gnu'
run: |
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse"
sudo apt-get update -y -qq
sudo apt-get install xz-utils
- name: Clone repo.
uses: actions/checkout@v2
with:
fetch-depth: 1
#submodules: recursive
- name: Install zig.
if: env.BUILD_HOST == 'ubuntu-22.04'
run: |
wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
- name: Install wasm3.
if: env.BUILD_HOST == 'ubuntu-22.04' && (env.BUILD_TARGET == 'wasm32-freestanding' || env.BUILD_TARGET == 'wasm32-wasi')
run: |
git clone --depth=1 https://github.com/wasm3/wasm3.git
cd wasm3
mkdir build
cd build
cmake ..
make
- name: Install zig.
if: env.BUILD_HOST == 'macos-12'
run: |
wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
xcode-select --print-path
- name: Install zig.
if: env.BUILD_HOST == 'macos-14'
run: |
wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-macos-aarch64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
xcode-select --print-path
- name: Install zig.
if: env.BUILD_HOST == 'windows-2022'
run: |
Invoke-WebRequest -Uri 'https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-windows-x86_64-${{ env.ZIG_VERSION }}.zip' -OutFile 'C:\zig.zip'
cd C:\
7z x zig.zip
Add-Content $env:GITHUB_PATH 'C:\zig-windows-x86_64-${{ env.ZIG_VERSION }}\'
- name: Cache.
uses: actions/cache@v2
with:
path: |-
~/.cache/zig
zig-cache
~/AppData/Local/zig
key:
pr-build-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-1
restore-keys:
pr-build-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-1
- name: Run tests. (debug)
if: env.BUILD_TARGET != 'wasm32-wasi' && (env.BUILD_CMD == 'cli' || (env.BUILD_CMD == 'lib' && env.BUILD_TARGET != 'x86_64-windows-msvc'))
run: |
zig build test ${{ env.ZIG_TARGET_FLAG }}
# Optimize with ReleaseSafe since there are issues with Zig 0.11.0 and building tests for ReleaseFast.
- name: Run tests. (release)
if: env.BUILD_TARGET != 'wasm32-wasi' && (env.BUILD_CMD == 'cli' || (env.BUILD_CMD == 'lib' && env.BUILD_TARGET != 'x86_64-windows-msvc'))
run: |
zig build test ${{ env.ZIG_TARGET_FLAG }} -Doptimize=ReleaseFast
- name: Run tests.
if: env.BUILD_TARGET == 'wasm32-freestanding' || env.BUILD_TARGET == 'wasm32-wasi'
run: |
zig build build-test -Dtarget=wasm32-wasi ${{ env.ZIG_MODE_FLAG }}
wasm3/build/wasm3 zig-out/bin/unit_test.wasm
wasm3/build/wasm3 zig-out/bin/test.wasm
wasm3/build/wasm3 zig-out/bin/trace_test.wasm
- name: Build.
run: zig build ${{ env.BUILD_CMD }} ${{ env.ZIG_MODE_FLAG }} ${{ env.ZIG_TARGET_FLAG }}