Skip to content

ci: add a CI workflow with a gate - #37

Merged
uniqueg merged 6 commits into
devfrom
ci/add-ci-workflow
Nov 6, 2026
Merged

uniqueg merged 6 commits into
devfrom
ci/add-ci-workflow

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

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.

  • Jobs: 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 pushes Push image and Publish image, gate CI passed.
  • Publishing as in cloud-registry: on pushes to dev, both images (pubgrade, pubgrade-updater) are pushed by digest in the environment dev-images, scanned by digest, then attested, signed with Sigstore (keyless) and tagged dev and sha-<commit>. Org secrets DOCKERHUB_LOGIN, DOCKERHUB_TOKEN, CODECOV_TOKEN, variable DOCKERHUB_ORG (default elixircloud). latest isn't updated any more, as it's for releases, which don't exist here yet; no date tags.
  • Replaces .travis.yml and main.yaml.
  • Fixes the 5 failing unit tests, all on the test side: shared mock data changed by inserts, and a missing app context.
  • pymongo 3.13 in the image: FOCA 0.7 pins 3.10, which doesn't start on current MongoDB versions.
  • .dockerignore excludes .env* at any depth, helm/ and test reports.
  • Chart apiVersion: v2, as the chart already sets type; org images in values.yaml.
  • README: development section with tests, CI, publishing requirements and how to verify signatures.

Lint, type checks, further test levels, docs and release workflows follow in the other children of #51. Scan image can become a real gate with the move to a newer FOCA.

How it was verified

  • make test: 106 passed, 100% coverage, reports/coverage.xml written 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.
  • Image plus mongo:7.0 locally, tests/smoke.sh: pass.
  • actionlint 1.7.12 and zizmor 1.16.3 (offline) on ci.yml: no findings.
  • Full review (adversarial and quality reviewers, 2 rounds): findings fixed (docs of the publishing requirements, coverage report on failed runs, comments).
  • CI on this PR: see the checks. Push image and Publish image run only after the merge, so they're first exercised on dev.

Declined review findings

  • The two build/push and attest steps are written out per image instead of a matrix: a matrix job can't return one digest output per entry without artifacts; the explicit steps keep the outputs readable.
  • A queued Publish image job 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

  • Environment dev-images restricted to dev, with access to the org secrets DOCKERHUB_LOGIN and DOCKERHUB_TOKEN; CODECOV_TOKEN visible to the repo (a missing token fails Test on pushes).

🤖 Generated with Claude Code

uniqueg and others added 3 commits November 5, 2026 05:25
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]>
@sourcery-ai

sourcery-ai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Introduces a GitHub Actions CI workflow with a single CI passed gate, covering title validation, containerized tests, Helm validation, image smoke testing, and report-only scanning, while publishing tagged images on dev. The PR also updates image dependencies and metadata, fixes test isolation and application-context issues, adds smoke coverage, and documents the new development and release-tagging workflow.

Sequence diagram for publishing images on dev pushes

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

Flow diagram for the CI workflow and gate

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

File-Level Changes

Change Details Files
Replaced the legacy Travis and main workflows with a gated GitHub Actions pipeline for pull requests and pushes to dev.
  • Runs PR-title validation, containerized unit tests with required coverage, Helm lint/render checks, an image-plus-MongoDB smoke test, and report-only image scanning.
  • Publishes application and updater images after successful checks on dev, using dev, commit SHA, and date tags rather than latest.
  • Aggregates job outcomes through the CI passed required check, with concurrency handling and explicit allowances for intentional skips.
.github/workflows/ci.yml
.travis.yml
.github/workflows/main.yaml
Aligned dependency automation, container configuration, and image publishing with the new CI and FOCA-based build process.
  • Added monthly grouped Dependabot updates for GitHub Actions and a Trivy ignore configuration.
  • Updated the Docker image to install pymongo==3.13.0 over the pinned base dependency to support current MongoDB versions.
  • Updated image defaults, Makefile commands, and Docker ignore rules for the Elixir Cloud images and Helm layout.
.github/dependabot.yml
.trivyignore.yaml
.dockerignore
Dockerfile
Makefile
helm/values.yaml
Made the test suite deterministic and added end-to-end validation of the running image.
  • Added an autouse fixture that restores shared mock dictionaries between tests and supplied missing Flask application contexts in affected tests.
  • Added a smoke script covering repository listing, creation, access-token redaction, and missing-resource behavior.
tests/conftest.py
tests/pubgrade/endpoints/test_builds.py
tests/smoke.sh
Updated chart metadata and project documentation for Helm v3 and the new CI-driven development workflow.
  • Changed the chart to apiVersion: v2 and documented the helm/ paths and development test workflow.
  • Replaced Travis and Coveralls badges with the GitHub Actions status badge and documented published image tags.
helm/Chart.yaml
README.md
Moved test tooling into an explicit package extra and configured coverage reporting for image-based test execution.
  • Added pinned coverage and pytest dependencies under the test extra.
  • Adjusted coverage configuration to support the updated test command.
setup.py
setup.cfg

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

@uniqueg
uniqueg marked this pull request as ready for review November 5, 2026 04:55

@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 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


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

Comment thread helm/values.yaml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread tests/pubgrade/endpoints/test_builds.py Resolved
Comment thread .github/workflows/ci.yml Resolved
uniqueg and others added 2 commits November 6, 2026 05:01
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]>
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

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 ☂️

@uniqueg
uniqueg merged commit 10804d0 into dev Nov 6, 2026
26 of 34 checks passed
@uniqueg
uniqueg deleted the ci/add-ci-workflow branch November 6, 2026 04:38
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.

ci: add a CI workflow with a gate

1 participant