Skip to content

Replace shell smoke test with Go integration tests#26

Open
swalkinshaw wants to merge 2 commits intomainfrom
test-improvements
Open

Replace shell smoke test with Go integration tests#26
swalkinshaw wants to merge 2 commits intomainfrom
test-improvements

Conversation

@swalkinshaw
Copy link
Member

Replaces the 480-line bash smoke test with Go integration tests that are deterministic, fast, and self-contained. The new test infrastructure uses fixture data and a mock wp.org server so tests run without network dependencies on the WordPress.org API.

New files:

  • Mock wp.org server (internal/wporg/mock_server.go) + API fixtures
  • Test DB helpers (internal/testutil/testdb.go) for in-memory SQLite
  • Integration smoke test covering full pipeline, HTTP endpoints, composer install, version pinning, and build integrity
  • R2 sync test using gofakes3 for S3-compat verification
  • Live canary test for nightly runs against real wp.org
  • Fixture capture script (test/capture-fixtures.sh)
  • Canary CI workflow (.github/workflows/canary.yml)

Changes:

  • wporg.Client now supports configurable base URL via SetBaseURL()
  • S3 client uses path-style addressing (needed for R2 + test compat)
  • CI workflow gains integration test job (stub CSS, no Tailwind needed)
  • Makefile: smoke target replaced with integration target

Deleted: test/smoke_test.sh, .github/workflows/smoke-test.yml

@swalkinshaw swalkinshaw requested a review from retlehs March 18, 2026 03:42
}
}

func runComposer(t *testing.T, composerPath, dir string, args ...string) string {
Copy link
Member

@tangrufus tangrufus Mar 18, 2026

Choose a reason for hiding this comment

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

How about using https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript ?

We can test it against multiple composer versions via docker images.
Also open up the possibility to run e2e test against production server.

Examples:

Copy link
Member Author

Choose a reason for hiding this comment

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

Using docker for multiple versions is definitely better 👍 think I'll defer as a follow-up though

swalkinshaw and others added 2 commits March 17, 2026 23:34
Replaces the 480-line bash smoke test with Go integration tests that are
deterministic, fast, and self-contained. The new test infrastructure uses
fixture data and a mock wp.org server so tests run without network
dependencies on the WordPress.org API.

New files:
- Mock wp.org server (internal/wporg/mock_server.go) + API fixtures
- Test DB helpers (internal/testutil/testdb.go) for in-memory SQLite
- Integration smoke test covering full pipeline, HTTP endpoints,
  composer install, version pinning, and build integrity
- R2 sync test using gofakes3 for S3-compat verification
- Live canary test for nightly runs against real wp.org
- Fixture capture script (test/capture-fixtures.sh)
- Canary CI workflow (.github/workflows/canary.yml)

Changes:
- wporg.Client now supports configurable base URL via SetBaseURL()
- S3 client uses path-style addressing (needed for R2 + test compat)
- CI workflow gains integration test job (stub CSS, no Tailwind needed)
- Makefile: smoke target replaced with integration target

Deleted: test/smoke_test.sh, .github/workflows/smoke-test.yml

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The httptest server uses plain HTTP (http://127.0.0.1:...) which
Composer's secure-http default blocks. Add secure-http: false to the
generated composer.json config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@retlehs
Copy link
Member

retlehs commented Mar 18, 2026

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 98c0588250

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- name: Create stub CSS for embed
run: touch internal/http/static/assets/styles/app.css
- name: Live Canary Test
run: go test -tags=wporg_live -count=1 -timeout=5m -v ./internal/integration/...

Choose a reason for hiding this comment

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

P2 Badge Reinstate a canary that hits the deployed repository

The scheduled canary now only runs go test -tags=wporg_live, but TestWpOrgLive serves Composer metadata from an in-process httptest.Server and installs from repoServer.URL rather than https://repo.wp-composer.com. Because this commit also deletes .github/workflows/smoke-test.yml, a broken production deploy of the public repository, CDN, or /downloads endpoint would no longer trip any scheduled check; the canary will stay green as long as the local build still works.

Useful? React with 👍 / 👎.

Comment on lines +60 to +63
cfg := &config.Config{
AppURL: "http://test.local",
Env: "test",
}

Choose a reason for hiding this comment

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

P2 Badge Point the smoke install at the same host as notify-batch

repository.Build bakes notify-batch from AppURL (internal/repository/builder.go:261-268), so setting AppURL to http://test.local here while the Composer project is later pointed at repoServer.URL means the install never exercises the app server's /downloads handler. The old shell smoke test asserted install events; after this change CI can pass even if notify-batch generation or download ingestion regresses, which removes coverage for one of the repo's core production metrics.

Useful? React with 👍 / 👎.

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.

3 participants