Skip to content

Resolve environment alternate IDs before static builds - #285

Merged
nathanyoung merged 3 commits into
mainfrom
fix/static-build-environment-alias
Oct 3, 2026
Merged

nathanyoung merged 3 commits into
mainfrom
fix/static-build-environment-alias

Conversation

@nathanyoung

@nathanyoung nathanyoung commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Resolve environment alternate IDs before static builds

Summary

  • Resolve an explicit static-build environment within the configured project before uploading files. hx build --env development --type static ./dist now sends the canonical environment ID required by the existing upload API.
  • Use the same resolved ID when registering the build; leave builds without --env available to all environments.
  • Stop before uploading if environment lookup fails, and clarify the --env help text.
  • Add coverage for alternate IDs, canonical IDs, unscoped builds, lookup failures, and the static deploy flow.

Corresponding app instructions: https://github.com/Hyphen/hyphen-app/pull/1636

Validation

  • Build and deploy package tests passed, including the upload and registration flow.
  • go test -race ./internal/build ./cmd/build ./cmd/deploy passed after synchronizing the captured-request assertions.
  • All command, internal, and utility packages passed in go test ./....
  • Two pre-existing unauthenticated acceptance cases fail locally because they inherit saved credentials. Restricting access to the global .hx confirms the exit-code behavior but produces a file-permission error rather than the expected missing-credentials message. Credentials were not modified.
  • gofmt and git diff --check passed.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces environment resolution for static builds, allowing the use of either an environment ID or an alternate ID, and updates the CLI flag description and tests accordingly. A critical feedback item identifies a data race in the newly added TestStaticBuildEnvironmentFailureStopsBeforeUploading test, where the requests slice is accessed concurrently without synchronization, and suggests protecting it with a sync.Mutex.

Comment thread internal/build/static_test.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation consistently uses canonical IDs, fails before upload, preserves unscoped behavior, and includes comprehensive coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Resolves static-build environment aliases to canonical IDs before upload and registration.

Changes:

  • Adds environment resolution and early failure handling.
  • Preserves unscoped builds for all environments.
  • Expands static build and deploy-flow tests and clarifies CLI help.
File Description
internal/​build/​static.go Adds environment lookup.
internal/​build/​service.go Resolves static-build environments before upload.
internal/​build/​static_test.go Tests resolution and failure behavior.
cmd/​deploy/​static_flow_test.go Updates static deployment integration coverage.
cmd/​build/​build.go Clarifies --env help text.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to resolve environment IDs or alternate IDs for static builds. It adds a new resolveSiteEnvironment method to the BuildService to fetch and resolve the environment ID from the API before proceeding with the build. Additionally, it updates the --env flag description, adds comprehensive unit tests for various environment resolution scenarios, and includes error handling tests for when environment resolution fails. There are no review comments, and I have no feedback to provide.

@nathanyoung
nathanyoung requested a review from Terryda October 3, 2026 19:26
Comment thread internal/build/service.go Outdated
This change resolves project environment IDs for all build types, not just static builds. A shared environment lookup helper now handles environment validation before build execution, and the related tests cover both static and docker flows for failure cases such as missing environments, forbidden access, malformed responses, and missing IDs.
@nathanyoung
nathanyoung merged commit d481141 into main Oct 3, 2026
6 checks passed
@nathanyoung
nathanyoung deleted the fix/static-build-environment-alias branch October 3, 2026 20:36
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