Repository navigation
ci(chart): install test on kind and GHCR release - #365
Conversation
Add a Helm library chart for FOCA apps, extracted from the chart of cloud-registry (version 3): the app Deployment, the config overlay ConfigMap, Service, Ingress or OpenShift Route, NetworkPolicies and an optional MongoDB with credentials from an existing Secret. Templates take the root context and the app settings (values key, databases, generated config), so that app charts keep their values structure. Includes a JSON schema of the values for app charts to copy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add a thin chart for the petstore example on top of the library chart, and pytest tests rendering it with helm template: snapshot tests of a few sets of values and tests of the behavior of the templates. The tests need Helm, so the default test paths exclude them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add a workflow that lints the library and petstore charts and runs their tests with a pinned Helm version. Exclude Helm templates and snapshots from check-yaml. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe how to build an app chart on the library chart: settings, templates, values and schema, deployment notes and development. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Install Gunicorn in the petstore image and serve the app with it via a WSGI app factory (wsgi.py), so that the image works with the thin chart; Docker Compose still runs the development server. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fail without config.db.host if the bundled MongoDB is disabled, with the parse error if the app settings are not valid YAML, and clearly if the values lack the mongodb map; do not panic on null security sections in the audience check. Make the pull policy of MongoDB configurable, and default the petstore chart to the locally built image (foca-petstore, IfNotPresent). Add tests of probes, grace periods, Gunicorn settings, Services and MongoDB settings, and document the Helm version of the snapshots. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pin a Gunicorn version that exists on PyPI, give the commands to build and load the petstore image, and document external MongoDB settings and the pull policy of MongoDB. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add a test hook pod to the petstore chart that adds a pet and reads it back via the app Service, checking the app, MongoDB and the app user. The template tests render without hooks and check the hook separately. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build the FOCA and petstore images, load them into a kind cluster, create the MongoDB credentials and install the petstore chart with chart-testing, which runs its helm test. Tools and actions are pinned. Co-Authored-By: Claude Opus 5.5 <[email protected]>
On a chart-vX.Y.Z tag, check that the tag is annotated with a verified signature, on dev, matches the chart version and is not published yet; lint and test the chart, then package it and push it to oci://ghcr.io/elixir-cloud-aai/charts. Document releases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t/chart-kind-release
Call charts.yml (now also a reusable workflow) before publishing, so releases run the same lint, tests and kind installation as CI. Name the kind cluster explicitly, document that only final chart versions are released, and tidy the hook tests and docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Derive the external MongoDB host, audience and body size checks from the merged overlay (generated and values config), require the mongodb.auth map, strip build metadata from the version label, note missing TLS in the petstore notes, and document the limits of the MongoDB init script (Sourcery review). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Derive the package version only from FOCA release tags (vX.Y.Z and pre-releases), not from the tags of the Helm library chart (chart-vX.Y.Z), which setuptools-scm would otherwise pick up on dev. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Require the signed tag to point to the checked-out commit, publish only if GHCR reports the version as not found (or, on the first release, the package as inaccessible), keep the kind releases for debugging, and document making the package public after the first release. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t/chart-kind-release # Conflicts: # charts/foca-common/tests/test_templates.py
Require setuptools-scm 9, which added the `scm.git` describe_command option used to ignore chart tags. Document the GHCR package settings an admin sets after the first release, how to retry a failed first release, why chart releases come from `dev`, and that the published version check matches Helm's messages on a best-effort basis. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # .pre-commit-config.yaml # pyproject.toml
Add docstrings and return types to the chart tests and justify the subprocess call, as the shared ruff standard (#358) requires. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t/chart-kind-release
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # .github/workflows/charts.yml # charts/foca-common/tests/chart_helpers.py # charts/foca-common/tests/test_templates.py # docs/helm-chart.md
Reviewer's GuideThe PR adds a reusable kind-based Helm installation and API hook test, introduces a signed-tag-validated GHCR release workflow for Sequence diagram for kind-based petstore chart installationsequenceDiagram
participant CI as GitHub Actions
participant Kind as kind cluster
participant CT as chart-testing
participant Helm as Helm
participant App as Petstore API
participant Mongo as MongoDB
CI->>Kind: Create cluster
CI->>Kind: Build and load petstore image
CI->>Kind: Create namespace and mongodb Secret
CI->>CT: ct install
CT->>Helm: Install petstore chart
Helm->>Kind: Deploy Petstore and MongoDB
Kind->>Mongo: Start database
Kind->>App: Start API with probePath /openapi.json
CT->>Helm: helm test
Helm->>Kind: Create test-api hook Pod
Kind->>App: Create pet through API
Kind->>App: Read pet through API
App-->>Kind: Return created pet
Sequence diagram for signed Helm chart releasesequenceDiagram
actor Maintainer
participant GitHub as GitHub Actions
participant Charts as charts.yml
participant Git as Git repository
participant GHCR as GHCR OCI registry
Maintainer->>Git: Push signed chart-vX.Y.Z tag
Git-->>GitHub: Trigger release-chart.yml
GitHub->>Charts: Call reusable workflow
Charts-->>GitHub: Lint, template tests, kind install and helm test pass
GitHub->>Git: Check tag format, chart version and dev ancestry
GitHub->>Git: Verify annotated tag signature and commit
GitHub->>GHCR: helm show chart for version
GHCR-->>GitHub: Version not published
GitHub->>GHCR: helm package and helm push
GHCR-->>GitHub: Store foca-common OCI artifact
Flow diagram for independent chart and Python version tagsflowchart LR
ChartTag[chart-vX.Y.Z tag] --> ChartRelease[Release foca-common to GHCR]
ChartTag --> Ignore[Excluded from setuptools-scm]
PythonTag[vX.Y.Z tag] --> PythonVersion[Python package version]
PythonVersion --> FOCARelease[FOCA release workflow]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #365 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 25 25
Lines 2000 2000
=========================================
Hits 2000 2000
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The kind install showed that the Swagger UI (`/ui/`) of the petstore example returns 500, as Connexion cannot build the spec URL for APIs at `/` (BuildError for endpoint '/._openapi_json'), so the pod never got ready. Probe the served spec (`/openapi.json`) instead and point the NOTES to the API and its spec. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # README.md
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/release-chart.yml" line_range="84" />
<code_context>
+ exit 1
+ fi
+ tag="$(gh api "repos/${GH_REPO}/git/tags/$(jq -r '.object.sha' <<< "${ref}")")"
+ if [ "$(jq -r '.verification.verified' <<< "${tag}")" != "true" ]; then
+ echo "::error::Tag '${TAG}' has no verified signature"
+ exit 1
</code_context>
<issue_to_address>
**Unapproved signers can publish charts**
When a repository writer who is not an approved release signer pushes a GitHub-verified chart tag for an unpublished version on `dev`, the check accepts any GitHub-verified signer, without checking whether that identity is authorized to release. A repository writer can sign and push an unpublished `chart-vX.Y.Z` tag for a matching commit on `dev`, triggering the job with `packages: write` and publishing the chart without release approval.
Restrict publishing to approved signer identities or require an appropriately protected release approval before granting `packages: write`.
Also at `.github/workflows/release-chart.yml:42`.
</issue_to_address>
### Comment 2
<location path=".github/workflows/release-chart.yml" line_range="83-88" />
<code_context>
+ echo "::error::Tag '${TAG}' is not an annotated (signed) tag"
+ exit 1
+ fi
+ tag="$(gh api "repos/${GH_REPO}/git/tags/$(jq -r '.object.sha' <<< "${ref}")")"
+ if [ "$(jq -r '.verification.verified' <<< "${tag}")" != "true" ]; then
+ echo "::error::Tag '${TAG}' has no verified signature"
+ exit 1
+ fi
+ if [ "$(jq -r '.object.sha' <<< "${tag}")" != "$(git rev-parse HEAD)" ]; then
+ echo "::error::Tag '${TAG}' does not point to the checked-out commit"
+ exit 1
</code_context>
<issue_to_address>
**Signed tag name is not verified**
When a `chart-vX.Y.Z` ref points to a verified annotated tag object whose signed tag name differs from the ref name, the check verifies the pointed-to tag object’s signature and target commit but never compares its signed `.tag` name with `${TAG}`. A `chart-vX.Y.Z` ref pointing to a different-name signed tag object for the same commit therefore passes, and the workflow publishes without a signature over the release tag name.
Require the annotated tag object’s `.tag` field to equal `${TAG}` before publishing.
</issue_to_address>
### Comment 3
<location path=".github/workflows/release-chart.yml" line_range="22" />
<code_context>
+
+# One release at a time
+concurrency:
+ group: ${{ github.workflow }}
+ cancel-in-progress: false
+
</code_context>
<issue_to_address>
**Chart releases get skipped**
When a chart release is running, another release is pending, and a newer tag is pushed, gitHub replaces the pending run with the newer one, so the earlier version is never published and dependent charts cannot pull it. Use a release mechanism that queues every tag instead of relying on this single-pending-run concurrency group.
Replace this concurrency setup with a release mechanism that queues every tag for publication.
</issue_to_address>
### Comment 4
<location path="examples/petstore/chart/templates/tests/test-api.yaml" line_range="15" />
<code_context>
+metadata:
+ name: {{ printf "%s-test-api" $fullname | quote }}
+ labels:
+ {{- include "foca-common.labels" (dict "root" . "component" "test") | nindent 4 }}
+ annotations:
+ helm.sh/hook: test
</code_context>
<issue_to_address>
**Helm test blocked by policy**
When the chart enables `networkPolicy` and its `ingressFrom` peers do not include the test pod, the test pod has component `test`, while the app NetworkPolicy selects app pods and admits only peers in `ingressFrom`. When `networkPolicy.enabled` is true and that list excludes the test pod, its requests to the app Service are blocked and `helm test` fails.
Allow the test pod as an ingress peer when rendering the app NetworkPolicy, or otherwise ensure the hook can reach the app when the policy is enabled.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 4 findings to address first, and a signed chart tag can cause this workflow to publish a chart version to GHCR, where consumers may download and deploy it. Reverting the workflow does not retract an already published version or undo deployments; running the new Helm test also writes a pet record to the chart’s MongoDB.
Blocking findings: .github/workflows/release-chart.yml:84, .github/workflows/release-chart.yml:88, .github/workflows/release-chart.yml:22, examples/petstore/chart/templates/tests/test-api.yaml:15
Check that the annotated tag object has the pushed tag's name, run releases of different tags independently instead of dropping pending ones, recommend a tag ruleset for who may release, and document how to let the helm test pass a NetworkPolicy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Follow-up to #357 (merged): installs the petstore example chart on a kind cluster in CI and adds the release workflow for the library chart
foca-common.Helm test hook:
examples/petstore/chart/templates/tests/test-api.yaml, a pod that creates a pet through the API and reads it back (Python'surllib, with the petstore image). The template tests render with--no-hooks; a new test checks the hook.kind install (
charts.yml, jobinstall): chart-testing v3.15.0 and kind v0.33.0 (actions pinned by SHA). The job builds the FOCA image and the petstore image on it, loads them into kind, creates the MongoDB Secret with random passwords, then runsct install(install, wait until ready,helm test). If it fails, a step prints the cluster state.charts.ymlcan also be called by other workflows (workflow_call).Release (
release-chart.yml): runs on pushedchart-v*tags, first callscharts.yml(lint, tests, kind install), then checks:chart-vX.Y.Z) equal toversionincharts/foca-common/Chart.yaml;dev;It then packages the chart and pushes it to
oci://ghcr.io/elixir-cloud-aai/chartswith the job'sGITHUB_TOKEN(packages: writeonly in that job). Chart releases come fromdevon purpose (FOCA's releases come frommain), so app charts can use a chart change without waiting for a FOCA release.Package version:
chart-v*tags must not become FOCA's version. setuptools-scm now matches onlyv*tags (tag_regexandgit describe --match 'v[0-9]*'), which needs setuptools-scm 9, so the build requirement is nowsetuptools-scm>=9.Probe fix (found by the kind install): the Swagger UI (
/ui/) of the petstore returns 500. Connexion 2 cannot build the spec URL for an API served at/(werkzeugBuildErrorfor endpoint/._openapi_json; reproduced locally with a test client), so the probes never passed. The petstore chart now probes the served spec,/openapi.json, and NOTES.txt points to the API and its spec. The Swagger UI bug itself is not fixed here; it affects every FOCA app served at/.Docs: a "Releases" section in
docs/helm-chart.mdcovers tagging, what the workflow checks, a failed first release, and the GHCR package settings an admin changes after the first release. A paragraph in the README links to it.Closes #356
How it was verified
pytest charts/foca-common/tests: 93 passed (Helm v3.22.1)ruff check,ruff format --check: passedactionlinton all workflows: passed;shellcheckon the run scripts: passedmkdocs build --strict: passedpython -m setuptools_scmwith setuptools-scm 10.3.4 and a localchart-v0.1.0tag: the version still comes from thev*tagschart-v0.1.0tag.dev), including the kind install, wherehelm testran thetest-apihook with phase Succeeded. The first run failed because the petstore pod never got ready (see the probe fix above); 69e9d4d fixes it. Sourcery re-reviewed; its 4 threads are answered and resolved.Declined review findings
First release when an earlier, unpublished
chart-v*tag exists (adversarial reviewer, low): the check accepts "denied" from GHCR only if no other chart tag exists. This is documented ("if the first release fails, delete its tag before tagging again") rather than loosened, because loosening it would let other access errors through.The way the not-published check reads Helm's errors (": not found", "denied") is best-effort, and a comment says so. If Helm's messages change, the check fails closed instead of overwriting anything. What GHCR returns to an authenticated token for a package that does not exist yet is not verified; check the log of the first release.
Signer allow-list in the workflow (Sourcery): not added. The tag ruleset on
chart-v*decides who may release, and the docs now recommend one. A protected environment with required reviewers is a maintainer decision.Admitting the helm test pod in the library's app NetworkPolicy (Sourcery): documented in the hook instead. Changing the library would change the rendered NetworkPolicy for every app chart (cloud-registry's must stay unchanged). The policy is off by default and in CI.
Sourcery's other two findings are fixed: the tag object's name is checked, and the concurrency group is per tag.
Open questions
None.
🤖 Generated with Claude Code