Skip to content

Commit 44af32c

Browse files
committed
ci: stop broken changes from merging green
Clippy denies todo!, unimplemented! and, outside tests, panic! and dbg!. cargo-deny also rejects `*` requirements and sources other than crates.io, across every feature. A new infra job validates the piqueld manifests with piquelctl and the telemetry configs with the images that run them. The rust filter now covers the files Rust reads outside the crates.
1 parent 1019072 commit 44af32c

10 files changed

Lines changed: 99 additions & 21 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# web server on its own host, Mailpit receiving auth's email, and
1515
# the binary's CLI granting administrators and recovering accounts
1616
# docker -> the deployment images: auth, sourceorigin.dev's web server and the docs
17+
# infra -> the piqueld manifests, by piquelctl, and the telemetry configs,
18+
# each by the image that runs it
1719
# docs -> the documentation book, built with warnings denied, with every
1820
# link and heading anchor in it and in the repository's Markdown
1921
# checked offline
@@ -59,18 +61,22 @@ jobs:
5961
# matches a filter only when it matches every pattern. `web` covers every
6062
# file Prettier, ESLint or tsc can see, so it excludes file types rather than
6163
# directories. `app` covers everything the running service and its images
62-
# are built from, and the TypeScript SDK the browser suite also runs.
64+
# are built from, and the TypeScript SDK the browser suite also runs. Rust
65+
# also reads files outside the crates: the committed audit verifier keys,
66+
# which auth compiles in, and the generated reference pages its tests compare
67+
# with the code, which `reference` matches since `rust` skips Markdown.
6368
changes:
6469
name: changes
6570
runs-on: ubuntu-latest
6671
timeout-minutes: 5
6772
permissions:
6873
pull-requests: read
6974
outputs:
70-
rust: ${{ github.event_name != 'pull_request' || steps.filter.outputs.rust == 'true' }}
75+
rust: ${{ github.event_name != 'pull_request' || steps.filter.outputs.rust == 'true' || steps.filter.outputs.reference == 'true' }}
7176
web: ${{ github.event_name != 'pull_request' || steps.filter.outputs.web == 'true' }}
7277
deps: ${{ github.event_name != 'pull_request' || steps.filter.outputs.deps == 'true' }}
7378
app: ${{ github.event_name != 'pull_request' || steps.filter.outputs.app == 'true' }}
79+
infra: ${{ github.event_name != 'pull_request' || steps.filter.outputs.infra == 'true' }}
7480
steps:
7581
- if: github.event_name == 'pull_request'
7682
id: filter
@@ -79,8 +85,10 @@ jobs:
7985
predicate-quantifier: every
8086
filters: |
8187
rust:
82-
- '{Cargo.toml,Cargo.lock,rust-toolchain.toml,justfile,just/**,apps/**,crates/**,tests/sdk-vectors/**,packages/auth/src/protocol.ts,.github/workflows/ci.yml}'
88+
- '{Cargo.toml,Cargo.lock,rust-toolchain.toml,clippy.toml,.cargo/**,justfile,just/**,apps/**,crates/**,tests/sdk-vectors/**,packages/auth/src/protocol.ts,docs/dev/security/audit-key.pub,.github/workflows/ci.yml}'
8389
- '!**/*.md'
90+
reference:
91+
- 'docs/dev/operations/{cli-commands,variables/*}.md'
8492
web:
8593
- '**'
8694
- '!**/*.{rs,sql,toml,md}'
@@ -90,9 +98,11 @@ jobs:
9098
deps:
9199
- '{Cargo.toml,**/Cargo.toml,Cargo.lock,deny.toml,package.json,**/package.json,pnpm-lock.yaml,pnpm-workspace.yaml,.github/workflows/ci.yml}'
92100
app:
93-
- '{Cargo.toml,Cargo.lock,rust-toolchain.toml,justfile,just/**,package.json,pnpm-lock.yaml,playwright.config.ts,apps/**,crates/**,packages/auth/**,tests/browser/**,infra/**,.dockerignore,.github/workflows/ci.yml}'
101+
- '{Cargo.toml,Cargo.lock,rust-toolchain.toml,.cargo/**,justfile,just/**,package.json,pnpm-lock.yaml,playwright.config.ts,apps/**,crates/**,packages/auth/**,tests/browser/**,infra/**,docs/dev/security/audit-key.pub,.dockerignore,.github/workflows/ci.yml}'
94102
- '!**/*.md'
95103
- '!infra/piqueld.toml'
104+
infra:
105+
- '{infra/piqueld.toml,infra/telemetry.toml,infra/telemetry/*.yaml,just/infra.just,.github/workflows/ci.yml}'
96106
97107
checks:
98108
name: checks
@@ -319,6 +329,22 @@ jobs:
319329
- run: docker build --file infra/web.Dockerfile .
320330
- run: docker build --file infra/docs.Dockerfile .
321331

332+
# piquelctl publishes no prebuilt binaries either. rust-cache keeps it as it
333+
# keeps sqlx-cli in `rust`, and `cargo install` upgrades it when a newer
334+
# release is out. Docker pulls each telemetry image.
335+
infra:
336+
name: infra
337+
needs: changes
338+
if: needs.changes.outputs.infra == 'true'
339+
runs-on: ubuntu-latest
340+
timeout-minutes: 20
341+
steps:
342+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
343+
- *install-just
344+
- *rust-cache
345+
- run: cargo install --locked piquelctl
346+
- run: just infra check
347+
322348
# mdBook and lychee at the versions `just install-tools` installs.
323349
docs:
324350
name: docs
@@ -341,11 +367,12 @@ jobs:
341367
- rust
342368
- e2e
343369
- docker
370+
- infra
344371
- docs
345372
runs-on: ubuntu-latest
346373
timeout-minutes: 5
347374
steps:
348375
- uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # v1.3.0
349376
with:
350-
allowed-skips: checks, web, rust, e2e, docker
377+
allowed-skips: checks, web, rust, e2e, docker, infra
351378
jobs: ${{ toJSON(needs) }}

‎Cargo.toml‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,26 @@ missing_docs = "warn"
2929
all = { level = "warn", priority = -1 }
3030
pedantic = { level = "warn", priority = -1 }
3131
unwrap_used = "warn"
32-
# Tests may expect (see clippy.toml); production code propagates errors.
32+
# Tests may expect, panic and dbg (see clippy.toml); production code
33+
# propagates errors and logs through tracing.
3334
expect_used = "warn"
35+
panic = "warn"
36+
todo = "warn"
37+
unimplemented = "warn"
38+
dbg_macro = "warn"
3439
# Modules with children live in `foo/mod.rs`, never a `foo.rs` beside `foo/`.
3540
self_named_module_files = "warn"
3641

3742
[workspace.dependencies]
38-
# Local crates
39-
sourceorigin-common = { path = "crates/common" }
40-
sourceorigin-crypto = { path = "crates/crypto" }
41-
sourceorigin-repository = { path = "crates/database" }
42-
sourceorigin-telemetry = { path = "crates/telemetry" }
43-
sourceorigin-auth = { path = "crates/auth-sdk" }
44-
sourceorigin-ui = { path = "crates/ui" }
43+
# Local crates. Each names the workspace's version: cargo-deny (deny.toml)
44+
# denies a dependency with no version as a wildcard, and crates.io would refuse
45+
# to publish the SDK without one.
46+
sourceorigin-common = { version = "0.1.0", path = "crates/common" }
47+
sourceorigin-crypto = { version = "0.1.0", path = "crates/crypto" }
48+
sourceorigin-repository = { version = "0.1.0", path = "crates/database" }
49+
sourceorigin-telemetry = { version = "0.1.0", path = "crates/telemetry" }
50+
sourceorigin-auth = { version = "0.1.0", path = "crates/auth-sdk" }
51+
sourceorigin-ui = { version = "0.1.0", path = "crates/ui" }
4552

4653
# External crates
4754
async-trait = "0.1"

‎clippy.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# `expect_used` holds for production code only; tests may panic on failure.
1+
# `expect_used`, `panic` and `dbg_macro` hold for production code only; tests
2+
# may panic on failure and print what they inspect.
23
allow-expect-in-tests = true
4+
allow-panic-in-tests = true
5+
allow-dbg-in-tests = true
36

47
# The project's name is a word in prose, not code. `..` keeps Clippy's defaults.
58
doc-valid-idents = ["SourceOrigin", ".."]

‎deny.toml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,16 @@ exceptions = [
1919
{ crate = "sourceorigin-telemetry", allow = ["PolyForm-Noncommercial-1.0.0"] },
2020
{ crate = "sourceorigin-ui", allow = ["PolyForm-Noncommercial-1.0.0"] },
2121
]
22+
23+
[bans]
24+
# A `*` requirement accepts any future release, breaking or malicious.
25+
# Workspace crates name their version (Cargo.toml) so they don't count as one.
26+
wildcards = "deny"
27+
# Duplicates come from dependencies' own requirements, which this workspace
28+
# can't change; warning about them would only bury real failures.
29+
multiple-versions = "allow"
30+
31+
# Crates come from crates.io only: never another registry or a Git repository.
32+
[sources]
33+
unknown-registry = "deny"
34+
unknown-git = "deny"

‎docs/dev/operations/deploying.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ The manifest declares both environments and where each deploys from: staging
5555
follows pushes to `main` (`sync = true`), and production receives releases
5656
promoted from staging (`promote_from = "staging"`). Saving the manifest creates
5757
them, and every later push to `main` keeps them in line with it. Change them in
58-
the manifest, never with `piquelctl env create`, `env source` or `env sync`.
58+
the manifest, never with `piquelctl env create`, `env source` or `env sync`. CI
59+
validates every change to it with `piquelctl app validate`, and
60+
`just infra check` runs the same check locally.
5961

6062
To set them up on a new daemon, once the manifest is on `main`:
6163

‎docs/dev/operations/telemetry.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ This runs Grafana's all-in-one OpenTelemetry backend, with both dashboards, at
112112
| `loki` | `grafana/loki` | Logs, received over OTLP, kept 30 days |
113113
| `grafana` | `grafana/grafana` | Dashboards at `grafana.sourceorigin.dev` |
114114

115-
Their configuration is in `infra/telemetry/`, mounted as piqueld files.
115+
Their configuration is in `infra/telemetry/`, mounted as piqueld files. CI checks
116+
the collector's, Prometheus's, Loki's and Tempo's with their own validators, in
117+
the images `infra/telemetry.toml` runs, and so does `just infra check`.
116118

117119
## Dashboards
118120

‎docs/dev/rust-conventions.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ Return explicit `thiserror` errors. Preserve sources with `#[source]` or `#[from
299299
use `?` when a conversion already exists. Do not use `Result<_, ()>` or production
300300
`expect`, `unwrap` or `panic!`. Drop a source only when it contains a secret or
301301
can quote personal data, and explain that exception in the code. Gate test helpers with `#[cfg(test)]`.
302+
Clippy enforces this: it denies `unwrap`, `todo!` and `unimplemented!`
303+
everywhere, and `expect`, `panic!` and `dbg!` outside tests (`clippy.toml`).
302304

303305
Helpers return the feature's domain error. Browser handlers return `ApiError`
304306
through `From<DomainError>`; that exhaustive mapping owns public statuses and

‎docs/dev/testing.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ expressions included.
148148
| Any command against a scratch cluster | `just db scratch -- psql` |
149149
| Browser tests, against a running deployment | `just web test-browser` |
150150
| Register the browser tests' clients with auth on `localhost` | `just web browser-client` |
151-
| Dependency audits (cargo-deny and pnpm) | `just audit` (`just rust audit` / `just web audit`) |
151+
| Dependency audits: cargo-deny's advisories, licenses, `*` requirements and sources other than crates.io, and pnpm's | `just audit` (`just rust audit` / `just web audit`) |
152+
| Validate the piqueld manifests with piquelctl, and the telemetry configs with the images that run them (needs Docker) | `just infra check` |
152153
| Regenerate the query cache, the SDK vectors, the TypeScript SDK's wire types, or the generated documentation | `just db prepare` / `just sdk-vectors` / `just sdk-types` / `just docs reference` |
153154
| Build the book and check its links | `just docs` |
154155

@@ -163,12 +164,15 @@ CI runs the same recipes, in these jobs:
163164
| `rust` | `just rust lint`, `just coverage` against a PostgreSQL 18 service, `just db prepare-check`, `just doc` and `just doc-test` |
164165
| `e2e` | The browser suite, against the debug binary behind Caddy, with Mailpit receiving auth's email and sourceorigin.dev's web server on its own host |
165166
| `docker` | Builds the auth, web and docs images |
167+
| `infra` | `just infra check`, with the latest piquelctl |
166168
| `docs` | `just docs` |
167169

168170
A pull request runs only the jobs its changes can affect, by the paths it changes:
169-
Rust jobs for Rust code, the web job for files Prettier, ESLint or tsc can see,
170-
and `e2e` and `docker` for anything the service, its images, the TypeScript SDK
171-
or the browser suite is built from. Changes to Markdown alone run only `docs`, which runs on every
171+
Rust jobs for Rust code and the files it reads, such as the committed audit keys
172+
and the generated reference pages, the web job for files Prettier, ESLint or tsc
173+
can see, `e2e` and `docker` for anything the service, its images, the TypeScript
174+
SDK or the browser suite is built from, and `infra` for the manifests and the
175+
telemetry configs. Other Markdown changes run only `docs`, which runs on every
172176
pull request, since a change anywhere can break a link to it. The `changes` job
173177
in [ci.yml](https://github.com/sourceorigin-dev/sourceorigin/blob/main/.github/workflows/ci.yml)
174178
has the exact filters.

‎just/infra.just‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ preview *args:
1010
preview-delete *args:
1111
piquelctl --timeout 5m preview delete sourceorigin "$(git branch --show-current)" {{ args }} --yes
1212

13+
# Each telemetry config is checked by the image infra/telemetry.toml runs it
14+
# with, so by the version that will read it. Needs piquelctl and Docker.
15+
# Validate the piqueld manifests and the telemetry configs.
16+
check:
17+
#!/usr/bin/env bash
18+
set -euo pipefail
19+
piquelctl app validate --file infra/piqueld.toml
20+
piquelctl app validate --file infra/telemetry.toml
21+
image() { grep -o "image = \"$1:[^\"]*\"" infra/telemetry.toml | cut -d '"' -f 2; }
22+
run() { docker run --rm --volume "$PWD/infra/telemetry:/etc/telemetry:ro" "$@"; }
23+
run "$(image otel/opentelemetry-collector-contrib)" validate --config=/etc/telemetry/collector.yaml
24+
run --entrypoint promtool "$(image prom/prometheus)" check config /etc/telemetry/prometheus.yaml
25+
run "$(image grafana/loki)" -config.file=/etc/telemetry/loki.yaml -verify-config
26+
run "$(image grafana/tempo)" -config.file=/etc/telemetry/tempo.yaml -config.verify=true
27+
1328
# Point auth at it with OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 and
1429
# OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=local.
1530
# Grafana's all-in-one OpenTelemetry backend, with the SourceOrigin dashboards, at http://localhost:3000.

‎just/rust.just‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ lint:
2424
unused:
2525
@cargo machete
2626

27+
# Advisories, licenses, wildcard requirements and sources other than crates.io,
28+
# as deny.toml configures them. Every feature is on, so the audit covers what
29+
# the SDKs' features pull in even when no workspace crate enables them.
2730
audit:
28-
@cargo deny check advisories licenses
31+
@cargo deny --all-features check
2932

3033
# Build auth-service and sourceorigin-web; pass `--release` for release.
3134
[positional-arguments]

0 commit comments

Comments
 (0)