-
Notifications
You must be signed in to change notification settings - Fork 5
236 lines (224 loc) · 8.38 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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: CI
on:
push:
branches:
- main
- 'build/**'
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
env:
NIGHTLY_TOOLCHAIN: nightly-2023-12-30
jobs:
check:
name: Run checks
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install SQLx CLI
run: |
mkdir -p ~/.local/bin
curl -L https://development-content.brioche.dev/tools/sqlx-cli_v0.7.1/sqlx -o ~/.local/bin/sqlx
curl -L https://development-content.brioche.dev/tools/sqlx-cli_v0.7.1/cargo-sqlx -o ~/.local/bin/cargo-sqlx
chmod +x ~/.local/bin/sqlx ~/.local/bin/cargo-sqlx
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Check formatting
run: cargo fmt -- --check
- name: Check database schema
run: make check-db-schema
- name: Check Clippy
run: cargo clippy --all -- -Dwarnings
- name: Install runtime distribution packages
run: |
cd crates/brioche-core/runtime
npm install
- name: Check runtime distribution types
run: |
cd crates/brioche-core/runtime
npm run check
- name: Check runtime distribution is up to date
run: |
cd crates/brioche-core/runtime
npm install
npm run build
if [ -n "$(git status --porcelain)" ]; then
git status
echo "NPM build in crates/brioche/runtime is out of date!" >&2
echo "Re-run 'npm run build' and commit the results" >&2
exit 1
fi
test:
name: Run tests
strategy:
matrix:
runs_on:
- ubuntu-22.04
- macos-14
runs-on: ${{ matrix.runs_on }}
steps:
- name: Checkout code
uses: actions/checkout@v4
# Run tests in release mode. Running tests in debug mode uses a lot
# more disk space, so much so that it can cause the run to fail
- name: Run tests
run: cargo test --all --release
build:
name: Build artifacts
if: github.event_name == 'push'
strategy:
matrix:
platform:
- name: x86_64-linux
runs_on: ubuntu-22.04
target: x86_64-unknown-linux-gnu
tools_target: x86_64-unknown-linux-musl
packed_exec: brioche-packed-userland-exec
- name: x86_64-macos
runs_on: macos-14
target: x86_64-apple-darwin
tools_target: x86_64-apple-darwin
packed_exec: brioche-packed-plain-exec
- name: aarch64-macos
runs_on: macos-14
target: aarch64-apple-darwin
tools_target: aarch64-apple-darwin
packed_exec: brioche-packed-plain-exec
runs-on: ${{ matrix.platform.runs_on }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust targets
run: rustup target add "$TARGET" "$TOOLS_TARGET"
env:
TARGET: ${{ matrix.platform.target }}
TOOLS_TARGET: ${{ matrix.platform.tools_target }}
- name: Install Rust nightly toolchain
run: |
rustup toolchain install "$NIGHTLY_TOOLCHAIN" \
--target "$TOOLS_TARGET" \
--component rust-src
env:
TOOLS_TARGET: ${{ matrix.platform.tools_target }}
- name: Build Brioche
run: |
cargo build \
--all \
--bin brioche \
--release \
--target="$TARGET"
env:
TARGET: ${{ matrix.platform.target }}
- name: Build brioche-pack tools
run: |
cargo build \
--all \
--bin brioche-packer \
--bin brioche-ld \
--release \
--target="$TOOLS_TARGET"
cargo +"$NIGHTLY_TOOLCHAIN" build \
--all \
--bin brioche-packed-plain-exec \
--bin brioche-packed-userland-exec \
--profile=release-tiny \
--target="$TOOLS_TARGET" \
-Z 'build-std=std,panic_abort' \
-Z 'build-std-features=panic_immediate_abort'
env:
TOOLS_TARGET: ${{ matrix.platform.tools_target }}
- name: Prepare artifact
run: |
mkdir -p "artifacts/brioche/$PLATFORM/"
mkdir -p "artifacts/brioche-pack/$PLATFORM/bin/"
cp \
"target/$TARGET/release/brioche" \
"artifacts/brioche/$PLATFORM/"
cp \
"target/$TOOLS_TARGET/release/brioche-packer" \
"target/$TOOLS_TARGET/release/brioche-ld" \
"target/$TOOLS_TARGET/release-tiny/brioche-packed-plain-exec" \
"target/$TOOLS_TARGET/release-tiny/brioche-packed-userland-exec" \
"artifacts/brioche-pack/$PLATFORM/bin/"
cp "artifacts/brioche-pack/$PLATFORM/bin/$PACKED_EXEC" "artifacts/brioche-pack/$PLATFORM/bin/brioche-packed-exec"
(cd "artifacts/brioche-pack/$PLATFORM/" && tar --zstd -cf "../../brioche/$PLATFORM/brioche-pack.tar.zstd" .)
if command -v tree &> /dev/null; then
tree --du -h artifacts/brioche-pack
tree --du -h artifacts/brioche
fi
env:
PLATFORM: ${{ matrix.platform.name }}
TARGET: ${{ matrix.platform.target }}
TOOLS_TARGET: ${{ matrix.platform.tools_target }}
PACKED_EXEC: ${{ matrix.platform.packed_exec }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: brioche-${{ matrix.platform.name }}
if-no-files-found: error
path: artifacts/brioche
push:
name: Push artifacts
if: github.event_name == 'push' && github.repository == 'brioche-dev/brioche'
needs: [check, test, build]
runs-on: ubuntu-22.04
steps:
- name: Download artifacts (x86_64-linux)
uses: actions/download-artifact@v4
with:
name: brioche-x86_64-linux
path: artifacts/brioche
- name: Download artifacts (x86_64-macos)
uses: actions/download-artifact@v4
with:
name: brioche-x86_64-macos
path: artifacts/brioche
- name: Download artifacts (aarch64-macos)
uses: actions/download-artifact@v4
with:
name: brioche-aarch64-macos
path: artifacts/brioche
# Prepare the upload for the current commit and branch:
# - The current branch will be uploaded with all artifacts
# - The current commit will be uploaded with most artifacts (with some
# exceptions to avoid wasting space)
# - The current files from the bucket will be downloaded first,
# so that existing files are not overwritten. This is so that file
# hashes never change under the commit e.g. if the GitHub Actions
# workflow is re-run
- name: Prepare upload
run: |
mkdir -p artifacts/uploads/commit artifacts/uploads/branch
cp -r artifacts/brioche/* artifacts/uploads/commit/
cp -r artifacts/brioche/* artifacts/uploads/branch/
rm artifacts/uploads/commit/*/brioche
if command -v tree &> /dev/null; then
tree --du -h artifacts/uploads/commit
tree --du -h artifacts/uploads/branch
fi
aws s3 sync \
--endpoint "$S3_ENDPOINT" \
"s3://brioche-dev-development-content/github.com/brioche-dev/brioche/commits/$GITHUB_SHA/" \
artifacts/uploads/commit/
env:
AWS_ACCESS_KEY_ID: ${{ secrets.R2_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_S3_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ vars.R2_S3_REGION }}
S3_ENDPOINT: ${{ secrets.R2_S3_ENDPOINT }}
- name: Upload to S3
run: |
aws s3 sync \
--endpoint "$S3_ENDPOINT" \
--delete \
artifacts/uploads/branch/ \
"s3://brioche-dev-development-content/github.com/brioche-dev/brioche/branches/$GITHUB_REF_NAME/"
aws s3 sync \
--endpoint "$S3_ENDPOINT" \
--delete \
artifacts/uploads/commit/ \
"s3://brioche-dev-development-content/github.com/brioche-dev/brioche/commits/$GITHUB_SHA/"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.R2_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_S3_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ vars.R2_S3_REGION }}
S3_ENDPOINT: ${{ secrets.R2_S3_ENDPOINT }}