Skip to content

Etsy upstream sync#12

Open
shraykay wants to merge 8 commits intomainfrom
etsy-upstream-sync
Open

Etsy upstream sync#12
shraykay wants to merge 8 commits intomainfrom
etsy-upstream-sync

Conversation

@shraykay
Copy link

Bring all Etsy-specific customizations onto the latest upstream/main, which includes Bazel 8 upgrade, bazel_flag support, .diff target, RUNFILES_DIR fix, protobuf migration, and release prep.

Etsy changes ported:

  • GitHub App support (github_app package, CreateCommit/CreatePR)
  • go-github v32 → v68, added ghinstallation/v2
  • Buildkite CI integration (env vars, branch naming)
  • Optional namespace in k8s/kustomize rules
  • respect_resource_namespace parameter
  • app_name for gitops directory structure
  • Image resolver enhancements (resolveImageName, updateContainerEnv)
  • push_oci external image fix
  • Deploy GitHub Actions workflow

Upstream features preserved:

  • deploy_branch_prefix configurability
  • bazel_flag passthrough
  • BazelCmd usage in cquery
  • CloneOrCheckout with branch prefix
  • "${@}" argument passthrough in template
  • google.golang.org/protobuf (not golang/protobuf)
  • errgroup for parallel push

ptxmac and others added 8 commits February 9, 2025 11:46
[docs] Fix broken links in README.md
* upgrade modules

* no vendor

* update tests

* update e2e

* go mod tidy

* bump go

* update k8s client

* canonical bcr name for rules_go and gazelle

* upgrade protobuf

* fix e2e

* cleanup

* upgrade k8s client
Signed-off-by: Vincent Composieux <vincent@composieux.fr>
…terci#63)

* fix: export RUNFILES_DIR for child bash scripts

Add RUNFILES_DIR=${RUNFILES} to async function so that child bash
scripts (like .push scripts) can find runfiles.bash. Without this,
child scripts fail with "runfiles.bash initializer cannot find
bazel_tools/tools/bash/runfiles/runfiles.bash" error.

The issue occurs because:
- Parent scripts only export PYTHON_RUNFILES (Python-specific)
- Child bash scripts check RUNFILES_DIR environment variable
- Without RUNFILES_DIR, runfiles.bash initialization fails

* fix: export RUNFILES_DIR in k8s_gitops.sh.tpl for k8s_deploy

Add RUNFILES_DIR=${RUNFILES} to async function in k8s_gitops.sh.tpl.
This template is used by k8s_deploy.apply (not k8s_test_namespace.sh.tpl
which is for tests only).

* fix: export RUNFILES_DIR in kubectl.sh.tpl for k8s_deploy.apply

Add RUNFILES_DIR=${RUNFILES} to async function in kubectl.sh.tpl.
This is the actual template used by the kubectl rule which generates
the k8s_deploy.apply target.
Bring all Etsy-specific customizations onto the latest upstream/main,
which includes Bazel 8 upgrade, bazel_flag support, .diff target,
RUNFILES_DIR fix, protobuf migration, and release prep.

Etsy changes ported:
- GitHub App support (github_app package, CreateCommit/CreatePR)
- go-github v32 → v68, added ghinstallation/v2
- Buildkite CI integration (env vars, branch naming)
- Optional namespace in k8s/kustomize rules
- respect_resource_namespace parameter
- app_name for gitops directory structure
- Image resolver enhancements (resolveImageName, updateContainerEnv)
- push_oci external image fix
- Deploy GitHub Actions workflow

Upstream features preserved:
- deploy_branch_prefix configurability
- bazel_flag passthrough
- BazelCmd usage in cquery
- CloneOrCheckout with branch prefix
- "${@}" argument passthrough in template
- google.golang.org/protobuf (not golang/protobuf)
- errgroup for parallel push

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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: 4a5f26eda5

ℹ️ 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".

bkRepo = strings.Replace(bkRepo, "git@", "https://", 1)
bkRepo = strings.Replace(bkRepo, ".git", "", 1)
commit := fmt.Sprintf("%s/commit/%s", bkRepo, sha)
shortSha := sha[:7]

Choose a reason for hiding this comment

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

P1 Badge Guard SHA truncation when Buildkite env is absent

This slices BUILDKITE_COMMIT unconditionally, so running create_gitops_prs outside Buildkite (or with a missing/short BUILDKITE_COMMIT) panics with slice bounds out of range before any push/PR logic runs. The script already passes --git_commit, but this code ignores it for title generation, making non-Buildkite executions fail at runtime.

Useful? React with 👍 / 👎.

Comment on lines +162 to +166
if strings.HasPrefix(envValue, "//") {
kv["value"] = pt.images[envValue]
}
if strings.HasPrefix(envValue, ":") {
kv["value"] = pt.images[envValue[1:]]

Choose a reason for hiding this comment

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

P1 Badge Avoid blanking unresolved IMAGE_URL env references

These assignments write directly from the map without checking key existence, so an env value like //foo or :foo that is not present in pt.images is silently replaced with an empty string instead of being preserved or rejected. That can generate manifests with empty image URL env vars and break workloads at deploy/runtime.

Useful? React with 👍 / 👎.

Comment on lines +223 to +225
ref, _, err := gh.Git.CreateRef(ctx, *repoOwner, *repo, newRef)
if err != nil {
log.Fatalf("failed to create branch ref: %v", err)

Choose a reason for hiding this comment

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

P2 Badge Handle existing GitHub App branch refs on reruns

This path always calls CreateRef and fatals on any error, so rerunning a deployment for the same branch name (which the wrapper derives from commit SHA prefix) fails with a 422 "Reference already exists" instead of updating/reusing the branch. That makes retries non-idempotent in the github_app flow.

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.

7 participants