Repository navigation
ci: add a CI workflow with a gate - #37
Conversation
Inserting shared mock data into a collection adds an `_id`, and later tests couldn't serialize it. Two more tests lacked an app context. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replaces Travis and `main.yaml`. Tests run in the image. The smoke test uses MongoDB 7, which needs a newer pymongo than FOCA 0.7 pins. Excludes `.env*` from the image build context. Closes #32 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideIntroduces a GitHub Actions CI workflow with a single Sequence diagram for publishing images on dev pushessequenceDiagram
participant GitHub
participant CI
participant DockerHub
GitHub->>CI: Trigger push workflow on dev
CI->>CI: Run test, chart, and smoke jobs
CI->>CI: Check that commit is branch head
CI->>DockerHub: Log in with Docker Hub credentials
CI->>DockerHub: Build and push pubgrade and pubgrade-updater
CI->>DockerHub: Publish dev, sha-<commit>, and date tags
CI->>GitHub: Report CI passed
Flow diagram for the CI workflow and gateflowchart TD
Event[Pull request or push to dev] --> Title[PR title]
Event --> Test[Test: containerized unit tests]
Event --> Chart[Chart: Helm lint and render]
Event --> Smoke[Smoke test: app with MongoDB 7]
Event --> Scan[Scan image: report only]
Test --> Gate[CI passed]
Chart --> Gate
Smoke --> Gate
Title --> Gate
Scan --> Gate
Event -->|push to dev only| Push[Push tagged images]
Test --> Push
Chart --> Push
Smoke --> Push
Push --> Gate
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="helm/values.yaml" line_range="6" />
<code_context>
pubgrade_build_complete_updater:
replicaCount: 1
- image: "akash7778/pubgrade-updater" # This will be moved to elixir-cloud-aai
+ image: elixircloud/pubgrade-updater:dev
imagePullPolicy: IfNotPresent
</code_context>
<issue_to_address>
**Pods keep running old code**
When CI publishes a new `dev` image and an operator upgrades or restarts the Helm release without changing its image reference, helm renders the same `elixircloud/pubgrade-updater:dev` pod template, so the Deployment does not roll out; with `IfNotPresent`, a restarted pod can also use a cached older image, leaving the service on stale code.
Use an immutable image tag in the chart and update it when a new image is published so the pod template changes and the Deployment rolls out.
Also at `helm/values.yaml:36`.
</issue_to_address>
### Comment 2
<location path=".github/workflows/ci.yml" line_range="186" />
<code_context>
+ if [ "${head}" = "${SHA}" ]; then
+ echo "current=true" >> "$GITHUB_OUTPUT"
+ else
+ echo "::notice::Skipping push: ${REF} has moved on to ${head}"
+ fi
+ - name: Check out repository
</code_context>
<issue_to_address>
**Green gate without commit image**
When A push job starts after a newer commit has moved the branch head, the head-check step exits successfully when the branch has moved, and every later push step is conditionally skipped. GitHub therefore marks the `push` job successful, so the gate can pass even though this commit has no `sha-<commit>` image tag.
Make the stale-head path produce a non-success result, or explicitly represent and validate the intentional no-image outcome in the gate.
</issue_to_address>
### Comment 3
<location path=".github/workflows/ci.yml" line_range="105-107" />
<code_context>
+ - name: Start app
+ run: |
+ docker network create smoke
+ docker run --detach --name mongodb --network smoke \
+ --network-alias mongodb.pubgrade-ns mongo:7.0
+ docker run --detach --name pubgrade --network smoke \
+ --publish 8080:8080 pubgrade:smoke
+ for _ in $(seq 1 60); do
</code_context>
<issue_to_address>
**Smoke test races MongoDB startup**
When mongoDB takes longer to become ready than the app's initial database connection wait, the workflow starts the app immediately after starting MongoDB, without waiting for MongoDB readiness. `create_admin_user` queries the database during app startup, so if MongoDB is not accepting connections yet, the app can exit and the later UI polling and API checks fail.
Wait for MongoDB to accept a database command before starting the app, or configure an app restart/readiness mechanism that waits for MongoDB.
</issue_to_address>
### Comment 4
<location path="tests/pubgrade/endpoints/test_builds.py" line_range="451-461" />
<code_context>
f = open("basedir/drs-filer/Dockerfile", "w")
f.write("test dockerfile")
f.close()
- create_build(
- repo_url=self.repository_url,
- branch="dev",
- commit="122c34d",
- base_dir="basedir",
- build_id="build123",
- dockerfile_location="basedir/drs-filer/Dockerfile",
- intermediate_registry_path="test_intermediate_registry_path",
- dockerhub_token="dockerhub_token",
- project_access_token="access_token",
- )
+ self.setup()
+ with self.app.app_context():
</code_context>
<issue_to_address>
**No-op build generation passes**
When `create_build` returns without generating build artifacts or invoking the push function, `test_create_build` makes no assertions about generated files or the mocked push call; replacing `create_build` with a no-op still reaches the cleanup and passes, so the test accepts a build that was never created.
Assert that the expected artifacts are created and that the mocked push function is called.
</issue_to_address>
### Comment 5
<location path=".github/workflows/ci.yml" line_range="44" />
<code_context>
+ if: >-
+ github.event_name == 'pull_request' && (
+ github.event.pull_request.user.login != 'dependabot[bot]' ||
+ github.event.changes.title &&
+ github.event.sender.login != 'dependabot[bot]')
+ runs-on: ubuntu-latest
</code_context>
<issue_to_address>
**Dependabot title check skips**
The issue asks for a PR-title check, but this condition skips the shared check for unedited Dependabot pull requests. Run the check for those pull requests too, or otherwise ensure their titles meet the required format.
</issue_to_address>Linked issues
#32 ci: add a CI workflow with a gate · 11 of 12 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Check PR titles for Conventional Commits and a 50-character limit | 🟡 Partly met | The shared check runs for ordinary pull requests, but an unedited Dependabot pull request skips it. |
| 2 | Run unit tests with coverage in the deployed image | ✅ Met | The Test job runs make test, which builds and tests in the image; coverage is configured to require 100%. |
| 3 | Lint and render the Helm chart | ✅ Met | The Chart job runs helm lint --strict and helm template. |
| 4 | Smoke-test the image with MongoDB and API calls | ✅ Met | The Smoke test job starts the app with MongoDB 7 and runs tests/smoke.sh. |
| 5 | Run Trivy as a report-only image scan | ✅ Met | The scan action is configured to report without failing the job. |
| 6 | Publish both images on pushes to dev, replacing main.yaml | ✅ Met | The push job builds both images, runs only for push events, and the old workflow is deleted. |
| 7 | Have CI passed report on every pull request and fail when a needed job fails | ✅ Met | The gate uses always(), depends on all jobs, and allows only the documented skips. |
| 8 | Fix the failing tests and remove .travis.yml | ✅ Met | The shared mock-data fixture restores dictionaries after each test, the affected tests add app contexts, and .travis.yml is deleted. |
| 9 | Exclude .env* from the image build context | ✅ Met | The ignore rules exclude .env* at any depth; the .env.example exception is retained as a sample file. |
| 10 | Point the README badges and Makefile to the new setup | ✅ Met | The badges now point to GitHub Actions, and the Makefile uses the new image names and chart path. |
| 11 | Keep GitHub Actions up to date with Dependabot | ✅ Met | Dependabot is configured for GitHub Actions updates on dev. |
| 12 | Publish images under the org on pushes to dev, only through ci.yml | ✅ Met | The workflow defaults to the elixircloud Docker Hub organization, and the previous publishing workflow is removed. |
Sourcery assessment
Needs a human reviewer. 5 findings to address first, and a successful push publishes the built images to Docker Hub, and the chart now defaults to those image repositories and tags. If the wrong image is published and consumers pull or deploy it, reverting restores the workflow and chart but does not undo images already distributed or deployments already made.
Blocking findings: helm/values.yaml:6, .github/workflows/ci.yml:186, .github/workflows/ci.yml:107, tests/pubgrade/endpoints/test_builds.py:461, .github/workflows/ci.yml:44
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Push both images by digest in the environment dev-images, scan exactly those digests, then attest, sign with Sigstore and tag them, as cloud-registry does. Report unit test coverage to Codecov. Drop the date tag, which the other repos don't publish. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Always write the coverage report and hand it to the host user, also when tests fail. Document the environment, secrets and variable that publishing needs, and how to verify an image's signature. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Summary
Closes #32 (part of #51). Adds
ci.yml/CI, following the org's other repos (cloud-registry in names and structure), as the first step of the upgrade path for M4.3.PR title,Test(in the image, as FOCA 0.7's base image pins the dependencies; 100% coverage required, report to Codecov),Chart,Smoke test(image plus MongoDB 7),Scan image (…)(report only, both images), on pushesPush imageandPublish image, gateCI passed.dev, both images (pubgrade,pubgrade-updater) are pushed by digest in the environmentdev-images, scanned by digest, then attested, signed with Sigstore (keyless) and taggeddevandsha-<commit>. Org secretsDOCKERHUB_LOGIN,DOCKERHUB_TOKEN,CODECOV_TOKEN, variableDOCKERHUB_ORG(defaultelixircloud).latestisn't updated any more, as it's for releases, which don't exist here yet; no date tags..travis.ymlandmain.yaml.pymongo3.13 in the image: FOCA 0.7 pins 3.10, which doesn't start on current MongoDB versions..dockerignoreexcludes.env*at any depth,helm/and test reports.apiVersion: v2, as the chart already setstype; org images invalues.yaml.Lint, type checks, further test levels, docs and release workflows follow in the other children of #51.
Scan imagecan become a real gate with the move to a newer FOCA.How it was verified
make test: 106 passed, 100% coverage,reports/coverage.xmlwritten with relative paths and owned by the host user (also when tests fail).helm lint helm --strict,helm template: pass with Helm 3.22.1.mongo:7.0locally,tests/smoke.sh: pass.actionlint1.7.12 andzizmor1.16.3 (offline) onci.yml: no findings.Push imageandPublish imagerun only after the merge, so they're first exercised ondev.Declined review findings
Publish imagejob that GitHub cancels when several commits land at once makes the gate of that commit fail. Accepted and noted in the workflow: the newest commit's images are published.Needs from the repo settings
dev-imagesrestricted todev, with access to the org secretsDOCKERHUB_LOGINandDOCKERHUB_TOKEN;CODECOV_TOKENvisible to the repo (a missing token failsTeston pushes).🤖 Generated with Claude Code