From 54abbe4932ce3b448d3d8eb639b772a1a99a147d Mon Sep 17 00:00:00 2001 From: Toby Hede Date: Fri, 4 Dec 2026 17:26:08 +1100 Subject: [PATCH 1/2] ci(release): smoke test the published image after each release The integration suite only ever ran against a Proxy image built from source, so nothing checked the image customers actually pull from Docker Hub after a release. `mise run proxy:up` now takes a PROXY_IMAGE variable. When it is set, proxy:up pulls that image and tags it as cipherstash/proxy:latest, the image tests/docker-compose.yml runs, instead of building from source. A new Smoke test workflow runs the integration suite against a published image on PostgreSQL 14 to 17. release.yml calls it after the merge job publishes a release's multi-platform image, passing the released version. A pull request that changes the workflow runs it against `latest`. Ported from the release/2.2 change. --- .github/workflows/release.yml | 12 ++++++ .github/workflows/smoke-test.yml | 69 ++++++++++++++++++++++++++++++++ DEVELOPMENT.md | 11 +++++ mise.toml | 15 ++++--- tests/docker-compose.yml | 8 ++-- 5 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/smoke-test.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 35e8037e5..702f23623 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -130,6 +130,8 @@ jobs: - build env: publish: ${{contains(fromJSON('["push", "release"]'), github.event_name)}} + outputs: + version: ${{ steps.meta.outputs.version }} steps: - uses: actions/checkout@v7 @@ -184,3 +186,13 @@ jobs: if: ${{ fromJSON(env.publish) }} run: | docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} + + smoke-test: + name: Smoke test published image + needs: + - merge + if: github.event_name == 'release' + uses: ./.github/workflows/smoke-test.yml + with: + version: ${{ needs.merge.outputs.version }} + secrets: inherit diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml new file mode 100644 index 000000000..45e1639d9 --- /dev/null +++ b/.github/workflows/smoke-test.yml @@ -0,0 +1,69 @@ +name: Smoke test + +# Runs the integration suite against a published Proxy image instead of one built from source. +# `release.yml` calls it after a release's image is published. +# A pull request that changes this workflow runs it against the `latest` published image. +on: + workflow_call: + inputs: + version: + description: Published image version to test, such as 3.1.1 + required: true + type: string + pull_request: + branches: + - main + paths: + - '.github/workflows/smoke-test.yml' + +env: + CARGO_TERM_COLOR: always + +jobs: + smoke-test: + name: Smoke test cipherstash/proxy:${{ inputs.version || 'latest' }} (PostgreSQL ${{ matrix.pg_version }}) + runs-on: blacksmith-16vcpu-ubuntu-2204 + strategy: + fail-fast: false + matrix: + pg_version: [14, 15, 16, 17] # PG 18 not currently supported + env: + PG_VERSION: ${{ matrix.pg_version }} + PROXY_IMAGE: cipherstash/proxy:${{ inputs.version || 'latest' }} + CS_ZEROKMS_HOST: https://us-east-1.aws.zerokms.cipherstashmanaged.net + CS_CTS_HOST: https://ap-southeast-2.aws.cts.cipherstashmanaged.net + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v7 + - uses: ./.github/actions/setup-test + + - name: Decrypt secrets + uses: cipherstash/secrets-action@main + with: + secrets-file: .github/secrets.env.encrypted + env: + CS_CLIENT_ID: ${{ secrets.CS_VAULT_CLIENT_ID }} + CS_CLIENT_KEY: ${{ secrets.CS_VAULT_CLIENT_KEY }} + CS_CLIENT_ACCESS_KEY: ${{ secrets.CS_VAULT_CLIENT_ACCESS_KEY }} + CS_WORKSPACE_CRN: ${{ secrets.CS_VAULT_WORKSPACE_CRN }} + + - name: Show the image under test + run: | + docker pull --quiet "${PROXY_IMAGE}" + docker image inspect "${PROXY_IMAGE}" --format '{{index .RepoDigests 0}} {{.Created}}' + + - run: | + mise run postgres:up --extra-args "--detach --wait" + + - name: Run integration tests against the published image + env: + RUST_BACKTRACE: "1" + run: | + mise run --output prefix test:integration + + - name: Show proxy logs on failure + if: failure() + run: | + docker logs --timestamps proxy 2>&1 || true + docker logs --timestamps proxy-tls 2>&1 || true diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 481547139..42728f6b3 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -460,6 +460,17 @@ Integration tests are defined in `tests/tasks/test/`. Integration tests verify behaviour from a PostgreSQL client (`psql`), to Proxy (running in a container), to a PostgreSQL instance (running in a container). +By default `mise run proxy:up` builds the Proxy image from source, so the tests run against your working tree. +To run them against a published image instead, set `PROXY_IMAGE`: + +```bash +PROXY_IMAGE=cipherstash/proxy:3.1.1 mise run test:integration +``` + +`proxy:up` then pulls that image and tags it as `cipherstash/proxy:latest`, the image `tests/docker-compose.yml` runs, and skips the build. +The test clients still come from your checkout, so check out the release's tag to test it with its own tests. +After a release is published, `release.yml` runs this suite against the new image in the `Smoke test published image` job. + The integration tests have several runtime dependencies: - Running PostgreSQL instances (that can be started with `mise run postgres:up`) diff --git a/mise.toml b/mise.toml index 80ef048c0..ab5a6c568 100644 --- a/mise.toml +++ b/mise.toml @@ -71,11 +71,16 @@ set -e {% set target = target_arch ~ "-unknown-linux-gnu" %} {% set docker_platform = "linux/" ~ arch() | replace(from="x64", to="amd64") %} -# build a binary -mise run build:binary --target {{target}} - -# build a new container -mise run build:docker --platform {{docker_platform}} +if [ -n "${PROXY_IMAGE:-}" ]; then + # Test a published image instead of building from source. + # tests/docker-compose.yml never pulls, so tag the image as the one it runs. + echo "Using published image: ${PROXY_IMAGE}" + docker pull --quiet "${PROXY_IMAGE}" + docker tag "${PROXY_IMAGE}" cipherstash/proxy:latest +else + mise run build:binary --target {{target}} + mise run build:docker --platform {{docker_platform}} +fi # Make the default invocation with `mise run proxy:up` work. # The default mise environment configuration works for Proxy running as a process, connecting via a port forward. diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 9c3e606bb..3fe7ff26f 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -48,10 +48,10 @@ services: proxy: image: cipherstash/proxy:latest - # Never pull from Docker Hub. The proxy image must be built from source - # via `mise run proxy:up` (which runs build:binary + build:docker). - # This ensures integration tests always run against the current source, - # not the released version on Docker Hub. + # Never pull from Docker Hub. `mise run proxy:up` builds this image from + # source (build:binary + build:docker), so integration tests run against + # the current source. With PROXY_IMAGE set, proxy:up instead pulls that + # published image and tags it as cipherstash/proxy:latest. pull_policy: never container_name: proxy ports: From dd5c06f0810fd776da32ca9585555012058082aa Mon Sep 17 00:00:00 2001 From: Toby Hede Date: Fri, 4 Dec 2026 18:07:01 +1100 Subject: [PATCH 2/2] ci(release): alert on smoke test failure and harden the workflow Address review feedback on the release smoke test: - Notify Slack when the smoke test fails on a release. The image is already published by then, and the shared notification action only fires on main, so a failure would otherwise alert nobody. - Pull the published image only when it is missing. test:integration calls proxy:up many times, and each extra Docker Hub pull was another chance for a rate limit to fail a good release. - Limit the token to contents: read and pass the five secrets the workflow uses instead of inheriting every secret. - Update the two DEVELOPMENT.md passages that still said Proxy is always built from source for tests. --- .github/workflows/release.yml | 7 ++++++- .github/workflows/smoke-test.yml | 28 ++++++++++++++++++++++++++++ DEVELOPMENT.md | 6 +++--- mise.toml | 3 ++- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 702f23623..abb2de22a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -195,4 +195,9 @@ jobs: uses: ./.github/workflows/smoke-test.yml with: version: ${{ needs.merge.outputs.version }} - secrets: inherit + secrets: + CS_VAULT_CLIENT_ID: ${{ secrets.CS_VAULT_CLIENT_ID }} + CS_VAULT_CLIENT_KEY: ${{ secrets.CS_VAULT_CLIENT_KEY }} + CS_VAULT_CLIENT_ACCESS_KEY: ${{ secrets.CS_VAULT_CLIENT_ACCESS_KEY }} + CS_VAULT_WORKSPACE_CRN: ${{ secrets.CS_VAULT_WORKSPACE_CRN }} + SLACK_NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATION_WEBHOOK_URL }} diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 45e1639d9..f575ddc8a 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -10,12 +10,26 @@ on: description: Published image version to test, such as 3.1.1 required: true type: string + secrets: + CS_VAULT_CLIENT_ID: + required: true + CS_VAULT_CLIENT_KEY: + required: true + CS_VAULT_CLIENT_ACCESS_KEY: + required: true + CS_VAULT_WORKSPACE_CRN: + required: true + SLACK_NOTIFICATION_WEBHOOK_URL: + required: false pull_request: branches: - main paths: - '.github/workflows/smoke-test.yml' +permissions: + contents: read + env: CARGO_TERM_COLOR: always @@ -67,3 +81,17 @@ jobs: run: | docker logs --timestamps proxy 2>&1 || true docker logs --timestamps proxy-tls 2>&1 || true + + # The image is already published, so say so. Not the shared send-slack-notification + # action: it only fires on main, and a release run's ref is the tag. + - name: Notify Slack on failure + if: failure() && github.event_name == 'release' + uses: slackapi/slack-github-action@v1 + with: + payload: | + { + "text": ":alert::alert::alert:\n\nSmoke test failed for the published image `${{ env.PROXY_IMAGE }}`.\n\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>", + "channel": "#engineering" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATION_WEBHOOK_URL }} diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 42728f6b3..3181fc2c6 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -380,7 +380,7 @@ Running Proxy in a container cross-compiles a binary for Linux and the current a We cross-compile binary outside the container because it's generally faster, due to packages already being cached, and slower network and disk IO in Docker. > [!IMPORTANT] -> **Proxy must always be built from source for testing.** The `proxy:up` task builds a binary from source (`build:binary`), packages it into a Docker image tagged `cipherstash/proxy:latest` (`build:docker`), then starts it via `docker compose up`. The `tests/docker-compose.yml` file uses `pull_policy: never` on the proxy services to ensure Docker never pulls the released image from Docker Hub. If you see an error like `pull access denied` or `image not found`, run `mise run build` first to build the local image. +> **Proxy is built from source for testing, unless `PROXY_IMAGE` is set** (see [Integration tests](#integration-tests)). The `proxy:up` task builds a binary from source (`build:binary`), packages it into a Docker image tagged `cipherstash/proxy:latest` (`build:docker`), then starts it via `docker compose up`. The `tests/docker-compose.yml` file uses `pull_policy: never` on the proxy services to ensure Docker never pulls the released image from Docker Hub. If you see an error like `pull access denied` or `image not found`, run `mise run build` first to build the local image. > The released-image RSS rig is the one exception: it measures published images on purpose, so it pulls them. > See [`packages/cipherstash-proxy-burn-in/README.md`](packages/cipherstash-proxy-burn-in/README.md). @@ -467,7 +467,7 @@ To run them against a published image instead, set `PROXY_IMAGE`: PROXY_IMAGE=cipherstash/proxy:3.1.1 mise run test:integration ``` -`proxy:up` then pulls that image and tags it as `cipherstash/proxy:latest`, the image `tests/docker-compose.yml` runs, and skips the build. +`proxy:up` then pulls that image if it isn't already present locally, tags it as `cipherstash/proxy:latest`, the image `tests/docker-compose.yml` runs, and skips the build. The test clients still come from your checkout, so check out the release's tag to test it with its own tests. After a release is published, `release.yml` runs this suite against the new image in the `Smoke test published image` job. @@ -556,7 +556,7 @@ This project uses `docker compose` to manage containers and networking. The configuration for those containers is in `tests/docker-compose.yml`. -The proxy services in `tests/docker-compose.yml` use `pull_policy: never` to ensure Docker never pulls the released `cipherstash/proxy:latest` image from Docker Hub. The image must be built locally from source via `mise run proxy:up` (or `mise run build`). This guarantees integration tests always run against the current source code. +The proxy services in `tests/docker-compose.yml` use `pull_policy: never` to ensure Docker never pulls the released `cipherstash/proxy:latest` image from Docker Hub. The image is built locally from source via `mise run proxy:up` (or `mise run build`), so integration tests run against the current source code. With `PROXY_IMAGE` set, `proxy:up` pulls that published image and tags it as `cipherstash/proxy:latest` instead. The integration tests use the `proxy:up` and `proxy:down` commands documented above to run containers in different configurations. diff --git a/mise.toml b/mise.toml index ab5a6c568..4dccc3bbc 100644 --- a/mise.toml +++ b/mise.toml @@ -74,8 +74,9 @@ set -e if [ -n "${PROXY_IMAGE:-}" ]; then # Test a published image instead of building from source. # tests/docker-compose.yml never pulls, so tag the image as the one it runs. + # Pull only when missing: test:integration calls proxy:up many times. echo "Using published image: ${PROXY_IMAGE}" - docker pull --quiet "${PROXY_IMAGE}" + docker image inspect "${PROXY_IMAGE}" >/dev/null 2>&1 || docker pull --quiet "${PROXY_IMAGE}" docker tag "${PROXY_IMAGE}" cipherstash/proxy:latest else mise run build:binary --target {{target}}