-
Notifications
You must be signed in to change notification settings - Fork 12
217 lines (193 loc) · 7.37 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
name: CI
on:
push:
branches: [main]
tags: [v*]
pull_request:
branches: [main]
paths-ignore:
- '**.md'
- 'docs/**'
workflow_dispatch:
jobs:
build:
name: Build ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
# Raspberry Pi 3 or later: rustup target add aarch64-unknown-linux-gnu
# Raspberry Pi 2: rustup target add armv7-unknown-linux-gnueabihf
# Raspberry Pi Zero: rustup target add arm-unknown-linux-gnueabihf
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
target_rustflags: ''
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
target_rustflags: '--codegen linker=aarch64-linux-gnu-gcc'
# - target: armv7-unknown-linux-gnueabihf
# os: ubuntu-latest
# target_rustflags: '--codegen linker=arm-linux-gnueabihf-gcc'
- target: x86_64-pc-windows-msvc
os: windows-latest
target_rustflags: ''
- target: x86_64-apple-darwin
os: macOS-latest
# compile without debug symbols
target_rustflags: '-C link-arg=-s'
- target: aarch64-apple-darwin
os: macOS-latest
target_rustflags: ''
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: rustup
shell: bash
run: |
rustup toolchain install stable --profile minimal
rustup target add ${{ matrix.target }}
# Target specific tools
if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-gnu" ]]; then
rustup component add clippy
elif [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
sudo apt-get install gcc-aarch64-linux-gnu
elif [[ "${{ matrix.target }}" == "armv7-unknown-linux-gnueabihf" ]]; then
sudo apt-get install gcc-arm-linux-gnueabihf
fi
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Lint
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
- name: Run build
shell: bash
run: |
if [[ "${{ matrix.target }}" == "x86_64-pc-windows-msvc" ]]; then
# Skip bbox-map-server on Windows (uses Unix sockets)
RUSTFLAGS="${{ matrix.target_rustflags }}" cargo build --release --target ${{ matrix.target }} --package bbox-server --no-default-features --features=feature-server,asset-server,processes-server,tile-server,frontend
RUSTFLAGS="${{ matrix.target_rustflags }}" cargo build --release --target ${{ matrix.target }} --package bbox-tile-server --no-default-features
else
RUSTFLAGS="${{ matrix.target_rustflags }}" cargo build --release --target ${{ matrix.target }} --package bbox-server
RUSTFLAGS="${{ matrix.target_rustflags }}" cargo build --release --target ${{ matrix.target }} --package bbox-tile-server
fi
mkdir target_releases
if [[ "${{ runner.os }}" == "Windows" ]]; then
mv target/${{ matrix.target }}/release/bbox-*.exe target_releases
else
mv target/${{ matrix.target }}/release/bbox*server target_releases
fi
- name: Build (.deb)
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
set -x
cargo install cargo-deb --locked
cd bbox-tile-server
cargo deb -v --deb-revision $(lsb_release -c -s)
mv ../target/debian/*.deb ../target_releases/
cargo deb -v --variant bookworm
mv ../target/debian/*.deb ../target_releases/
cargo deb -v --variant bullseye
mv ../target/debian/*.deb ../target_releases/
- name: Save build artifact build-${{ matrix.target }}
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.target }}
path: target_releases/*
test:
name: Test
needs: [build]
runs-on: ubuntu-latest
services:
postgres:
image: sourcepole/mvtbenchdb:v1.2
ports:
- 5439:5432
steps:
- name: Checkout sources
uses: actions/checkout@v4
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Unit Tests (Linux)
run: |
cargo test --all
- name: DB Tests (Linux)
run: |
cargo test --all -- --ignored
package:
name: Package
runs-on: ubuntu-latest
needs: [test]
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download built artifact build-x86_64-unknown-linux-gnu
uses: actions/download-artifact@v4
with:
name: build-x86_64-unknown-linux-gnu
path: target/x86_64-unknown-linux-gnu
- name: Download built artifact build-aarch64-unknown-linux-gnu
uses: actions/download-artifact@v4
with:
name: build-aarch64-unknown-linux-gnu
path: target/aarch64-unknown-linux-gnu
- name: Download built artifact build-x86_64-pc-windows-msvc
uses: actions/download-artifact@v4
with:
name: build-x86_64-pc-windows-msvc
path: target/x86_64-pc-windows-msvc
- name: Download built artifact build-x86_64-apple-darwin
uses: actions/download-artifact@v4
with:
name: build-x86_64-apple-darwin
path: target/x86_64-apple-darwin
- name: Download built artifact build-aarch64-apple-darwin
uses: actions/download-artifact@v4
with:
name: build-aarch64-apple-darwin
path: target/aarch64-apple-darwin
- name: Package
run: |
set -x
cd target
mkdir files
mv x86_64-unknown-linux-gnu/*.deb files/
for dist in x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu x86_64-apple-darwin aarch64-apple-darwin; do
cd $dist
chmod +x *
tar czvf ../files/bbox-server-$dist.tar.gz bbox-server
tar czvf ../files/bbox-tile-server-$dist.tar.gz bbox-tile-server
cd ..
done
cd x86_64-pc-windows-msvc
7z a ../files/bbox-server-x86_64-pc-windows-msvc.zip bbox-server.exe
7z a ../files/bbox-tile-server-x86_64-pc-windows-msvc.zip bbox-tile-server.exe
cd ..
- name: Generate Changelog
run: echo "See [CHANGELOG](https://github.com/bbox-services/bbox/blob/main/CHANGELOG.md#xzy-betax-$(date +'%Y-%m-%d'))" > ${{ github.workspace }}-CHANGELOG.txt
- name: Publish
uses: softprops/action-gh-release@v2
with:
draft: true
files: 'target/files/*'
body_path: ${{ github.workspace }}-CHANGELOG.txt