Skip to content

refactor: Add nightly test stability workflow (aka The Gauntlet) - #343

Merged
greyscaled merged 20 commits into
mainfrom
bryphe/refactor/add-stability-workflow
Mar 19, 2022
Merged

greyscaled merged 20 commits into
mainfrom
bryphe/refactor/add-stability-workflow

Conversation

@bryphe-coder

Copy link
Copy Markdown
Contributor

@kylecarbs has done some awesome work to stamp out and fix intermittent failures to keep our CI stable, fast, and green.

This adds a nightly stability run - where we'll kick off a high-iteration run each night and report to datadog (with a stability- prefix) to keep an eye on any intermittencies that crop up.

@bryphe-coder bryphe-coder self-assigned this Feb 21, 2022
- name: Test with Mock Database
shell: bash
env:
GOCOUNT: 25

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Neato! I didn't know about this - thanks @jawnsy

Giving it a test run here: 5b867a1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Found out apparently those inputs don't get populated for pull requests (thread here: https://github.community/t/how-to-set-a-default-value-for-a-workflow-dispatch-variable/156961) - just for workflows, so added a default here too: a0c1800

@codecov

codecov Bot commented Feb 21, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #343 (3dd10a4) into main (22f820c) will increase coverage by 0.09%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #343      +/-   ##
==========================================
+ Coverage   67.98%   68.08%   +0.09%     
==========================================
  Files         164      164              
  Lines        9309     9309              
  Branches       85       85              
==========================================
+ Hits         6329     6338       +9     
+ Misses       2353     2344       -9     
  Partials      627      627              
Flag Coverage Δ
unittest-go-macos-latest 62.68% <ø> (+0.04%) ⬆️
unittest-go-ubuntu-latest 67.36% <ø> (-0.04%) ⬇️
unittest-go-windows-2022 62.24% <ø> (+0.08%) ⬆️
unittest-js 63.63% <ø> (ø)
Impacted Files Coverage Δ
peerbroker/dial.go 75.43% <0.00%> (-7.02%) ⬇️
peerbroker/listen.go 81.35% <0.00%> (-2.55%) ⬇️
peer/conn.go 80.05% <0.00%> (-0.26%) ⬇️
provisionerd/provisionerd.go 79.77% <0.00%> (+2.20%) ⬆️
provisioner/echo/serve.go 57.50% <0.00%> (+2.50%) ⬆️
codersdk/provisionerdaemons.go 61.53% <0.00%> (+3.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22f820c...3dd10a4. Read the comment docs.

runs-on: ${{ matrix.os }}
strategy:
matrix:
os:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you might want to consider adding another variable for a run number, so you can run multiple in parallel (e.g. instance: [1, 2] would let you run 2x each base OS, for a total of 6 runs happening in parallel). since this is happening in the background, the main cost is monetary, and running more instances in parallel will help surface flakes sooner

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, we can try it out. Since this is a nightly job, the performance isn't as important as for a PR gate - so it might be actually be OK to run them serially. Trying it out in: e5c4e18

@kylecarbs kylecarbs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Big fan! Gotta catch em' all

@bryphe-coder
bryphe-coder marked this pull request as ready for review February 23, 2022 05:16
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: fake
GIT_COMMIT_MESSAGE: stability-${{ github.event.head_commit.message }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could use a custom tag instead, that might be better!

It'll require minor edits to the DataDog script I wrote, but that should be simple enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, that sounds good - like maybe an additional trait we could send up?

"test.traits": fmt.Sprintf(`{"database":["%s"]}`, os.Getenv("DD_DATABASE")),

I also noticed we're sending up the workflow:

"ci.pipeline.name":   os.Getenv("GITHUB_WORKFLOW"),

That might be sufficient by itself to differentiate the stability run

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh ya, it looks like that is available to differentiate and filter these runs:
image

So I'll remove this superfluous stability- prefix then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in 14345df

@stale

stale Bot commented Mar 9, 2022

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no activity occurs in the next 5 days.

@stale stale Bot added the stale This issue is like stale bread. label Mar 9, 2022
@stale stale Bot closed this Mar 14, 2022
@bryphe-coder bryphe-coder reopened this Mar 14, 2022
@stale stale Bot removed the stale This issue is like stale bread. label Mar 14, 2022

pull_request:
branches:
# TODO: Remove before merge

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Remove this

@greyscaled
greyscaled enabled auto-merge (squash) March 19, 2022 23:05
@greyscaled
greyscaled merged commit 64d9d00 into main Mar 19, 2022
@greyscaled
greyscaled deleted the bryphe/refactor/add-stability-workflow branch March 19, 2022 23:07
deansheather added a commit that referenced this pull request Nov 16, 2026
…#32229)

> [!NOTE]
> Generated by Coder Agents on behalf of @deansheather.

Main builds and releases now build and sign through one shared composite
action, so they can't drift apart. PR builds use the same action
unsigned, in a job with no environment, so they can't reach signing
secrets or identities.

Depends on coder/gcp#343, which must merge first. The `release-signer`
identity provider only accepts tag-dispatched releases and `ci.yaml`.
Since #32211 made that login unconditional, releases and non-push main
runs already fail today.

## Changes

- **`.github/actions/build-coder` (new):** tool setup, then `make` for
the given targets. With `sign: true` it signs darwin binaries with the
Apple key in Cloud KMS, Windows binaries with EV, and everything with
GPG (the legacy key plus the optional KMS key). With `notarize: true` it
also notarizes. Composite actions can't read secrets, so callers pass
them in.
- Signing material goes in a `$RUNNER_TEMP/coder-signing` directory with
mode 700 and is removed with `if: always()`.
  - Signing builds disable the mise, pnpm and rcodesign caches.
- KMS signing no longer checks the event or ref. If the provider rejects
a run, the build fails loudly.
- **`.github/workflows/build.yaml` (new):** the signed main and
`release/*` build, moved out of `ci.yaml`.
- Triggers: `push` to `main` and `release/*` (ignoring the same
docs-only paths as `ci.yaml`'s `changes` filter), plus `create` for
`release/*`. No `pull_request` or `workflow_dispatch`. Top-level
`permissions: {}`.
- The `build` job runs in `ci-signing`. It builds and signs, pushes
`coder-preview` tags, then runs SBOM, image attestations and binary
attestations (new), and uploads artifacts.
- `prune` runs `action-ghcr-prune` in its own job, away from the signing
credentials.
- `deploy` calls `deploy.yaml`. `notify-slack-on-failure` covers build,
prune and deploy failures on main.
- **`ci.yaml`:**
  - The `build` and `deploy` jobs are removed.
- `check-build` now runs `make build-slim` through the action, unsigned.
That compile-checks all 7 OS/arch targets without the frontend and fat
builds.
  - `check-build` also runs when CI files change.
- **`release.yaml`:**
- Builds and signs through the action with `notarize: true`. Tagging,
base image, images, attestations and publishing are unchanged.
  - The `refs/tags/*` KMS gate is removed.
- The publish step now reads the `release-signer` credentials from the
action's output.
- **Hardening on top of #32211:**
- `install-rcodesign` gains a `use-cache` input, which signing jobs set
to `false`. Depot caches are shared across branches, so a PR could
otherwise plant a binary under the cache key that a signing job would
run with signing credentials.
- `cargo install --locked` pins rcodesign's dependency tree. I verified
the lockfile resolves with the patch at the pinned revision.
- `sign_darwin.sh` takes `AC_PKCS11_CREDENTIALS_FILE` and sets
`GOOGLE_APPLICATION_CREDENTIALS` only for `rcodesign`. The
`release-signer` credentials no longer reach the whole `make` step.
  - The jsign jar is now verified against a pinned sha256.

## Validation

- `make lint/actions/actionlint` passes. zizmor (offline, strict
collection) reports no findings. shellcheck passes on every `run` block
in the composite actions.
- I dry-ran the signing-material and target-parsing logic locally. The
kmsp11 config renders correctly and files are mode 600. Multi-line
targets parse correctly.
- Not run: a real signed build. The first main run after merge should
show `.asc` and `.v2.asc` files, rcodesign and jsign output,
`coder-preview:main` pushed and dogfood deployed. A release dry run from
`main` covers `release.yaml` once #56 lets the `release` environment run
on `main`; release branches still carry the old `release.yaml`.

## Follow-ups (manual)

- After the first successful signed main build and release, delete
`AC_CERTIFICATE_P12_BASE64` and `AC_CERTIFICATE_PASSWORD`.
- The Rust toolchain is still whatever `stable` the runner has.
Rebuilding rcodesign without the cache adds a few minutes to each signed
build.

The `release` environment changes and the release-branch `ci.yaml`
signing are handled in coder/github-org-terraform#56 and coder/gcp#343.

## Merge order (all 8 PRs)

coder/gcp applies on merge, so the order matters.

1. coder/github-org-terraform#56: the `code-signing` environments, tag
rulesets, and coder/coder `release` and `release-publish` allowing
`main`. This must be applied before an RC can be dispatched from `main`.
2. coder/gcp#343, then #32229 right after. Signed `ci.yaml`
builds on `main` fail between those two. `release/2.37` to `2.39` keep
signing through `ci.yaml` under #343's temporary rule until 2027-02-16.
3. coder/coder-desktop-windows#192, coder/mutagen#19, coder/pr-buddy#69
and coder/xum#8170.
4. coder/gcp#347. Windows signing in those 4 repos breaks if this lands
before step 3.

<details>
<summary>Plan and decision log</summary>

**Goal:** main and `release/*` pushes build coderd fully, sign
everything (EV, Apple, GPG and KMS GPG) the same way releases do, push
`coder-preview`, and deploy dogfood. PRs get a compile check with no
signing access.

**Verified constraints:**

- Signing secrets exist only in the `ci-signing` and `release`
environments. There are none at the repo or org level.
- `ci-signing` allows `main` and `release/*`. `release` requires
`release-managers` with self-review prevented, and admins can't bypass.
- `ev-code-signing` (coder-ci) and `release-signer`
(coder-release-signing) are bound only to the `environment:ci-signing`
and `environment:release` subjects.
- The `release-signer` provider condition checks `job_workflow_ref`. A
reusable workflow would change that claim, so the shared code is a
composite action that runs inside the caller's job. This also keeps the
release job as a single job, with no artifact handoff between build and
publish.

**Decisions:**

- The new workflow is named `build.yaml`.
- There is no cutover period, so the provider names only `build.yaml`.
- Main builds are signed identically to releases. Only notarization and
publishing differ, because main doesn't build darwin archives.
- `release/*` still gets `coder-preview:release-X.Y` images.
- PR `check-build` builds slim binaries only, which keeps the
cross-compile coverage at a fraction of the cost.

</details>
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.

4 participants