Skip to content

Commit dadd6df

Browse files
committed
Pre-prepare SQLX queries to simplify bundler CI
1 parent 6d7dd12 commit dadd6df

File tree

5 files changed

+73
-40
lines changed

5 files changed

+73
-40
lines changed

.github/workflows/_bundler_container.yaml

Lines changed: 6 additions & 14 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/checkout@v4.2.2
2615

16+
- name: Download Prepared Queries Artifact
17+
uses: actions/download-artifact@v4.1.8
18+
with:
19+
name: prepared-queries
20+
path: bundler/.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

@@ -46,13 +41,10 @@ jobs:
4641
4742
- name: Set up Docker Buildx
4843
uses: docker/setup-buildx-action@v3.8.0
49-
with:
50-
driver-opts: network=host
5144

5245
- name: Build & Publish Image
5346
uses: docker/build-push-action@v6.10.0
5447
with:
55-
build-args: DATABASE_URL=mysql://root:rootpassword@localhost:3306/ispyb_build
5648
context: bundler/
5749
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
5850
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/checkout@v4.2.2
2512

13+
- name: Download Prepared Queries Artifact
14+
uses: actions/download-artifact@v4.1.8
15+
with:
16+
name: prepared-queries
17+
path: bundler/.sqlx
18+
2619
- name: Install stable toolchain
2720
uses: actions-rs/toolchain@v1.0.7
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/checkout@v4.2.2
2512

13+
- name: Download Prepared Queries Artifact
14+
uses: actions/download-artifact@v4.1.8
15+
with:
16+
name: prepared-queries
17+
path: bundler/.sqlx
18+
2619
- name: Install stable toolchain
2720
uses: actions-rs/toolchain@v1.0.7
2821
with:
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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/checkout@v4.2.2
25+
26+
- name: Install stable toolchain
27+
uses: actions-rs/toolchain@v1.0.7
28+
with:
29+
toolchain: stable
30+
default: true
31+
32+
- name: Cache Rust Build
33+
uses: Swatinem/rust-cache@v2.7.7
34+
35+
- name: Install SQLX CLI
36+
run: cargo install sqlx-cli
37+
38+
- name: Prepare SQLX Query
39+
working-directory: bundler
40+
run: cargo sqlx prepare
41+
42+
- name: Upload Prepared Queries Artifact
43+
uses: actions/upload-artifact@v4.5.0
44+
with:
45+
name: prepared-queries
46+
path: bundler/.sqlx
47+
include-hidden-files: true

.github/workflows/ci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ jobs:
1010
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
1111
uses: ./.github/workflows/_devcontainer.yaml
1212

13+
bundler_sqlx:
14+
# Deduplicate jobs from pull requests and branch pushes within the same repo.
15+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
16+
uses: ./.github/workflows/_bundler_sqlx.yaml
17+
1318
bundler_lint:
1419
# Deduplicate jobs from pull requests and branch pushes within the same repo.
1520
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
21+
needs: bundler_sqlx
1622
uses: ./.github/workflows/_bundler_lint.yaml
1723

1824
bundler_test:
@@ -24,6 +30,7 @@ jobs:
2430
# Deduplicate jobs from pull requests and branch pushes within the same repo.
2531
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
2632
needs:
33+
- bundler_sqlx
2734
- bundler_lint
2835
- bundler_test
2936
permissions:
@@ -34,6 +41,7 @@ jobs:
3441
bundler_docs:
3542
# Deduplicate jobs from pull requests and branch pushes within the same repo.
3643
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
44+
needs: bundler_sqlx
3745
uses: ./.github/workflows/_bundler_docs.yaml
3846

3947
policy_lint:

0 commit comments

Comments
 (0)