Skip to content

Commit ae8f6cb

Browse files
committed
Website: Add docker build check
To avoid the mistake that happened earlier
1 parent acfef93 commit ae8f6cb

4 files changed

Lines changed: 44 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Run the smallest set of checks possible for efficiency while maintaining confide
5353
|cargo-audit|cargo-deny|cargo-udeps|jscpd-rust|cfg-gate|rust-tests|rust-tests-linux (slow)|license-server-prettier
5454
|license-server-eslint|license-server-typecheck|license-server-tests|gofmt|go-vet|staticcheck|ineffassign|misspell
5555
|gocyclo|nilaway|govulncheck|deadcode|go-tests|website-prettier|website-eslint|website-typecheck|website-build
56-
|website-e2e|pnpm-audit|file-length}` (can use multiple `--check` flags or even a comma-separated list)
56+
|website-e2e|docker-build|pnpm-audit|file-length}` (can use multiple `--check` flags or even a comma-separated list)
5757
- Run all: `./scripts/check.sh`. Runs all tests, linters, and formatters (with auto fixing) for all apps.
5858
- **E2E testing**: Full guide on Docker E2E, Playwright smoke tests, VNC debugging, fixture system:
5959
[docs/tooling/e2e-testing-guide.md](docs/tooling/e2e-testing-guide.md)

scripts/check/CLAUDE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,24 @@ check name, duration, result (pass/fail/skip/blocked), and optional counts (tota
8181
`CheckResult` has `Total`, `Issues`, `Changes` fields (`-1` = N/A, rendered as `N/A` in CSV).
8282
Disabled by `--no-log` or `--ci`. Implementation in `stats.go`.
8383

84+
## Adding a new check
85+
86+
1. Create `checks/{app}-{name}.go` with a `func RunSomething(ctx *CheckContext) (CheckResult, error)`.
87+
Use `website-build.go` or `website-docker.go` as templates — they're the simplest.
88+
2. Register it in `AllChecks` in `registry.go` (ID, App, Tech, DependsOn, Run).
89+
3. Return `Success("message")` on pass, `fmt.Errorf(...)` on fail, `Skipped("reason")` to skip.
90+
4. Add a test file if the check has non-trivial logic (`checks/{app}-{name}_test.go`).
91+
5. Run `./scripts/check.sh --go` to verify (staticcheck is strict about idiomatic Go).
92+
6. Update the table below and `AGENTS.md`'s `--check` list.
93+
8494
## Apps and check counts
8595

8696
| App | Tech | Checks |
8797
|-----|------|--------|
8898
| Desktop | Rust | rustfmt, clippy, cargo-audit, cargo-deny, cargo-udeps, jscpd, tests, tests-linux (slow) |
8999
| Desktop | Svelte | prettier, eslint, stylelint, css-unused, svelte-check, knip, type-drift, tests, smoke, e2e-linux-typecheck, e2e-linux (slow) |
90100
| Website | Astro | prettier, eslint, typecheck, build, e2e |
101+
| Website | Docker | docker-build |
91102
| License server | TS | prettier, eslint, typecheck, tests |
92103
| Scripts | Go | gofmt, go-vet, staticcheck, ineffassign, misspell, gocyclo, nilaway, govulncheck, deadcode, go-tests |
93104
| Other | pnpm | pnpm-audit |

scripts/check/checks/registry.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,15 @@ var AllChecks = []CheckDefinition{
214214
DependsOn: []string{"website-eslint"},
215215
Run: RunWebsiteTypecheck,
216216
},
217+
{
218+
ID: "website-docker-build",
219+
Nickname: "docker-build",
220+
DisplayName: "docker build",
221+
App: AppWebsite,
222+
Tech: "🐳 Docker",
223+
DependsOn: nil,
224+
Run: RunWebsiteDockerBuild,
225+
},
217226
{
218227
ID: "website-build",
219228
DisplayName: "build",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package checks
2+
3+
import (
4+
"fmt"
5+
"os/exec"
6+
)
7+
8+
// RunWebsiteDockerBuild runs the full Docker build for the website.
9+
// Catches .dockerignore mismatches, missing COPY sources, pnpm install failures,
10+
// and Astro build errors in the container context — anything that would break the deploy.
11+
func RunWebsiteDockerBuild(ctx *CheckContext) (CheckResult, error) {
12+
if !CommandExists("docker") {
13+
return Skipped("docker not installed"), nil
14+
}
15+
16+
cmd := exec.Command("docker", "build", "-f", "apps/website/Dockerfile", "-t", "getcmdr-check", ".")
17+
cmd.Dir = ctx.RootDir
18+
output, err := RunCommand(cmd, true)
19+
if err != nil {
20+
return CheckResult{}, fmt.Errorf("docker build failed\n%s", indentOutput(output))
21+
}
22+
return Success("Docker build passed"), nil
23+
}

0 commit comments

Comments
 (0)