|
| 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 |
0 commit comments