Skip to content

Commit 5199720

Browse files
committed
Pre-prepare SQLX queries to simplify bundler CI
1 parent 548512d commit 5199720

File tree

6 files changed

+87
-55
lines changed

6 files changed

+87
-55
lines changed

.github/workflows/_bundler_container.yaml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@ jobs:
99
permissions:
1010
contents: read
1111
packages: write
12-
services:
13-
ispyb:
14-
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
15-
ports:
16-
- 3306:3306
17-
env:
18-
MARIADB_ROOT_PASSWORD: rootpassword
19-
options: >-
20-
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
21-
--health-interval 1s
22-
--health-retries 60
2312
steps:
2413
- name: Checkout source
2514
uses: actions/[email protected]
2615

16+
- name: Download Prepared Queries Artifact
17+
uses: actions/[email protected]
18+
with:
19+
name: prepared-queries
20+
path: .sqlx
21+
2722
- name: Generate Image Name
2823
run: echo IMAGE_REPOSITORY=ghcr.io/$(echo "${{ github.repository }}-bundler" | tr '[:upper:]' '[:lower:]' | tr '[_]' '[\-]') >> $GITHUB_ENV
2924

@@ -52,7 +47,6 @@ jobs:
5247
- name: Build & Publish Image
5348
uses: docker/[email protected]
5449
with:
55-
build-args: DATABASE_URL=mysql://root:rootpassword@localhost:3306/ispyb_build
5650
context: bundler/
5751
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
5852
load: ${{ !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}

.github/workflows/_bundler_docs.yaml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,16 @@ on:
66
jobs:
77
build:
88
runs-on: ubuntu-latest
9-
services:
10-
ispyb:
11-
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
12-
ports:
13-
- 3306:3306
14-
env:
15-
MARIADB_ROOT_PASSWORD: rootpassword
16-
options: >-
17-
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
18-
--health-interval 1s
19-
--health-retries 60
20-
env:
21-
DATABASE_URL: mysql://root:rootpassword@localhost/ispyb_build
229
steps:
2310
- name: Checkout source
2411
uses: actions/[email protected]
2512

13+
- name: Download Prepared Queries Artifact
14+
uses: actions/[email protected]
15+
with:
16+
name: prepared-queries
17+
path: .sqlx
18+
2619
- name: Install stable toolchain
2720
uses: actions-rs/[email protected]
2821
with:

.github/workflows/_bundler_lint.yaml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,16 @@ on:
66
jobs:
77
lint:
88
runs-on: ubuntu-latest
9-
services:
10-
ispyb:
11-
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
12-
ports:
13-
- 3306:3306
14-
env:
15-
MARIADB_ROOT_PASSWORD: rootpassword
16-
options: >-
17-
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
18-
--health-interval 1s
19-
--health-retries 60
20-
env:
21-
DATABASE_URL: mysql://root:rootpassword@localhost/ispyb_build
229
steps:
2310
- name: Checkout source
2411
uses: actions/[email protected]
2512

13+
- name: Download Prepared Queries Artifact
14+
uses: actions/[email protected]
15+
with:
16+
name: prepared-queries
17+
path: .sqlx
18+
2619
- name: Install stable toolchain
2720
uses: actions-rs/[email protected]
2821
with:
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Bundler SQLX
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
prepare:
8+
runs-on: ubuntu-latest
9+
services:
10+
ispyb:
11+
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
12+
ports:
13+
- 3306:3306
14+
env:
15+
MARIADB_ROOT_PASSWORD: rootpassword
16+
options: >-
17+
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
18+
--health-interval 1s
19+
--health-retries 60
20+
env:
21+
DATABASE_URL: mysql://root:rootpassword@localhost/ispyb_build
22+
steps:
23+
- name: Checkout source
24+
uses: actions/[email protected]
25+
26+
- name: Install stable toolchain
27+
uses: actions-rs/[email protected]
28+
with:
29+
toolchain: stable
30+
default: true
31+
32+
- name: Cache Rust Build
33+
uses: Swatinem/[email protected]
34+
35+
- name: Install SQLX CLI
36+
run: cargo install sqlx-cli
37+
38+
- name: Prepare SQLX Query
39+
working-directory: bundler
40+
run: >-
41+
cargo sqlx prepare
42+
43+
- name: Upload Prepared Queries Artifact
44+
uses: actions/[email protected]
45+
with:
46+
name: prepared-queries
47+
path: .sqlx
48+

.github/workflows/_bundler_test.yaml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,16 @@ on:
66
jobs:
77
test:
88
runs-on: ubuntu-latest
9-
services:
10-
ispyb:
11-
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
12-
ports:
13-
- 3306:3306
14-
env:
15-
MARIADB_ROOT_PASSWORD: rootpassword
16-
options: >-
17-
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
18-
--health-interval 1s
19-
--health-retries 60
20-
env:
21-
DATABASE_URL: mysql://root:rootpassword@localhost/ispyb_build
229
steps:
2310
- name: Checkout source
2411
uses: actions/[email protected]
2512

13+
- name: Download Prepared Queries Artifact
14+
uses: actions/[email protected]
15+
with:
16+
name: prepared-queries
17+
path: .sqlx
18+
2619
- name: Install stable toolchain
2720
uses: actions-rs/[email protected]
2821
with:

.github/workflows/ci.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,26 @@ jobs:
1616
needs: deduplicate
1717
uses: ./.github/workflows/_devcontainer.yaml
1818

19-
bundler_lint:
19+
bundler_sqlx:
2020
needs: deduplicate
21+
uses: ./.github/workflows/_bundler_sqlx.yaml
22+
23+
bundler_lint:
24+
needs:
25+
- deduplicate
26+
- bundler_sqlx
2127
uses: ./.github/workflows/_bundler_lint.yaml
2228

2329
bundler_test:
24-
needs: deduplicate
30+
needs:
31+
- deduplicate
32+
- bundler_sqlx
2533
uses: ./.github/workflows/_bundler_test.yaml
2634

2735
bundler_container:
28-
needs:
36+
needs:
2937
- deduplicate
38+
- bundler_sqlx
3039
- bundler_lint
3140
- bundler_test
3241
permissions:
@@ -35,7 +44,9 @@ jobs:
3544
uses: ./.github/workflows/_bundler_container.yaml
3645

3746
bundler_docs:
38-
needs: deduplicate
47+
needs:
48+
- deduplicate
49+
- bundler_sqlx
3950
uses: ./.github/workflows/_bundler_docs.yaml
4051

4152
policy_lint:

0 commit comments

Comments
 (0)