-
Notifications
You must be signed in to change notification settings - Fork 10
157 lines (153 loc) · 5.23 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
name: CI
on:
push:
# branches: [main]
pull_request:
branches: [main]
release:
types: [published]
workflow_dispatch:
jobs:
build:
# Don't change this name - it is used by the merge protection rules
name: Build ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macOS-latest
target: x86_64-apple-darwin
- os: macOS-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Rust Versions
shell: bash
run: |
rustc --version
cargo --version
- name: Lint
if: matrix.target == 'x86_64-unknown-linux-gnu'
shell: bash
run: |
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings || true
- name: Run build
shell: bash
run: |
if [[ "${{ matrix.target }}" == "x86_64-pc-windows-msvc" ]]; then
# Skip bbox-map-server on Windows (uses Unix sockets)
cargo build --release --target ${{ matrix.target }} --package bbox-server --no-default-features --features=feature-server,asset-server,processes-server,tile-server
elif [[ "${{ matrix.target }}" == "aarch64-apple-darwin" ]]; then
rustup target add aarch64-apple-darwin
# compile without debug symbols
RUSTFLAGS='-C link-arg=-s' cargo build --release --target ${{ matrix.target }} --package bbox-server
else
cargo build --release --target ${{ matrix.target }} --package bbox-server
fi
mkdir target_releases
if [[ "${{ runner.os }}" == "Windows" ]]; then
mv target/${{ matrix.target }}/release/bbox-server.exe target_releases
else
mv target/${{ matrix.target }}/release/bbox-server target_releases
fi
- name: Save build artifact build-${{ matrix.target }}
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.target }}
path: target_releases/*
test:
# Don't change this name - it is used by the merge protection rules
name: Test & package ${{ matrix.target }}
needs: [build]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
ext: ''
target: x86_64-unknown-linux-gnu
name: bbox-server-Linux-x86_64.tar.gz
- os: windows-latest
ext: '.exe'
target: x86_64-pc-windows-msvc
name: bbox-server-Windows-x86_64.zip
- os: macOS-latest
ext: ''
target: x86_64-apple-darwin
name: bbox-server-Darwin-x86_64.tar.gz
- os: ubuntu-latest
ext: ''
target: aarch64-apple-darwin
name: bbox-server-Darwin-aarch64.tar.gz
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
# - name: Start postgres
# if: matrix.target != 'aarch64-apple-darwin'
# uses: nyurik/action-setup-postgis@v1
# id: pg
# with:
# username: test
# password: test
# database: test
# rights: --superuser
# - name: Log DATABASE_URL string
# shell: bash
# run: |
# echo "DATABASE_URL=$DATABASE_URL"
# echo "And in base64 to bypass Github's obfuscation:"
# echo "$DATABASE_URL" | base64
# env:
# DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
# - name: Init database
# if: matrix.target != 'aarch64-apple-darwin'
# shell: bash
# run: tests/fixtures/initdb.sh
# env:
# DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
- name: Unit Tests (Linux)
if: matrix.target == 'x86_64-unknown-linux-gnu'
shell: bash
run: |
cargo test --all
rm -rf target
# env:
# DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
- uses: actions/download-artifact@v3
with:
name: build-${{ matrix.target }}
path: target/
- name: Package
shell: bash
run: |
cd target/
# Symbol stripping does not work cross-platform
if [[ "${{ matrix.target }}" != "aarch64-apple-darwin" ]]; then
strip bbox-server${{ matrix.ext }}
fi
if [[ "${{ runner.os }}" == "Windows" ]]; then
7z a ../${{ matrix.name }} bbox-server${{ matrix.ext }}
else
tar czvf ../${{ matrix.name }} bbox-server${{ matrix.ext }}
fi
cd -
- name: Generate SHA-256 (MacOS)
if: matrix.target == 'x86_64-apple-darwin' || matrix.target == 'aarch64-apple-darwin'
run: shasum -a 256 ${{ matrix.name }}
- name: Publish
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
draft: true
files: 'bbox-server*'
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}