From 27d86a4765c21502df701ee157e3d3c01111a076 Mon Sep 17 00:00:00 2001 From: chrisghill Date: Tue, 12 May 2026 09:47:01 -0600 Subject: [PATCH 1/2] support MASSDRIVER_INSTANCE_ID to replace MASSDRIVER_PACKAGE_NAME --- src/massdriver/main.go | 4 +- src/provisioners/terraform/backend.go | 7 +- src/provisioners/terraform/backend_test.go | 77 ++++++++++++++++------ 3 files changed, 65 insertions(+), 23 deletions(-) diff --git a/src/massdriver/main.go b/src/massdriver/main.go index bcaf086..5e22e41 100644 --- a/src/massdriver/main.go +++ b/src/massdriver/main.go @@ -21,8 +21,10 @@ type Specification struct { Action string `envconfig:"ACTION"` BundleName string `envconfig:"BUNDLE_NAME"` DeploymentID string `envconfig:"DEPLOYMENT_ID" required:"true"` + // TODO: make this required once PACKAGE_NAME is fully deprecated + InstanceID string `envconfig:"INSTANCE_ID"` OrganizationID string `envconfig:"ORGANIZATION_ID" required:"true"` - PackageName string `envconfig:"PACKAGE_NAME" required:"true"` + PackageName string `envconfig:"PACKAGE_NAME"` Token string `envconfig:"TOKEN" required:"true"` URL string `envconfig:"URL"` } diff --git a/src/provisioners/terraform/backend.go b/src/provisioners/terraform/backend.go index 46abd0f..97c075a 100644 --- a/src/provisioners/terraform/backend.go +++ b/src/provisioners/terraform/backend.go @@ -83,9 +83,14 @@ func GenerateBackendHTTPFile(ctx context.Context, output string, spec *massdrive func GenerateJSONBackendHTTPConfig(spec *massdriver.Specification, bundleStep string) ([]byte, error) { httpbb := new(HTTPBackendBlock) + instanceId := spec.InstanceID + if instanceId == "" { + instanceId = getPackageNameShort(spec.PackageName) + } + httpbb.Username = spec.DeploymentID httpbb.Password = spec.Token - httpbb.Address = fmt.Sprintf("%s/state/%s/%s", spec.URL, getPackageNameShort(spec.PackageName), bundleStep) + httpbb.Address = fmt.Sprintf("%s/state/%s/%s", spec.URL, instanceId, bundleStep) httpbb.LockAddress = httpbb.Address httpbb.UnlockAddress = httpbb.Address diff --git a/src/provisioners/terraform/backend_test.go b/src/provisioners/terraform/backend_test.go index 578cdb1..18e2fe0 100644 --- a/src/provisioners/terraform/backend_test.go +++ b/src/provisioners/terraform/backend_test.go @@ -8,28 +8,63 @@ import ( ) func TestGenerateJSONBackendHTTPConfig(t *testing.T) { - spec := massdriver.Specification{ - DeploymentID: "depId", - Token: "token", - PackageName: "pkg-id-long-0000", - URL: "https://foo.massdriver.cloud", - } - got, _ := GenerateJSONBackendHTTPConfig(&spec, "step") - want := ` - { - "terraform": { - "backend": { - "http": { - "username": "depId", - "password": "token", - "address": "https://foo.massdriver.cloud/state/pkg-id-long/step", - "lock_address": "https://foo.massdriver.cloud/state/pkg-id-long/step", - "unlock_address": "https://foo.massdriver.cloud/state/pkg-id-long/step" + tests := []struct { + name string + spec massdriver.Specification + step string + want string + }{ + { + name: "generates backend from Package Name", + spec: massdriver.Specification{ + DeploymentID: "depId", + Token: "token", + PackageName: "pkg-id-long-0000", + URL: "https://foo.massdriver.cloud", + }, + step: "step", + want: `{ + "terraform": { + "backend": { + "http": { + "username": "depId", + "password": "token", + "address": "https://foo.massdriver.cloud/state/pkg-id-long/step", + "lock_address": "https://foo.massdriver.cloud/state/pkg-id-long/step", + "unlock_address": "https://foo.massdriver.cloud/state/pkg-id-long/step" + } + } + } + }`, + }, { + name: "generates backend config from Instance ID", + spec: massdriver.Specification{ + DeploymentID: "depId", + Token: "token", + InstanceID: "inst-ance-id", + URL: "https://foo.massdriver.cloud", + }, + step: "step", + want: `{ + "terraform": { + "backend": { + "http": { + "username": "depId", + "password": "token", + "address": "https://foo.massdriver.cloud/state/inst-ance-id/step", + "lock_address": "https://foo.massdriver.cloud/state/inst-ance-id/step", + "unlock_address": "https://foo.massdriver.cloud/state/inst-ance-id/step" + } + } } - } - } + }`, + }, } -` - require.JSONEq(t, string(got), want) + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, _ := GenerateJSONBackendHTTPConfig(&tt.spec, tt.step) + require.JSONEq(t, string(got), tt.want) + }) + } } From eafa23137ef6360648d4cc9b374ba6cc322f895a Mon Sep 17 00:00:00 2001 From: chrisghill Date: Tue, 12 May 2026 09:51:41 -0600 Subject: [PATCH 2/2] add claude review workflow --- .github/workflows/claude-code-review.yml | 43 +++++++++++++++++++++ .github/workflows/claude.yml | 49 ++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 .github/workflows/claude-code-review.yml create mode 100644 .github/workflows/claude.yml diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml new file mode 100644 index 0000000..25f4ad1 --- /dev/null +++ b/.github/workflows/claude-code-review.yml @@ -0,0 +1,43 @@ +name: Claude Code Review + +on: + pull_request: + types: [opened, synchronize, ready_for_review, reopened] + # Optional: Only run on specific file changes + # paths: + # - "src/**/*.ts" + # - "src/**/*.tsx" + # - "src/**/*.js" + # - "src/**/*.jsx" + +jobs: + claude-review: + # Optional: Filter by PR author + # if: | + # github.event.pull_request.user.login == 'external-contributor' || + # github.event.pull_request.user.login == 'new-developer' || + # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code Review + id: claude-review + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' + plugins: 'code-review@claude-code-plugins' + prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}' + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://code.claude.com/docs/en/cli-reference for available options diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml new file mode 100644 index 0000000..9471a05 --- /dev/null +++ b/.github/workflows/claude.yml @@ -0,0 +1,49 @@ +name: Claude Code + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + issues: + types: [opened, assigned] + pull_request_review: + types: [submitted] + +jobs: + claude: + if: | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || + (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + actions: read # Required for Claude to read CI results on PRs + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code + id: claude + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + + # This is an optional setting that allows Claude to read CI results on PRs + additional_permissions: | + actions: read + + # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. + # prompt: 'Update the pull request description to include a summary of changes.' + + # Optional: Add claude_args to customize behavior and configuration + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://code.claude.com/docs/en/cli-reference for available options + # claude_args: '--allowed-tools Bash(gh pr:*)'