Skip to content

Commit

Permalink
Refactor CI using central flow
Browse files Browse the repository at this point in the history
  • Loading branch information
garryod committed Jan 8, 2025
1 parent 6ad17af commit f5c03aa
Show file tree
Hide file tree
Showing 21 changed files with 475 additions and 354 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
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
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/_bundler_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Bundler Docs

on:
workflow_call:

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

on:
workflow_call:

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"
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: 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
40 changes: 40 additions & 0 deletions .github/workflows/_bundler_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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"
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
26 changes: 26 additions & 0 deletions .github/workflows/_pages_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Pages Build

on:
workflow_call:

jobs:
combine:
runs-on: ubuntu-latest
steps:
- name: Download User Docs Artifact
uses: actions/[email protected]
with:
name: user-docs
path: docs

- name: Download User Docs Artifact
uses: actions/[email protected]
with:
name: bundler-docs
path: docs/bundler

- name: Upload Pages Artifact
uses: actions/[email protected]
with:
path: docs

23 changes: 23 additions & 0 deletions .github/workflows/_pages_publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pages Publish

on:
workflow_call:

jobs:
publish:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Setup Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/[email protected]

- name: Publish docs to GitHub Pages
id: deployment
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/[email protected]
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: Policy Container

on:
push:
pull_request:
workflow_call:

jobs:
build_bundle:
# 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
build_publish:
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/_policy_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Policy Lint

on:
workflow_call:

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

- name: Setup Regal
uses: StyraInc/[email protected]
with:
version: latest

- name: Lint
run: >
regal
lint
--format github
--config-file regal.yaml
./policy
Loading

0 comments on commit f5c03aa

Please sign in to comment.