-
Notifications
You must be signed in to change notification settings - Fork 56
164 lines (163 loc) · 6.02 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
name: build
on:
- push
jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Rust Build Cache
uses: Swatinem/rust-cache@v1
with:
key: cfg-v2
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install system dependencies
run: |
set -e
sudo apt install -y libseccomp-dev cmake
curl -L https://github.com/apple/foundationdb/releases/download/6.3.24/foundationdb-clients_6.3.24-1_amd64.deb --output fdb-client.deb
sudo dpkg -i fdb-client.deb
curl -L https://github.com/losfair/elfpromote/releases/download/v0.1.0/elfpromote_0.1.0_amd64.deb --output elfpromote.deb
sudo dpkg -i elfpromote.deb
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ghcr.io/${{ github.repository }}
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 6.18.0
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Install jsland deps
run: cd jsland && pnpm i
- name: Build mimalloc
run: |
set -e
git clone https://github.com/microsoft/mimalloc
cd mimalloc
git checkout v1.7.3
mkdir -p out/release
cd out/release
cmake ../..
make -j8
cd ../../..
cp ./mimalloc/out/release/libmimalloc.so.1.7 ./docker/libmimalloc.so
- name: Build
run: |
set -e
cp ./.cargo-ci/config ./.cargo/config
BLUEBOAT_DEB=1 ./build.sh
deb_file="$(find ./target/debian/ -type f)"
cp ${deb_file} ./docker/blueboat.deb
ls -lash ./docker
- name: Build Docker image for testing
uses: docker/build-push-action@v2
with:
context: ./docker
load: true
tags: losfair/blueboat:test
- name: Smoke test (multi-tenant)
run: |
set -e
mkdir test-workspace
cd test-workspace
curl -L --output minio https://dl.min.io/server/minio/release/linux-amd64/archive/minio.RELEASE.2022-02-01T18-00-14Z
chmod +x minio
mkdir test-data
./minio server --address 0.0.0.0:1932 ./test-data/minio &
docker run --rm -p 127.0.0.1:3000:3000 --name blueboat --entrypoint /usr/bin/blueboat_server \
-e AWS_ACCESS_KEY_ID="minioadmin" \
-e AWS_SECRET_ACCESS_KEY="minioadmin" \
-e RUST_LOG=info \
-e SMRAPP_BLUEBOAT_DISABLE_SECCOMP=1 \
losfair/blueboat:test \
-l "0.0.0.0:3000" \
--s3-bucket "apps" --s3-region "us-east-1" \
--s3-endpoint "http://172.17.0.1:1932" &
sleep 5
mkdir -p ./test-data/minio/apps/hello
echo 'Router.get("/", () => new Response("Hello from blueboat"))' | sudo tee ./index.js
tar -cvf ./test-data/minio/apps/hello/1.tar ./index.js
echo '{"version":"1","package":"hello/1.tar","env":{}}' | tee ./test-data/minio/apps/hello/metadata.json
curl -H "X-Blueboat-Metadata: hello/metadata.json" http://localhost:3000 | grep "Hello from blueboat"
- name: Smoke test (single-tenant)
run: |
set -e
cd test-workspace
mkdir single-tenant
cd single-tenant
cp ../test-data/minio/apps/hello/1.tar ./
echo '{"version":"1","package":"1.tar","env":{}}' | tee metadata.json
docker run --rm -p 127.0.0.1:3001:3001 --name blueboat-single-tenant --entrypoint /usr/bin/blueboat_server \
-v "$PWD:/app" \
-e RUST_LOG=info \
-e SMRAPP_BLUEBOAT_DISABLE_SECCOMP=1 \
losfair/blueboat:test \
-l "0.0.0.0:3001" \
--single-tenant "/app/metadata.json" &
sleep 5
curl http://localhost:3001 | grep "Hello from blueboat"
- name: Build Docker image for release
uses: docker/build-push-action@v2
with:
context: ./docker
push: ${{ startsWith(github.ref, 'refs/tags/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
unit-test:
name: Unit test
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Rust Build Cache
uses: Swatinem/rust-cache@v1
- name: Install system dependencies
run: |
set -e
sudo apt install -y libseccomp-dev cmake
curl -L https://github.com/apple/foundationdb/releases/download/6.3.24/foundationdb-clients_6.3.24-1_amd64.deb --output fdb-client.deb
sudo dpkg -i fdb-client.deb
curl -L https://github.com/losfair/elfpromote/releases/download/v0.1.0/elfpromote_0.1.0_amd64.deb --output elfpromote.deb
sudo dpkg -i elfpromote.deb
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 6.18.0
- name: Install jsland deps
run: cd jsland && pnpm i
- name: Prebuild and test
run: |
set -e
cp ./.cargo-ci/config ./.cargo/config
SKIP_FINAL_BUILD=1 ./build.sh
cargo test --release --lib
- name: Benchmark
run: cargo bench --bench api_benchmark