-
Notifications
You must be signed in to change notification settings - Fork 14
186 lines (178 loc) · 6.57 KB
/
Copy pathpackaging.yaml
File metadata and controls
186 lines (178 loc) · 6.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Packaging
on:
pull_request:
workflow_dispatch:
push:
branches:
- "main"
tags:
- "v*"
permissions:
contents: read
packages: write
attestations: write
id-token: write
jobs:
changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
helm: ${{ steps.filter.outputs.helm }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
helm:
- 'helm/**'
containers:
name: Containers
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/build-container
with:
container-name: climate-ref
dockerfile: packages/climate-ref/Dockerfile
helm:
name: Helm Chart
runs-on: ubuntu-latest
needs: [changes]
if: needs.changes.outputs.helm == 'true' || github.event_name != 'pull_request'
permissions:
packages: write
outputs:
generated-semver: ${{ steps.semantic-version.outputs.generated-semver }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
- name: Install jq
run: |
sudo apt-get install --yes jq
- name: Install yq
run: |
pip install yq
- name: Generate SemVer
id: semantic-version
run: |
CHART_VERSION=$(yq -r '.version' helm/Chart.yaml)
if [ "${{ github.event_name }}" = "pull_request" ]; then
LOCAL_SEGMENT=+pr-${{ github.event.pull_request.number }}
elif [ "${{ github.ref_type }}" = "tag" ]; then
LOCAL_SEGMENT=""
else
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
LOCAL_SEGMENT=+${SHORT_SHA}
fi
GENERATED_VERSION=${CHART_VERSION}${LOCAL_SEGMENT}
yq -Y -i ".version = \"$GENERATED_VERSION\"" helm/Chart.yaml
echo "generated-semver=$GENERATED_VERSION" >> $GITHUB_OUTPUT
- name: Chart | Push
uses: appany/helm-oci-chart-releaser@v0.5.0
with:
name: ref
repository: climate-ref/charts
tag: ${{ steps.semantic-version.outputs.generated-semver }}
path: helm
registry: ghcr.io
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
update_dependencies: 'true'
test:
name: Test Helm Deployment
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event_name == 'pull_request' && needs.changes.outputs.helm == 'true'
needs: [changes, containers, helm]
steps:
- uses: actions/checkout@v6
- name: Cache Sample Data (Restore)
id: cache-sample-data-restore
uses: actions/cache/restore@v5
with:
path: ${{ github.workspace }}/cache/ref-config
key: ${{ runner.os }}-sample-data
enableCrossOsArchive: true
- name: Set permissions for cached data
run: |
sudo install -d --owner=1000 --group=1000 ${GITHUB_WORKSPACE}/cache/ref-config
- name: Start minikube
uses: medyagh/setup-minikube@latest
with:
mount-path: '${{ github.workspace }}/cache/ref-config:/cache/ref-config'
- name: Set up Helm
uses: azure/setup-helm@v5.0.0
- name: Install Chart
run: |
helm install test oci://ghcr.io/climate-ref/charts/ref \
--version=${{ needs.helm.outputs.generated-semver }} \
--set defaults.image.tag=pr-${{ github.event.pull_request.number }} \
-f helm/ci/gh-actions-values.yaml
sleep 60
kubectl get pods
echo ""
kubectl describe pod -l app.kubernetes.io/component=pmp
echo ""
kubectl logs -l app.kubernetes.io/component=pmp
- name: Run Migrations
run: |
kubectl exec deployment/test-ref-orchestrator -- ref config list
- name: Initialize Providers
run: |
# Imports ilamb3 which tries to create /home/app/.config/ilamb3 on import, no way to tell it to live somewhere else
# First, set up all providers without fetching data (handles conda envs)
kubectl exec deployment/test-ref-orchestrator -- ref providers setup --skip-data --skip-validate
# Fetch data for providers except esmvaltool (ERA5 data is too large for CI)
kubectl exec deployment/test-ref-orchestrator -- ref providers setup --provider pmp
kubectl exec deployment/test-ref-orchestrator -- ref providers setup --provider ilamb
- name: Fetch Test Data
run: |
kubectl exec deployment/test-ref-orchestrator -- ref datasets fetch-data --registry sample-data --output-directory /ref/sample-data
- name: Cache Sample Data (Save)
uses: actions/cache/save@v5
with:
path: ${{ github.workspace }}/cache/ref-config
key: ${{ runner.os }}-sample-data
- name: Ingest Test Data (CMIP6)
run: |
kubectl exec deployment/test-ref-orchestrator -- ref -v datasets ingest --source-type cmip6 /ref/sample-data/CMIP6
- name: Ingest Test Data (obs4mips)
run: |
kubectl exec deployment/test-ref-orchestrator -- ref -v datasets ingest --source-type obs4mips /ref/sample-data/obs4REF
- name: Simple Solve
run: |
# Use a fixed set of fast diagnostics to keep CI times predictable
kubectl exec deployment/test-ref-orchestrator -- ref -v solve --timeout 720 --one-per-provider \
--diagnostic global-mean-timeseries \
--diagnostic annual-cycle \
--diagnostic gpp-wecann
- name: Capture Worker Logs on Failure
if: failure()
run: |
echo "=== PMP Worker Logs ==="
kubectl logs -l app.kubernetes.io/component=pmp --tail=500 || true
echo ""
echo "=== ESMValTool Worker Logs ==="
kubectl logs -l app.kubernetes.io/component=esmvaltool --tail=500 || true
echo ""
echo "=== ILAMB Worker Logs ==="
kubectl logs -l app.kubernetes.io/component=ilamb --tail=500 || true
echo ""
echo "=== Example Worker Logs ==="
kubectl logs -l app.kubernetes.io/component=example --tail=500 || true
echo ""
echo "=== Orchestrator Worker Logs ==="
kubectl logs -l app.kubernetes.io/component=orchestrator --tail=500 || true
echo ""
echo "=== Flower Logs ==="
kubectl logs -l app.kubernetes.io/component=flower --tail=500 || true
echo ""
echo "=== Dragonfly Logs ==="
kubectl logs -l app.kubernetes.io/name=dragonfly --tail=500 || true