This repository was archived by the owner on Aug 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
215 lines (183 loc) · 6.71 KB
/
Copy pathrust.yml
File metadata and controls
215 lines (183 loc) · 6.71 KB
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
name: CI
on:
push:
branches: [ main, ci ]
tags:
- "*.*.*"
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
precheck:
name: Miscellaneous checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cargo.toml version consistency
run: |
set -e
MODUS_LIB_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="modus-lib").version')
MODUS_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="modus").version')
if [ "$MODUS_LIB_VERSION" != "$MODUS_VERSION" ]; then
echo "modus-lib and modus versions do not match"
exit 1
fi
echo "MODUS_VERSION=$MODUS_VERSION" >> $GITHUB_ENV
- name: Tag and Cargo.toml version consistency
if: github.ref_type == 'tag'
run: |
set -u
if [ "$MODUS_VERSION" != "$GITHUB_REF_NAME" ]; then
echo "git tag does not match Cargo.toml version..."
echo "Please delete the tag with git push --delete origin $GITHUB_REF_NAME, change the version in the two Cargo.toml, and re-tag."
exit 1
fi
build-x86_64:
name: Build x86_64 binary
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# For some reason, native musl toolchain (apt musl-tools) doesn't work
# (produce binaries that just segfault/crash with "no such file")
- name: Build tools setup
run: >
rustup target add x86_64-unknown-linux-musl &&
wget https://more.musl.cc/x86_64-linux-musl/x86_64-linux-musl-cross.tgz -O /tmp/musl.tgz &&
(
cd ~/ &&
tar xf /tmp/musl.tgz &&
cd x86_64-linux-musl-cross &&
echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=$(pwd)/bin/x86_64-linux-musl-cc" >> $GITHUB_ENV &&
echo "CC_x86_64_unknown_linux_musl=$(pwd)/bin/x86_64-linux-musl-cc" >> $GITHUB_ENV
) &&
export $(cat "$GITHUB_ENV")
- name: Compile
run: cargo build --verbose --release --target x86_64-unknown-linux-musl
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: x86_64-linux-musl
path: |
target/x86_64-unknown-linux-musl/release/modus
target/x86_64-unknown-linux-musl/release/buildkit-frontend
build-aarch64:
name: Build ARM binary
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build tools setup
run: >
rustup target add aarch64-unknown-linux-musl &&
wget https://more.musl.cc/x86_64-linux-musl/aarch64-linux-musl-cross.tgz -O /tmp/musl.tgz &&
(
cd ~/ &&
tar xf /tmp/musl.tgz &&
cd aarch64-linux-musl-cross &&
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=$(pwd)/bin/aarch64-linux-musl-cc" >> $GITHUB_ENV &&
echo "CC_aarch64_unknown_linux_musl=$(pwd)/bin/aarch64-linux-musl-cc" >> $GITHUB_ENV
) &&
export $(cat "$GITHUB_ENV")
- name: Compile
run: cargo build --verbose --release --target aarch64-unknown-linux-musl
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: aarch64-linux-musl
path: |
target/aarch64-unknown-linux-musl/release/modus
target/aarch64-unknown-linux-musl/release/buildkit-frontend
debug-build-and-test:
name: cargo test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Debug Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Upload
uses: actions/upload-artifact@v3
with:
name: debug-build
path: target/debug/modus
build-image-and-test:
name: Build frontend image and run system tests
runs-on: ubuntu-latest
needs: [ build-x86_64, build-aarch64, debug-build-and-test, precheck ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download previously built binaries
uses: actions/download-artifact@v3
- run: |
set -e;
for name in *-linux-musl; do
chmod +x "$name/modus" "$name/buildkit-frontend";
cp "$name/modus" "modus-$name";
done;
chmod +x debug-build/modus;
- name: Quick smoke check
run: |
set -xe;
./x86_64-linux-musl/modus --version;
./debug-build/modus --version;
- name: Upload modus binaries for all arch
uses: actions/upload-artifact@v3
with:
name: modus-all
path: |
modus-*-linux-*
- name: Generate frontend image
run: |
set -e;
mkdir /tmp/frontend;
DOCKERFILE="/tmp/frontend/Dockerfile";
echo 'FROM alpine' >> $DOCKERFILE;
echo 'ARG TARGETARCH' >> $DOCKERFILE;
echo 'COPY "$TARGETARCH" "buildkit-frontend"' >> $DOCKERFILE;
echo 'ENTRYPOINT ["/buildkit-frontend"]' >> $DOCKERFILE;
cp aarch64-linux-musl/buildkit-frontend /tmp/frontend/arm64;
cp x86_64-linux-musl/buildkit-frontend /tmp/frontend/amd64;
cd /tmp/frontend;
echo "SHORT_SHA=$(echo $GITHUB_SHA | head -c 10)" >> $GITHUB_ENV;
echo "IMAGE_BASE=ghcr.io/$GITHUB_REPOSITORY-buildkit-frontend" >> $GITHUB_ENV;
export $(cat "$GITHUB_ENV");
echo "IMAGE_REF=$IMAGE_BASE:$SHORT_SHA" >> $GITHUB_ENV;
export $(cat "$GITHUB_ENV");
echo Image: $IMAGE_REF;
cat $DOCKERFILE;
docker buildx build --platform linux/amd64 . -o type=docker -t $IMAGE_REF;
- name: System tests
run: >
export MODUS_EXECUTABLE=$PWD/debug-build/modus MODUS_BUILDKIT_FRONTEND=$IMAGE_REF &&
cd test && python -m unittest discover && cd ..
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish the rest of the images
if: github.event_name != 'pull_request'
run: |
set -e;
cd /tmp/frontend;
docker buildx create --use;
docker buildx build --platform linux/arm64,linux/amd64 . -t $IMAGE_REF --push;
docker buildx build --platform linux/arm64,linux/amd64 . -t $IMAGE_BASE:latest --push;
- name: Make GitHub release
if: github.event_name == 'push' && github.ref_type == 'tag'
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
draft: true
title: "${{ github.ref_name }}"
files: |
modus-*-linux-*