Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ jobs:
- build
env:
publish: ${{contains(fromJSON('["push", "release"]'), github.event_name)}}
outputs:
version: ${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -204,3 +206,18 @@ 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:
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 }}
91 changes: 91 additions & 0 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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 2.2.x image.
on:
workflow_call:
inputs:
version:
description: Published image version to test, such as 2.2.7
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:
- release/**
paths:
- '.github/workflows/smoke-test.yml'

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
smoke-test:
name: Smoke test cipherstash/proxy:${{ inputs.version || '2.2' }} (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 || '2.2' }}
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@v4
- 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

# 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 }}
15 changes: 13 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,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.

### Building

Expand Down Expand Up @@ -400,6 +400,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:2.2.7 mise run test:integration
```

`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.

The integration tests have several runtime dependencies:

- Running PostgreSQL instances (that can be started with `mise run postgres:up`)
Expand Down Expand Up @@ -463,7 +474,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.

Expand Down
17 changes: 13 additions & 4 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,20 @@ set -e
{% set target = arch() ~ "-unknown-linux-gnu" | replace(from="arm64", to="aarch64") | replace(from="x64", to="x86_64") %}
{% set docker_platform = "linux/" ~ arch() | replace(from="x64", to="amd64") %}

# build a binary
mise run build:binary --target {{target}}
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 image inspect "${PROXY_IMAGE}" >/dev/null 2>&1 || docker pull --quiet "${PROXY_IMAGE}"
docker tag "${PROXY_IMAGE}" cipherstash/proxy:latest
else
# build a binary
mise run build:binary --target {{target}}

# build a new container
mise run build:docker --platform {{docker_platform}}
# build a new container
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.
Expand Down
8 changes: 4 additions & 4 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading