Skip to content

Commit 0150e92

Browse files
committed
Pre-prepare SQLX queries to simplify bundler CI
1 parent 6b3933f commit 0150e92

File tree

5 files changed

+74
-38
lines changed

5 files changed

+74
-38
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: 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

@@ -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: bundler/.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: bundler/.sqlx
18+
2619
- name: Install stable toolchain
2720
uses: actions-rs/[email protected]
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/[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: cargo sqlx prepare
41+
42+
- name: Upload Prepared Queries Artifact
43+
uses: actions/[email protected]
44+
with:
45+
name: prepared-queries
46+
path: bundler/.sqlx
47+
include-hidden-files: true

.github/workflows/ci.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,28 @@ 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:
1925
# Deduplicate jobs from pull requests and branch pushes within the same repo.
2026
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
27+
needs: bundler_sqlx
2128
uses: ./.github/workflows/_bundler_test.yaml
2229

2330
bundler_container:
2431
# Deduplicate jobs from pull requests and branch pushes within the same repo.
2532
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
2633
needs:
34+
- bundler_sqlx
2735
- bundler_lint
2836
- bundler_test
2937
permissions:
@@ -34,6 +42,7 @@ jobs:
3442
bundler_docs:
3543
# Deduplicate jobs from pull requests and branch pushes within the same repo.
3644
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
45+
needs: bundler_sqlx
3746
uses: ./.github/workflows/_bundler_docs.yaml
3847

3948
policy_lint:

0 commit comments

Comments
 (0)