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 9, 2025
1 parent 6b3933f commit 6ba22b3
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 40 deletions.
20 changes: 6 additions & 14 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: bundler/.sqlx

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

Expand All @@ -46,13 +41,10 @@ jobs:
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
driver-opts: network=host

- 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: bundler/.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: bundler/.sqlx

- name: Install stable toolchain
uses: actions-rs/[email protected]
with:
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/_bundler_sqlx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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@localhost/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: bundler/.sqlx
include-hidden-files: true
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ jobs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/_devcontainer.yaml

bundler_sqlx:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/_bundler_sqlx.yaml

bundler_lint:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
needs: bundler_sqlx
uses: ./.github/workflows/_bundler_lint.yaml

bundler_test:
Expand All @@ -24,6 +30,7 @@ jobs:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
needs:
- bundler_sqlx
- bundler_lint
- bundler_test
permissions:
Expand All @@ -34,6 +41,7 @@ jobs:
bundler_docs:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
needs: bundler_sqlx
uses: ./.github/workflows/_bundler_docs.yaml

policy_lint:
Expand Down

0 comments on commit 6ba22b3

Please sign in to comment.