Skip to content

Commit

Permalink
Pre-prepare SQLX queries to simplify bundler CI
Browse files Browse the repository at this point in the history
  • Loading branch information
garryod committed Jan 8, 2025
1 parent 548512d commit 54237fc
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 55 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/_bundler_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@ jobs:
permissions:
contents: read
packages: write
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >-
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
--health-interval 1s
--health-retries 60
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Download Prepared Queries Artifact
uses: actions/[email protected]
with:
name: prepared-queries
path: .sqlx

- name: Generate Image Name
run: echo IMAGE_REPOSITORY=ghcr.io/$(echo "${{ github.repository }}-bundler" | tr '[:upper:]' '[:lower:]' | tr '[_]' '[\-]') >> $GITHUB_ENV

Expand Down Expand Up @@ -52,7 +47,6 @@ jobs:
- name: Build & Publish Image
uses: docker/[email protected]
with:
build-args: DATABASE_URL=mysql://root:rootpassword@localhost:3306/ispyb_build
context: bundler/
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
load: ${{ !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}
Expand Down
19 changes: 6 additions & 13 deletions .github/workflows/_bundler_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,16 @@ on:
jobs:
build:
runs-on: ubuntu-latest
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >-
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
--health-interval 1s
--health-retries 60
env:
DATABASE_URL: mysql://root:rootpassword@localhost/ispyb_build
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Download Prepared Queries Artifact
uses: actions/[email protected]
with:
name: prepared-queries
path: .sqlx

- name: Install stable toolchain
uses: actions-rs/[email protected]
with:
Expand Down
19 changes: 6 additions & 13 deletions .github/workflows/_bundler_lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,16 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >-
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
--health-interval 1s
--health-retries 60
env:
DATABASE_URL: mysql://root:rootpassword@localhost/ispyb_build
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Download Prepared Queries Artifact
uses: actions/[email protected]
with:
name: prepared-queries
path: .sqlx

- name: Install stable toolchain
uses: actions-rs/[email protected]
with:
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/_bundler_sqlx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Bundler SQLX

on:
workflow_call:

jobs:
prepare:
runs-on: ubuntu-latest
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >-
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
--health-interval 1s
--health-retries 60
env:
DATABASE_URL: mysql://root:rootpassword@ispyb/ispyb_build
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Install stable toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
default: true

- name: Cache Rust Build
uses: Swatinem/[email protected]

- name: Install SQLX CLI
run: cargo install sqlx-cli

- name: Prepare SQLX Query
working-directory: bundler
run: >-
cargo sqlx prepare
- name: Upload Prepared Queries Artifact
uses: actions/[email protected]
with:
name: prepared-queries
path: .sqlx

19 changes: 6 additions & 13 deletions .github/workflows/_bundler_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,16 @@ on:
jobs:
test:
runs-on: ubuntu-latest
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >-
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
--health-interval 1s
--health-retries 60
env:
DATABASE_URL: mysql://root:rootpassword@localhost/ispyb_build
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Download Prepared Queries Artifact
uses: actions/[email protected]
with:
name: prepared-queries
path: .sqlx

- name: Install stable toolchain
uses: actions-rs/[email protected]
with:
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,26 @@ jobs:
needs: deduplicate
uses: ./.github/workflows/_devcontainer.yaml

bundler_lint:
bundler_sqlx:
needs: deduplicate
uses: ./.github/workflows/_bundler_sqlx.yaml

bundler_lint:
needs:
- deduplicate
- bundler_sqlx
uses: ./.github/workflows/_bundler_lint.yaml

bundler_test:
needs: deduplicate
needs:
- deduplicate
- bundler_sqlx
uses: ./.github/workflows/_bundler_test.yaml

bundler_container:
needs:
needs:
- deduplicate
- bundler_sqlx
- bundler_lint
- bundler_test
permissions:
Expand All @@ -35,7 +44,9 @@ jobs:
uses: ./.github/workflows/_bundler_container.yaml

bundler_docs:
needs: deduplicate
needs:
- deduplicate
- bundler_sqlx
uses: ./.github/workflows/_bundler_docs.yaml

policy_lint:
Expand Down

0 comments on commit 54237fc

Please sign in to comment.