Skip to content

Commit 51b163e

Browse files
Zach Pricelewisjared
authored andcommitted
feat: Build and publish Helm chart in CI
1 parent ceb9280 commit 51b163e

36 files changed

Lines changed: 981 additions & 170 deletions

.github/actions/build-container/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ runs:
2626
cache-to: type=gha,mode=max
2727
context: .
2828
file: ${{ inputs.dockerfile }}
29-
push: ${{ ! github.event.pull_request.head.repo.fork }}
29+
push: true
3030
sbom: true
3131
tags: ${{ steps.metadata.outputs.tags }}
3232
labels: ${{ steps.metadata.outputs.labels }}
3333
- name: Attest to REF image
3434
uses: actions/attest-build-provenance@v2
35-
if: ${{ ! github.event.pull_request.head.repo.fork }}
3635
with:
3736
subject-name: ghcr.io/${{ github.repository_owner }}/${{ inputs.container-name }}
3837
subject-digest: ${{ steps.push.outputs.digest }}

.github/workflows/bump.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
jobs:
2121
bump_version:
2222
name: "Bump version and create changelog"
23-
if: "!startsWith(github.event.head_commit.message, 'bump:')"
23+
if: ! startsWith(github.event.head_commit.message, 'bump:')
2424
runs-on: ubuntu-latest
2525
env:
2626
CI_COMMIT_EMAIL: "ci-runner@climate-ref.invalid"

.github/workflows/ci-integration.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
name: Integration tests
1+
# name: Integration tests
22

3-
on:
4-
# Allow manual triggering of this workflow
5-
workflow_dispatch:
6-
# Run on each push to main and tagged version
7-
push:
8-
branches: [main]
9-
tags: ['v*']
10-
# Runs every day at 2:15am (UTC) (~ midday in AEST)
11-
schedule:
12-
- cron: '2 15 * * *'
3+
# on:
4+
# # Allow manual triggering of this workflow
5+
# workflow_dispatch:
6+
# # Run on each push to main and tagged version
7+
# push:
8+
# branches: [main]
9+
# tags: ['v*']
10+
# # Runs every day at 2:15am (UTC) (~ midday in AEST)
11+
# schedule:
12+
# - cron: '2 15 * * *'
1313

1414
permissions:
1515
contents: read

.github/workflows/ci.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: CI
1+
# name: CI
22

3-
on:
4-
pull_request:
5-
push:
6-
branches: [main]
7-
tags: ['v*']
3+
# on:
4+
# pull_request:
5+
# push:
6+
# branches: [main]
7+
# tags: ['v*']
88

99
jobs:
1010
pre-commit:

.github/workflows/containers.yaml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/deploy.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# Deploys the published wheels to PyPI
2-
# Uses the artifact from the release job to publish to PyPI
1+
# # Deploys the published wheels to PyPI
2+
# # Uses the artifact from the release job to publish to PyPI
33

4-
name: Deploy
4+
# name: Deploy
55

6-
on:
7-
release:
8-
types: [published]
6+
# on:
7+
# release:
8+
# types: [published]
99

10-
defaults:
11-
run:
12-
shell: bash
10+
# defaults:
11+
# run:
12+
# shell: bash
1313

1414
jobs:
1515
deploy-pypi:

.github/workflows/install-pypi.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# Test installation of the latest version from PyPI works.
2-
# We make sure that we run the tests that apply to the version we installed,
3-
# rather than the latest tests in main.
4-
# The reason we do this, is that we want this workflow to test
5-
# that installing from PyPI leads to a correct installation.
6-
# If we tested against main, the tests could fail
7-
# because the tests from main require the new features in main to pass.
8-
name: Test installation PyPI
1+
# # Test installation of the latest version from PyPI works.
2+
# # We make sure that we run the tests that apply to the version we installed,
3+
# # rather than the latest tests in main.
4+
# # The reason we do this, is that we want this workflow to test
5+
# # that installing from PyPI leads to a correct installation.
6+
# # If we tested against main, the tests could fail
7+
# # because the tests from main require the new features in main to pass.
8+
# name: Test installation PyPI
99

10-
on:
11-
workflow_dispatch:
12-
schedule:
13-
# * is a special character in YAML so you have to quote this string
14-
# This means At 03:00 on Wednesday.
15-
# see https://crontab.guru/#0_0_*_*_3
16-
- cron: '0 3 * * 3'
10+
# on:
11+
# workflow_dispatch:
12+
# schedule:
13+
# # * is a special character in YAML so you have to quote this string
14+
# # This means At 03:00 on Wednesday.
15+
# # see https://crontab.guru/#0_0_*_*_3
16+
# - cron: '0 3 * * 3'
1717

1818
jobs:
1919
test-pypi-install:

.github/workflows/packaging.yaml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Packaging
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- "main"
9+
tags:
10+
- "v*"
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
attestations: write
16+
id-token: write
17+
18+
jobs:
19+
containers:
20+
name: Containers
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: docker/setup-buildx-action@v3
25+
- uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
- uses: ./.github/actions/build-container
31+
with:
32+
container-name: climate-ref
33+
dockerfile: packages/climate-ref/Dockerfile
34+
helm:
35+
name: Helm Chart
36+
runs-on: ubuntu-latest
37+
permissions:
38+
packages: write
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: actions/setup-python@v5
42+
- name: Install jq
43+
run: |
44+
sudo apt-get install --yes jq
45+
- name: Install yq
46+
run: |
47+
pip install yq
48+
- name: Generate SemVer
49+
id: semantic-version
50+
run: |
51+
CHART_VERSION=$(yq -r '.version' helm/Chart.yaml)
52+
LOCAL_SEGMENT=+pr-${{ github.event.pull_request.number }}
53+
GENERATED_VERSION=${CHART_VERSION}${LOCAL_SEGMENT}
54+
yq -Y -i ".version = \"$GENERATED_VERSION\"" helm/Chart.yaml
55+
echo "generated-semver=$GENERATED_VERSION" >> $GITHUB_OUTPUT
56+
- name: Chart | Push
57+
uses: appany/helm-oci-chart-releaser@v0.5.0
58+
with:
59+
name: ref
60+
repository: climate-ref/charts
61+
tag: ${{ steps.semantic-version.outputs.generated-semver }}
62+
path: helm
63+
registry: ghcr.io
64+
registry_username: ${{ github.actor }}
65+
registry_password: ${{ secrets.GITHUB_TOKEN }}
66+
update_dependencies: 'true'
67+
68+
test:
69+
name: Test Helm Deployment
70+
runs-on: ubuntu-latest
71+
if: github.event_name == 'pull_request'
72+
needs: [containers, helm]
73+
steps:
74+
- uses: actions/checkout@v4
75+
- name: Cache Sample Data (Restore)
76+
id: cache-sample-data-restore
77+
uses: actions/cache/restore@v4
78+
with:
79+
path: ${{ github.workspace }}/cache/ref-config
80+
key: ${{ runner.os }}-sample-data
81+
enableCrossOsArchive: true
82+
- name: Set permissions for cached data
83+
run: |
84+
sudo install -d --owner=1000 --group=1000 ${GITHUB_WORKSPACE}/cache/ref-config
85+
- name: Start minikube
86+
uses: medyagh/setup-minikube@latest
87+
with:
88+
mount-path: '${{ github.workspace }}/cache/ref-config:/cache/ref-config'
89+
- name: Set up Helm
90+
uses: azure/setup-helm@v4.3.0
91+
- name: Install Chart
92+
run: |
93+
helm install test oci://ghcr.io/climate-ref/charts/ref \
94+
--version=${{ needs.helm.outputs.generated-semver }} \
95+
--set climate-ref.image.tag=pr-${{ github.event.pull_request.number }} \
96+
-f helm/ci/gh-actions-values.yaml
97+
98+
sleep 60
99+
kubectl get pods
100+
echo ""
101+
kubectl describe pod -l app.kubernetes.io/component=pmp
102+
echo ""
103+
kubectl logs -l app.kubernetes.io/component=pmp
104+
- name: Run Migrations
105+
run: |
106+
kubectl exec deployment/test-ref-orchestrator -- ref config list
107+
- name: Initialize Providers (pmp)
108+
run: |
109+
# Imports ilamb3 which tries to create /home/app/.config/ilamb3 on import, no way to tell it to live somewhere else
110+
kubectl exec deployment/test-ref-pmp -- ref providers create-env --provider pmp
111+
- name: Initialize Providers (emsvaltool)
112+
run: |
113+
kubectl exec deployment/test-ref-esmvaltool -- ref providers create-env --provider esmvaltool
114+
- name: Fetch Test Data
115+
run: |
116+
kubectl exec deployment/test-ref-orchestrator -- ref datasets fetch-data --registry sample-data --output-directory /ref/sample-data
117+
118+
- name: Cache Sample Data (Save)
119+
uses: actions/cache/save@v4
120+
with:
121+
path: ${{ github.workspace }}/cache/ref-config
122+
key: ${{ runner.os }}-sample-data
123+
124+
- name: Ingest Test Data (CMIP6)
125+
run: |
126+
kubectl exec deployment/test-ref-orchestrator -- ref -v datasets ingest --source-type cmip6 /ref/sample-data/CMIP6
127+
- name: Ingest Test Data (obs4mips)
128+
run: |
129+
kubectl exec deployment/test-ref-orchestrator -- ref -v datasets ingest --source-type obs4mips /ref/sample-data/obs4REF
130+
- name: Simple Solve
131+
run: |
132+
kubectl exec deployment/test-ref-orchestrator -- ref -v solve --timeout 180 --one-per-provider

.github/workflows/release.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# Generate a draft release on GitHub when a new tag is pushed
2-
# The draft release will contain draft release notes and some built wheels
1+
# # Generate a draft release on GitHub when a new tag is pushed
2+
# # The draft release will contain draft release notes and some built wheels
33

4-
name: Release
4+
# name: Release
55

6-
on:
7-
push:
8-
tags: ['v*']
6+
# on:
7+
# push:
8+
# tags: ['v*']
99

10-
defaults:
11-
run:
12-
shell: bash
10+
# defaults:
11+
# run:
12+
# shell: bash
1313

1414
jobs:
1515
draft-release:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,6 @@ packages/*/NOTICE
164164

165165
# User-specific catalog paths (test data)
166166
*.paths.yaml
167+
168+
# Helm dependencies
169+
helm/charts/*

0 commit comments

Comments
 (0)