Skip to content

ci(chart): install test on kind and GHCR release - #365

Merged
uniqueg merged 28 commits into
devfrom
feat/chart-kind-release
Oct 22, 2026
Merged

uniqueg merged 28 commits into
devfrom
feat/chart-kind-release

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

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's urllib, with the petstore image). The template tests render with --no-hooks; a new test checks the hook.

  • kind install (charts.yml, job install): 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 runs ct install (install, wait until ready, helm test). If it fails, a step prints the cluster state. charts.yml can also be called by other workflows (workflow_call).

  • Release (release-chart.yml): runs on pushed chart-v* tags, first calls charts.yml (lint, tests, kind install), then checks:

    • the tag names a final version (chart-vX.Y.Z) equal to version in charts/foca-common/Chart.yaml;
    • the commit is on dev;
    • the tag is annotated, its signature is verified by GitHub, and it points at the checked-out commit;
    • the version is not published yet (published versions are never overwritten).

    It then packages the chart and pushes it to oci://ghcr.io/elixir-cloud-aai/charts with the job's GITHUB_TOKEN (packages: write only in that job). Chart releases come from dev on purpose (FOCA's releases come from main), 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 only v* tags (tag_regex and git describe --match 'v[0-9]*'), which needs setuptools-scm 9, so the build requirement is now setuptools-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 / (werkzeug BuildError for 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.md covers 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: passed
  • actionlint on all workflows: passed; shellcheck on the run scripts: passed
  • mkdocs build --strict: passed
  • python -m setuptools_scm with setuptools-scm 10.3.4 and a local chart-v0.1.0 tag: the version still comes from the v* tags
  • Not run locally: the kind install (no Docker here) and the release workflow (it needs a pushed signed tag). The kind install runs in this PR's CI. The release workflow runs on the first chart-v0.1.0 tag.
  • CI: all checks pass on b9f4024 (after Sourcery's fixes and merging dev), including the kind install, where helm test ran the test-api hook 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

uniqueg and others added 24 commits October 21, 2026 23:52
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]>
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]>
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]>
# Conflicts:
#	.github/workflows/charts.yml
#	charts/foca-common/tests/chart_helpers.py
#	charts/foca-common/tests/test_templates.py
#	docs/helm-chart.md
@sourcery-ai

sourcery-ai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR adds a reusable kind-based Helm installation and API hook test, introduces a signed-tag-validated GHCR release workflow for foca-common, fixes CI probes to target the served OpenAPI spec, prevents chart tags from affecting Python package versions, and documents the independent chart release process.

Sequence diagram for kind-based petstore chart installation

sequenceDiagram
    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
Loading

Sequence diagram for signed Helm chart release

sequenceDiagram
    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
Loading

Flow diagram for independent chart and Python version tags

flowchart 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]
Loading

File-Level Changes

Change Details Files
Adds an end-to-end kind-based chart installation job and makes chart checks reusable by release workflows.
  • Makes the charts workflow callable by other workflows.
  • Pins Helm, chart-testing, kind, and GitHub Actions versions.
  • Builds and loads the FOCA/petstore images, provisions MongoDB credentials, runs ct install and helm test, and dumps cluster diagnostics on failure.
.github/workflows/charts.yml
Introduces a guarded OCI release workflow for the foca-common library chart.
  • Triggers on chart-vX.Y.Z tags after the shared chart checks pass.
  • Validates final-version syntax, chart version matching, ancestry on dev, annotated GitHub-verified signatures, and tag/checkout alignment.
  • Prevents overwriting published versions, then packages and pushes the chart to GHCR with job-scoped package write permissions.
.github/workflows/release-chart.yml
Adds a Helm test hook that exercises the deployed petstore API end to end.
  • Creates a test pod using the application image and Python urllib to create and retrieve a pet through the Kubernetes Service.
  • Adds template-level assertions for hook metadata, image, URL, and executable test code.
  • Excludes hooks from ordinary template tests so the hook is tested separately.
examples/petstore/chart/templates/tests/test-api.yaml
charts/foca-common/tests/chart_helpers.py
charts/foca-common/tests/test_templates.py
Updates application health checks to use the served OpenAPI specification instead of the broken Swagger UI endpoint.
  • Changes startup, readiness, and liveness probes from /ui/ to /openapi.json.
  • Updates expected snapshots and documents the API/spec endpoints in chart notes.
examples/petstore/chart/values.yaml
charts/foca-common/tests/__snapshots__/default.yaml
charts/foca-common/tests/__snapshots__/ingress-https.yaml
charts/foca-common/tests/__snapshots__/mongodb-external.yaml
charts/foca-common/tests/__snapshots__/route.yaml
examples/petstore/chart/templates/NOTES.txt
Separates Python package version discovery from chart release tags.
  • Restricts setuptools-scm tag matching and git describe to v* tags.
  • Raises the build requirement to setuptools-scm 9.
pyproject.toml
Documents independent chart releases and GHCR package administration.
  • Documents signed chart-vX.Y.Z tagging from dev, workflow validation, first-release recovery, and package visibility/access settings.
  • Links the release instructions from the README.
docs/helm-chart.md
README.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (fb27bd7) to head (b9f4024).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #365   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        25           
  Lines         2000      2000           
=========================================
  Hits          2000      2000           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

uniqueg and others added 2 commits October 22, 2026 01:35
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]>
@uniqueg
uniqueg marked this pull request as ready for review October 22, 2026 00:00

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread .github/workflows/release-chart.yml Resolved
Comment thread .github/workflows/release-chart.yml Resolved
Comment thread .github/workflows/release-chart.yml Resolved
uniqueg and others added 2 commits October 22, 2026 02:05
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant