-
Notifications
You must be signed in to change notification settings - Fork 14
216 lines (211 loc) · 7.65 KB
/
build-linux.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: Build (Linux)
on:
workflow_dispatch:
inputs:
build-type:
description: Build in Release or Debug?
required: true
default: Debug
type: choice
options:
- Debug
- Release
- Release optimized
run-tests:
description: Run the tests?
required: false
default: false
type: boolean
rust-cache:
description: Use existing rust cache?
required: false
default: false
type: boolean
workflow_call:
inputs:
build-type:
required: true
default: Debug
type: string
run-tests:
required: false
default: false
type: boolean
rust-cache:
required: false
default: true
type: boolean
# Required for <compare> and <=> support
env:
CC: gcc-11
CXX: g++-11
jobs:
#
# Build shards for linux
#
Linux:
name: Build (${{ github.event.inputs.build-type || inputs.build-type }})
runs-on: ubuntu-22.04
outputs:
build-type: ${{ steps.setup.outputs.build-type }}
run-tests: ${{ steps.setup.outputs.run-tests }}
rust-cache: ${{ steps.setup.outputs.rust-cache }}
artifact-name: shards-linux ${{ steps.setup.outputs.build-type }}
steps:
- name: Setup
id: setup
run: |
if [ "${{ github.event.inputs.build-type || inputs.build-type }}" == "Release optimized" ]
then
echo "build-type=Release" >> $GITHUB_OUTPUT
echo "optimized=true" >> $GITHUB_OUTPUT
else
echo "build-type=${{ github.event.inputs.build-type || inputs.build-type }}" >> $GITHUB_OUTPUT
echo "optimized=false" >> $GITHUB_OUTPUT
fi
echo "run-tests=${{ github.event.inputs.run-tests || inputs.run-tests }}" >> $GITHUB_OUTPUT
echo "rust-cache=${{ github.event.inputs.rust-cache || inputs.rust-cache }}" >> $GITHUB_OUTPUT
- name: Checkout shards
uses: actions/checkout@v3
with:
repository: fragcolor-xyz/shards
fetch-depth: 2
submodules: recursive
- name: Set up dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install build-essential git cmake wget clang ninja-build xorg-dev libdbus-1-dev libssl-dev lcov mesa-utils libgtk-3-dev
./bootstrap
RUSTUP_TOOLCHAIN=`cat rust.version`
echo "RUSTUP_TOOLCHAIN=$RUSTUP_TOOLCHAIN" >> $GITHUB_ENV
rustup toolchain install $RUSTUP_TOOLCHAIN
- uses: Swatinem/rust-cache@v2
if: ${{ steps.setup.outputs.rust-cache == 'true'}}
with:
key: ${{ steps.setup.outputs.build-type }}
- name: Build
run: |
mkdir -p build
cd build
if [ "${{ steps.setup.outputs.build-type }}" == "Debug" ]; then
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=1 -DUSE_UBSAN=ON -DTRACY_ENABLE=ON -DTRACY_TIMER_FALLBACK=ON ..
else
cmake -G Ninja -DGNU_STATIC_BUILD=ON -DSKIP_HEAVY_INLINE=${{ steps.setup.outputs.optimized == 'false' }} -DCMAKE_BUILD_TYPE=Release ..
fi
ninja shards
- name: Test
env:
RUST_BACKTRACE: full
run: |
cd build
chmod +x shards
./shards new ../shards/tests/hello.shs
./shards new ../shards/tests/general.shs
./shards new ../shards/tests/table-compose.shs
./shards ../shards/tests/variables.edn
./shards new ../shards/tests/subwires.shs
./shards new ../shards/tests/linalg.shs
./shards ../shards/tests/loader.clj
./shards new ../shards/tests/network.shs
./shards new ../shards/tests/struct.shs
./shards new ../shards/tests/flows.shs
./shards new ../shards/tests/kdtree.shs
./shards new ../shards/tests/channels.shs
./shards new ../shards/tests/genetic.shs
./shards new ../shards/tests/imaging.shs
./shards new ../shards/tests/http.shs
./shards ../shards/tests/ws.edn
./shards new ../shards/tests/bigint.shs
./shards new ../shards/tests/brotli.shs
./shards new ../shards/tests/snappy.shs
./shards new ../shards/tests/expect.shs
./shards new ../shards/tests/failures.shs
./shards ../shards/tests/wasm.clj
./shards ../shards/tests/rust.clj
./shards new ../shards/tests/crypto.shs
./shards ../shards/tests/wire-macro.edn
./shards new ../shards/tests/const-vars.shs
./shards new ../shards/tests/branch.shs
./shards ../shards/tests/time.edn
./shards new ../shards/tests/eth.shs
./shards ../shards/tests/take.edn
./shards new ../shards/tests/casting-numbers.shs
./shards new ../shards/tests/pure.shs
# ./shards new ../shards/tests/shell.shs
./shards ../shards/tests/infos.clj
./shards ../shards/tests/many.edn
./shards new ../shards/tests/events.shs
./shards ../shards/tests/tablecase.edn
./shards ../shards/tests/types.edn
./shards new ../shards/tests/complex-deserialize.shs
./shards new ../shards/tests/db.shs
./shards new ../shards/tests/suspend-resume.shs
./shards new ../shards/tests/help.shs
- name: Test (Debug)
# Test that only works in Debug build go there
if: ${{ steps.setup.outputs.build-type == 'Debug' }}
env:
RUST_BACKTRACE: full
run: |
cd build
./shards ../shards/tests/export-strings.edn
./shards new ../shards/tests/audio.shs test-device:true
- name: Test doc samples (non-UI)
env:
RUST_BACKTRACE: full
run: |
cd docs/samples
for i in $(find shards -name '*.edn' \( ! -path '*UI*' ! -path '*GFX*' ! -path '*Dialog*' \));
do
echo "Running sample $i";
../../build/shards run-sample.edn --file "$i";
done
- name: Test runtime
env:
RUST_BACKTRACE: full
run: |
cd build
ninja test-runtime
./test-runtime
# Minimize disk usage to prevent the next steps getting stuck due to no disk space
- name: Minimize disk usage
env:
RUST_BACKTRACE: full
shell: bash
run: |
rm -rf build/target
rm -rf build/lib
rm -rf build/deps
rm -rf build/_deps
rm -rf build/.cache
- name: Collect coverage (Debug)
if: ${{ steps.setup.outputs.build-type == 'Debug' }}
run: |
mkdir coverage
# capture
lcov \
--capture \
--directory build/src \
--directory build/modules \
--output-file coverage/coverage.info
# remove external dependencies
lcov \
--remove coverage/coverage.info "*/c++/*" "*/boost/*" "*/usr/*" "*/deps/*" "*/shards/mal/*" \
--output-file coverage/coverage.linux.info
# convert absolute path to relative path
sed -i s/${PWD////\\/}/./g coverage/coverage.linux.info
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: shards-linux ${{ steps.setup.outputs.build-type }}
path: build/shards
if-no-files-found: error
retention-days: 1
- name: Upload coverage (Debug)
if: ${{ steps.setup.outputs.build-type == 'Debug' }}
uses: actions/upload-artifact@v3
with:
name: shards-linux-coverage
path: coverage/coverage.linux.info
if-no-files-found: error
retention-days: 1