Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CI using central flow #230

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
name: Bundler Container

on:
push:
pull_request:
workflow_call:

jobs:
build_publish:
# 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
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
ports:
- 3306:3306
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 @@ -47,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
45 changes: 45 additions & 0 deletions .github/workflows/_bundler_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Bundler Docs

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
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:
toolchain: stable
default: true

- name: Cache Rust Build
uses: Swatinem/[email protected]
GDYendell marked this conversation as resolved.
Show resolved Hide resolved

- name: Build docs
uses: actions-rs/[email protected]
with:
command: doc
args: >
--no-deps
--all-features
--document-private-items
--manifest-path bundler/Cargo.toml

- name: Fix file permissions for pages
run: chmod -R +rX bundler/target/doc

- name: Upload Bundler Docs Artifact
uses: actions/[email protected]
with:
name: bundler-docs
path: bundler/target/doc/bundler
48 changes: 48 additions & 0 deletions .github/workflows/_bundler_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Bundler Lint

on:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
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:
toolchain: stable
default: true

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

- name: Check Formatting
uses: actions-rs/[email protected]
with:
command: fmt
args: >
--manifest-path bundler/Cargo.toml
--all
--check

- name: Lint with Clippy
uses: actions-rs/[email protected]
with:
command: clippy
args: >
--manifest-path bundler/Cargo.toml
--all-targets
--all-features
--no-deps
--
--deny warnings

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
42 changes: 42 additions & 0 deletions .github/workflows/_bundler_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Bundler Test

on:
workflow_call:

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: Install stable toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
default: true

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

- name: Test
uses: actions-rs/[email protected]
with:
command: test
args: >
--manifest-path bundler/Cargo.toml
--all-targets
--all-features
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: Dev Container CI

on:
push:
pull_request:
workflow_call:

jobs:
build:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/_docs_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Docs Build

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Setup Python
uses: actions/[email protected]
with:
python-version: 3.12

- name: Install Python Dependencies
run: pip install -r docs/requirements.txt

- name: Build User Docs
run: mkdocs build

- name: Fix file permissions for pages
run: chmod -R +rX site

- name: Upload User Docs Artifact
uses: actions/[email protected]
with:
name: user-docs
path: site
26 changes: 26 additions & 0 deletions .github/workflows/_docs_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Docs Lint

on:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Setup Node
uses: actions/[email protected]
with:
node-version: 18

- name: Install Yarn dependencies
uses: borales/[email protected]
with:
cmd: global add markdownlint-cli2 markdown-it-admon

- name: Lint with markdownlint-cli2
run: >
markdownlint-cli2
**/*.{md,markdown}
27 changes: 27 additions & 0 deletions .github/workflows/_helm_chart_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Helm Charts Lint

on:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Setup Helm
uses: azure/setup-helm@v4

- name: Setup chart-testing
uses: helm/[email protected]

- name: Lint
run: >
ct
lint
--target-branch=${{ github.event.repository.default_branch }}
--validate-maintainers=false

Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
name: Helm Charts
name: Helm Charts Publish

on:
push:
pull_request:
workflow_call:

jobs:
test:
# 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
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Setup Helm
uses: azure/setup-helm@v4

- name: Setup chart-testing
uses: helm/[email protected]

- name: Lint
run: >
ct
lint
--target-branch=${{ github.event.repository.default_branch }}
--validate-maintainers=false

build_publish:
# 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
publish:
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
Loading
Loading