Skip to content

Commit 2d2aa76

Browse files
committed
Split CI jobs into _helm _rust and _container
1 parent c27c19f commit 2d2aa76

File tree

4 files changed

+166
-86
lines changed

4 files changed

+166
-86
lines changed

.github/workflows/_container.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout
9+
uses: actions/checkout@v4
10+
11+
- name: Generate Metadata
12+
id: meta
13+
uses: docker/metadata-action@v5
14+
with:
15+
images: ghcr.io/${{ github.repository }}
16+
17+
# - name: Build image
18+
# uses: docker/build-push-actions@v6
19+
20+
- name: Log in to GHCR
21+
# if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
22+
uses: docker/login-action@v3
23+
with:
24+
registry: ghcr.io/${{ github.repository_owner }}
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Publish image
29+
uses: docker/build-push-action@v6
30+
env:
31+
DOCKER_BUILD_RECORD_UPLOAD: false
32+
with:
33+
# push: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
34+
push: true
35+
tags: ${{ steps.meta.outputs.tags }}

.github/workflows/_helm.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Package helm charts
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
HELM_VERSION_TO_INSTALL: 3.17.1
8+
9+
jobs:
10+
package-helm-charts:
11+
name: Package and Push Helm Chart
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Install helm
20+
uses: Azure/setup-helm@v3
21+
with:
22+
version: ${{ env.HELM_VERSION_TO_INSTALL }}
23+
24+
# Check that alpha/beta versions have the form X.Y.Z-alpha.A requried by Helm.
25+
# An early check saves waiting for the entire build before finding a problem.
26+
- name: Check helm version tag
27+
if: ${{ github.ref_type == 'tag' }}
28+
env:
29+
VERSION: "${{ github.ref_name }}"
30+
run: |
31+
if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+((-alpha|-beta|-rc)\.[0-9]+)?$ ]]; then
32+
echo "Valid version format: '${VERSION}'"
33+
else
34+
echo "Invalid version: '${VERSION}'. Expected: 'X.Y.Z' or 'X.Y.Z-beta.1' or 'X.Y.Z-alpha.1'"
35+
exit 1
36+
fi
37+
38+
- name: Package helm charts
39+
env:
40+
VERSION: "${{ github.ref_type == 'tag' && github.ref_name || '0.0.0' }}"
41+
run: |
42+
set -xe
43+
44+
mkdir -p charts
45+
for i in $(find Charts -type d -maxdepth 1 -mindepth 1); do
46+
if [[ ${i} =~ ^.*-ioc$ ]]; then
47+
echo "Skipping IOC schema chart: ${i}"
48+
continue
49+
fi
50+
echo "Packaging chart: ${i}"
51+
helm package -u --app-version ${VERSION} --version ${VERSION} ${i}
52+
mv $(basename ${i})-*.tgz charts/
53+
done
54+
55+
- name: Upload helm chart values schemas
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: helm-chart-schemas
59+
path: schemas/*
60+
61+
- name: Push tagged helm chart to registry
62+
# TODO - switch to using https://github.com/helm/chart-releaser-action of maybe the docker action?
63+
if: ${{ github.ref_type == 'tag' }}
64+
run: |
65+
set -x
66+
67+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io/${{ github.repository_owner }} --username ${{ github.repository_owner }} --password-stdin
68+
REGISTRY=oci://ghcr.io/${{github.repository_owner }}/charts
69+
for i in charts/*.tgz; do
70+
helm push "${i}" ${REGISTRY,,}
71+
done

.github/workflows/_rust.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
on:
2+
workflow_call:
3+
4+
env:
5+
CARGO_TERM_COLOR: always
6+
7+
jobs:
8+
format:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: dtolnay/rust-toolchain@stable
13+
with:
14+
toolchain: nightly
15+
components: rustfmt
16+
- name: Check formatting
17+
# Use nightly for formatting to enable unstable formatting styles
18+
# * group imports
19+
# * import_granularity
20+
run: cargo +nightly fmt -- --check
21+
22+
lint:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: dtolnay/rust-toolchain@stable
27+
with:
28+
toolchain: stable
29+
components: clippy
30+
- uses: Swatinem/rust-cache@v2
31+
- name: Clippy
32+
run: |
33+
cargo --version
34+
cargo clippy --version
35+
cargo clippy --all-targets --all-features -- --deny warnings
36+
37+
test:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: dtolnay/rust-toolchain@stable
42+
with:
43+
toolchain: stable
44+
- uses: Swatinem/rust-cache@v2
45+
46+
- name: Build Everything
47+
run: cargo build --all-targets
48+
- name: Run tests
49+
run: cargo test --all-targets --verbose
50+
# Ensure that no files (most likely the Cargo.lock file) have changed
51+
- name: Unstaged Changes
52+
run: git diff --exit-code

.github/workflows/ci.yml

Lines changed: 8 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -6,91 +6,13 @@ on:
66
- main
77
pull_request:
88

9-
env:
10-
CARGO_TERM_COLOR: always
119

1210
jobs:
13-
format:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- uses: actions/checkout@v4
17-
- uses: dtolnay/rust-toolchain@stable
18-
with:
19-
toolchain: nightly
20-
components: rustfmt
21-
- name: Check formatting
22-
# Use nightly for formatting to enable unstable formatting styles
23-
# * group imports
24-
# * import_granularity
25-
run: cargo +nightly fmt -- --check
26-
27-
lint:
28-
runs-on: ubuntu-latest
29-
steps:
30-
- uses: actions/checkout@v4
31-
- uses: dtolnay/rust-toolchain@stable
32-
with:
33-
toolchain: stable
34-
components: clippy
35-
- uses: Swatinem/rust-cache@v2
36-
- name: Clippy
37-
run: |
38-
cargo --version
39-
cargo clippy --version
40-
cargo clippy --all-targets --all-features -- --deny warnings
41-
42-
test:
43-
runs-on: ubuntu-latest
44-
steps:
45-
- uses: actions/checkout@v4
46-
- uses: dtolnay/rust-toolchain@stable
47-
with:
48-
toolchain: stable
49-
- uses: Swatinem/rust-cache@v2
50-
51-
- name: Build Everything
52-
run: cargo build --all-targets
53-
- name: Run tests
54-
run: cargo test --all-targets --verbose
55-
# Ensure that no files (most likely the Cargo.lock file) have changed
56-
- name: Unstaged Changes
57-
run: git diff --exit-code
58-
59-
build:
60-
runs-on: ubuntu-latest
61-
steps:
62-
- name: Checkout
63-
uses: actions/checkout@v4
64-
65-
- name: Generate Metadata
66-
id: meta
67-
uses: docker/metadata-action@v5
68-
with:
69-
images: ghcr.io/${{ github.repository }}
70-
71-
# - name: Build image
72-
# uses: docker/build-push-actions@v6
73-
74-
- name: Log in to GHCR
75-
# if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
76-
uses: docker/login-action@v3
77-
with:
78-
registry: ghcr.io/${{ github.repository_owner }}
79-
username: ${{ github.actor }}
80-
password: ${{ secrets.GITHUB_TOKEN }}
81-
82-
- name: Publish image
83-
uses: docker/build-push-action@v6
84-
env:
85-
DOCKER_BUILD_RECORD_UPLOAD: false
86-
with:
87-
# push: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
88-
push: true
89-
tags: ${{ steps.meta.outputs.tags }}
90-
91-
92-
- name: Publish chart
93-
run: |
94-
helm dependencies update helm
95-
helm package helm --version ${GITHUB_REF##*/} --app-version ${GITHUB_REF##*/} -d /tmp/
96-
helm push /tmp/helm-${GITHUB_REF##*/}.tgz oci://ghcr.io/diamondlightsource/charts
11+
rust:
12+
uses: ./.github/_rust.yml
13+
14+
container:
15+
uses: ./.github/_container.yml
16+
17+
helm:
18+
uses: ./.github/_helm.yml

0 commit comments

Comments
 (0)