-
-
Notifications
You must be signed in to change notification settings - Fork 167
227 lines (220 loc) · 7.78 KB
/
ci.yml
File metadata and controls
227 lines (220 loc) · 7.78 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
216
217
218
219
220
221
222
223
224
225
226
227
name: CI
on:
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
branches:
- "main"
paths-ignore:
- "docs/**"
- "README.md"
- ".github/workflows/release.yml"
- ".github/workflows/official-site.yml"
pull_request:
branches:
- "main"
env:
CARGO_TERM_COLOR: always
REGISTRY_USERNAME: lovasoa
REGISTRY_IMAGE: lovasoa/sqlpage
jobs:
compile_and_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm test
- name: Set up cargo cache
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
with:
shared-key: rust-sqlpage-proj-test
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo fmt --all -- --check
- run: cargo clippy --all-targets --all-features -- -D warnings
- run: cargo test --features odbc-static
- name: Upload Linux binary
uses: actions/upload-artifact@v4
with:
name: sqlpage-linux-debug
path: "target/debug/sqlpage"
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- database: postgres
container: postgres
db_url: "postgres://root:Password123!@127.0.0.1/sqlpage"
- database: mysql
container: mysql
db_url: "mysql://root:Password123!@127.0.0.1/sqlpage"
- database: mssql
container: mssql
db_url: "mssql://root:Password123!@127.0.0.1/sqlpage"
- database: odbc
container: postgres
db_url: "Driver=PostgreSQL Unicode;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!"
setup_odbc: true
- database: oracle
container: oracle
db_url: "Driver=Oracle 21 ODBC driver;Dbq=//127.0.0.1:1521/FREEPDB1;Uid=root;Pwd=Password123!"
steps:
- uses: actions/checkout@v4
- name: Set up cargo cache
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
with:
shared-key: rust-sqlpage-proj-test
save-if: false
- name: Install PostgreSQL ODBC driver
if: matrix.setup_odbc
run: sudo apt-get install -y odbc-postgresql
- name: Install Oracle ODBC driver
if: matrix.database == 'oracle'
run: |
sudo apt-get install -y alien libaio1t64 libodbcinst2 unixodbc
wget https://download.oracle.com/otn_software/linux/instantclient/2114000/oracle-instantclient-{basic,odbc}-21.14.0.0.0-1.el8.x86_64.rpm
sudo alien -i oracle-instantclient-basic-21.14.0.0.0-1.el8.x86_64.rpm
sudo alien -i oracle-instantclient-odbc-21.14.0.0.0-1.el8.x86_64.rpm
sudo ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/libaio.so.1
sudo /usr/lib/oracle/21/client64/bin/odbc_update_ini.sh / /usr/lib/oracle/21/client64/lib
echo "LD_LIBRARY_PATH=/usr/lib/oracle/21/client64/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Start database container
run: docker compose up --wait ${{ matrix.container }}
- name: Show container logs
if: failure()
run: docker compose logs ${{ matrix.container }}
- name: Run tests against ${{ matrix.database }}
timeout-minutes: 5
run: cargo test --features odbc-static
env:
DATABASE_URL: ${{ matrix.db_url }}
MALLOC_CHECK_: 3
MALLOC_PERTURB_: 10
windows_test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up cargo cache
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- name: Check port usage
run: netstat -bano
- run: cargo test
env:
RUST_BACKTRACE: 1
- name: Upload Windows binary
uses: actions/upload-artifact@v4
with:
name: sqlpage-windows-debug
path: "target/debug/sqlpage.exe"
docker_build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm/v7
- linux/arm64
variant:
- minimal
- duckdb
exclude:
# DuckDB ODBC is not available for armv7
- platform: linux/arm/v7
variant: duckdb
steps:
- name: Checkout
uses: actions/checkout@v4
- id: suffix
name: Cache name suffix
run: |
suffix="-$(tr '/' '-' <<< "${{ matrix.platform }}")"
if [[ "${{ matrix.variant }}" != "minimal" ]]; then
suffix="${suffix}-${{ matrix.variant }}"
fi
echo "suffix=${suffix}" >> "$GITHUB_OUTPUT"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
flavor: suffix=${{ steps.suffix.outputs.suffix }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
target: ${{ matrix.variant }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:main${{ steps.suffix.outputs.suffix }}
# don't save cache on prs
cache-to: >
${{ github.event_name != 'pull_request'
&& format('type=registry,ref={0}:main{1},compression=zstd,mode=max', env.REGISTRY_IMAGE, steps.suffix.outputs.suffix)
|| ''
}}
- name: Export digest
if: github.event_name != 'pull_request'
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with:
name: digests-${{ matrix.variant }}${{ steps.suffix.outputs.suffix }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
docker_push:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
needs:
- docker_build
strategy:
matrix:
variant:
- minimal
- duckdb
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
pattern: digests-${{ matrix.variant }}*
merge-multiple: true
path: /tmp/digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
flavor: suffix=${{ matrix.variant != 'minimal' && format('-{0}', matrix.variant) || '' }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}