Skip to content

test: cloudflare artifacts roundtrip smoketest#4

Merged
ivarvong merged 3 commits into
mainfrom
cloudflare-artifacts-smoketest
May 6, 2026
Merged

test: cloudflare artifacts roundtrip smoketest#4
ivarvong merged 3 commits into
mainfrom
cloudflare-artifacts-smoketest

Conversation

@ivarvong
Copy link
Copy Markdown
Owner

@ivarvong ivarvong commented May 4, 2026

Summary

  • Realigns the Exgit.Test.CloudflareArtifacts adapter with the documented REST API: create_repo!/2 now returns the bootstrap {remote, token, ...}, mint_token!create_token!/3 (mirrors upstream naming, hits the correct POST /tokens endpoint, parses result.plaintext), adds revoke_token!/1.
  • Adds a live smoketest tagged :cloudflare that pushes a random blob via Exgit.push, verifies it two ways, then deletes the repo.
  • Documents the actual API token permissions (Artifacts Read + Artifacts Write).

What the smoketest proves

  1. exgit ↔ exgit — push then lazy-clone the same URL; assert blob bytes and ref SHA match what we computed locally. Catches transport / parser bugs in our code.
  2. exgit ↔ real git (:real_git) — push then git clone with the real binary plus git fsck --full. Proves Cloudflare stores valid git that a third-party client can read, not exgit-flavoured bytes.

Test plan

  • mix test --include cloudflare --include real_git test/exgit/cloudflare_artifacts_roundtrip_test.exs — 2 tests, 0 failures.
  • mix test --warnings-as-errors (default suite) — 729 tests, 0 failures.
  • mix format, mix compile --warnings-as-errors, MIX_ENV=dev mix credo --strict — all clean.
  • CI primary (Dialyzer + extended tiers).

🤖 Generated with Claude Code

ivarvong and others added 3 commits May 4, 2026 10:08
Realigns the Artifacts test-support adapter with the documented REST
API and adds a live smoketest tagged `:cloudflare`.

Adapter (`test/support/cloudflare_artifacts.ex`):
- `create_repo!/2` now returns the bootstrap `{remote, token, ...}`
  the API hands back, instead of throwing it away.
- `mint_token!` → `create_token!/3` to mirror upstream naming, fixed
  to `POST /tokens` (the previous `/repos/:name/tokens` 404'd) and to
  parse `result.plaintext` rather than `result.token`.
- Adds `revoke_token!/1`.
- Documents the required permissions: `Artifacts Read` + `Artifacts Write`.

Smoketest (`test/exgit/cloudflare_artifacts_roundtrip_test.exs`):
- Test 1: exgit push → exgit lazy-clone → byte equality. Proves our
  transport round-trips random content.
- Test 2 (`:real_git`): exgit push → real `git clone` + `git fsck`.
  Proves Cloudflare stores valid git, readable by a third-party client.

Both tests opt-in via `mix test --include cloudflare`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drops the REST control plane (create_repo / delete_repo) from the
test-support adapter. The smoketest now runs against a persistent
repo, with both the wire URL and token injected via env:

  * CF_ARTIFACT_REMOTE — full git wire URL
  * CF_ARTIFACT_TOKEN  — long-lived repo-scoped token (art_v1_)

Both are loaded from .env locally and from CI secrets. Hardcoding
neither the URL (account ID) nor the token in source.

Each test still uses a unique branch name to avoid stomping across
runs against the shared repo.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two fixes for the live-network cloudflare smoketest:

1. Drop `:real_git` from the second test. ExUnit's tag logic treats
   include as overriding exclude, so `mix test --include real_git`
   (used by the extended-tiers step) was pulling in the cloudflare
   test even though `:cloudflare` is on the default exclude list.
   The test then immediately raised "CF_ARTIFACT_REMOTE not set"
   because no secrets were injected into that step. The `:cloudflare`
   module tag is a sufficient gate; opting in implies `git` on PATH.

2. Add a dedicated CI step that runs `mix test --only cloudflare`
   with `CF_ARTIFACT_REMOTE` and `CF_ARTIFACT_TOKEN` injected from
   secrets. Gated push-to-main + primary matrix only, mirroring how
   `:github_private` is handled — these secrets aren't available on
   fork PRs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ivarvong ivarvong merged commit 9fb3425 into main May 6, 2026
2 checks passed
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.

1 participant