Skip to content

Comments

Improve bootstrap script logging for clarity and debuggability#251

Merged
amaralc merged 3 commits intomainfrom
200-enhance-project-setup-docs
Feb 13, 2026
Merged

Improve bootstrap script logging for clarity and debuggability#251
amaralc merged 3 commits intomainfrom
200-enhance-project-setup-docs

Conversation

@amaralc
Copy link
Owner

@amaralc amaralc commented Feb 13, 2026

Summary

Enhanced the bootstrap script logging to be more friendly, less verbose, and provide better visibility into script execution:

  • Exit on first error: Added set -e to stop on any failure
  • Clear section hierarchy: Organized steps into logical subsections (1a, 1b, 1c, 1d)
  • Suppressed verbose output: All gcloud and gsutil commands redirect to /dev/null
  • Idempotency feedback: Shows ○ existing vs ✓ created for resource status
  • Completion summary: Added actionable next steps at the end
  • Updated project insights: Captured logging patterns as long-term and short-term insights

Example Output

Before:

Operation "operations/acat.p2-707221884363-e5977a06-efc9-4ebb-b1bb-8d60c7a506ad" finished successfully.
Operation "operations/acat.p2-707221884363-970ba6b8-652e-416e-9940-f7c6e7855c7f" finished successfully.
...

After:

Setting up GCP project bootstrap-5541...
  ○ Tag key 'environment' already exists
  ✓ Tag value 'production' created
  ✓ Project created
  ✓ Billing linked
  ✓ APIs enabled
  ✓ Firebase label added

Test Plan

  • Script runs successfully with clean output
  • Idempotent operations show existing vs created status
  • Completion summary provides clear next steps
  • Script fails fast on first error

Closes #200

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Updated short-term insights with several new entries and removals; revised a long-term insight to focus on grouped operations and reduced CLI verbosity.
    • Expanded bootstrap README with more comprehensive setup parameters and automated organization-level role provisioning.
  • Chores

    • Refactored bootstrap and cleanup scripts for stricter error handling, clearer phased flow, and quieter non-interactive output.
    • Switched Terraform state storage to a new backend bucket.

amaralc and others added 2 commits February 13, 2026 18:24
…empotency

- Add set -e for fail-fast error handling
- Group operations under descriptive section headers (1a, 1b, 1c, 1d)
- Suppress verbose gcloud/gsutil output to reduce noise
- Show idempotency status: ○ for existing, ✓ for created resources
- Add completion summary with actionable next steps
- Update project insights with logging patterns learned

Addresses #200

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explore Ready Ready Preview, Comment Feb 13, 2026 9:43pm

@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Updates docs and bootstrap tooling: refactors bootstrap scripts into labeled idempotent phases, adds strict error handling and WIF/GitHub setup, automates organization-level IAM role grants, adjusts Terraform backend bucket, and refreshes long‑ and short‑term insights content.

Changes

Cohort / File(s) Summary
Documentation
docs/insights-long-term.md, docs/insights-short-term.md
Replaced insight #100 text to recommend grouping operations and suppressing verbose CLI output; refreshed short-term insights with several new timestamped entries and removal of older entries.
Bootstrap README
teams/kernel/iac/bootstrap/README.md
Rewrote usage and invocation examples, added many new required inputs, renamed params, and documented automated organization-level IAM role grants (removed manual console steps).
Bootstrap scripts
teams/kernel/iac/bootstrap/project-setup.sh, teams/kernel/iac/bootstrap/project-cleanup.sh
Major refactor: added set -e, repo/path validation, reorganized into labeled phases (GCP project, WIF/OIDC, IAM role grants, support group/artifact registry, GitHub secrets/environments, Terraform backend), quieter output, idempotent checks, and improved status messages.
Terraform backend
teams/kernel/iac/production/backend.tf
Changed GCS backend bucket name from bootstrap-9b47-tfstate to bootstrap-5541-tfstate (state location change).

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Script as project-setup.sh
    participant GCP as Google Cloud
    participant GH as GitHub
    participant GCS as GCS (Terraform backend)

    Dev->>Script: run setup (flags, repo path)
    Script->>GCP: ensure project exists, enable APIs
    Script->>GCP: create WIF pool & OIDC provider
    Script->>GCP: grant org/project IAM roles to SA
    Script->>GH: create repos/environments, push secrets (WIF configs)
    Script->>GCS: create/update backend bucket / backend.tf
    GCS-->>Script: confirm backend ready
    GH-->>Script: confirm secrets/environments created
    GCP-->>Script: confirm roles & WIF bindings
    Script-->>Dev: summary / completion status
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through scripts at break of day,

folded phases neat along the way,
WIF and roles now hum in tune,
GCS holds state beneath the moon,
Hooray — the setup hops and plays.

🚥 Pre-merge checks | ✅ 4 | ❌ 2
❌ Failed checks (2 inconclusive)
Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The PR addresses linked issue #200 by improving bootstrap script logging and automation. However, #200 requires eliminating all manual steps to release and achieving a fully automated CI/CD pipeline—broader goals than logging improvements alone. The PR only partially fulfills these larger objectives [#200]. Clarify whether this PR is intended as an incremental step toward #200's target condition or if additional changes are needed to fully close the issue. The logging improvements alone do not fully address the comprehensive CI/CD automation requirements outlined in #200.
Out of Scope Changes check ❓ Inconclusive Most changes directly support the stated objective of improving logging and debuggability. However, updates to short-term and long-term insights docs, backend.tf bucket name, and README parameter documentation appear tangential to the core logging improvement focus. Verify that documentation updates (insights, README, backend bucket name) are intended as part of this PR or if they should be separated into distinct changes focused solely on logging improvements.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Improve bootstrap script logging for clarity and debuggability' is concise and directly summarizes the main changes in the changeset, which focus on enhancing script logging with better structure, less noise, and clearer status indicators.
Description check ✅ Passed The PR description fully addresses the template requirements with clear sections on what was modified (logging improvements, fail-fast behavior, structured output) and how it was implemented (code changes, examples, test plan). The template's experiment record section is not required for all PRs based on context.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 200-enhance-project-setup-docs

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Feb 13, 2026

View your CI Pipeline Execution ↗ for commit 8091f25

Command Status Duration Result
nx affected --target=build --base=origin/main -... ✅ Succeeded <1s View ↗
nx affected --target=test --base=origin/main --... ✅ Succeeded <1s View ↗
nx affected --target=lint --base=origin/main --... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-13 21:42:48 UTC

@amaralc amaralc merged commit ca7bc8f into main Feb 13, 2026
6 of 7 checks passed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
teams/kernel/iac/bootstrap/project-setup.sh (1)

173-176: ⚠️ Potential issue | 🟡 Minor

Typo in error message: underscore instead of hyphen.

The error message says --nx-cloud-access_token-read-write but the actual flag is --nx-cloud-access-token-read-write.

🐛 Proposed fix
 if [ -z "$NX_CLOUD_ACCESS_TOKEN_READ_WRITE" ]
 then
-    echo "Error: --nx-cloud-access_token-read-write flag is required"
+    echo "Error: --nx-cloud-access-token-read-write flag is required"
     exit 1
 fi
🤖 Fix all issues with AI agents
In `@teams/kernel/iac/bootstrap/project-setup.sh`:
- Around line 1-2: The script declares a POSIX shell with "#!/bin/sh" but uses
bash-only redirections "&>/dev/null"; replace every "&>/dev/null" occurrence
(e.g., the redirections used in commands around lines referenced in the review)
with the POSIX-compliant form ">/dev/null 2>&1" so the script is portable under
dash/ash; search for the string "&>/dev/null" and update those instances in the
script (project-setup.sh) to the recommended redirect syntax.

In `@teams/kernel/iac/bootstrap/README.md`:
- Around line 52-54: Remove the unused parameter mention
--mongodb-atlas-group-id from the README header comments so the documented
expected parameters match the script and example invocation; locate the header
block that lists script flags (references to --mongodb-atlas-group-id and
MONGODB_ATLAS_GROUP_ID) and delete that flag and any associated variable name
from the list, ensuring the remaining parameters (e.g.,
--mongodb-atlas-public-key, --mongodb-atlas-private-key) remain intact and the
example command and header are consistent.
🧹 Nitpick comments (1)
teams/kernel/iac/bootstrap/project-setup.sh (1)

473-475: Consider reviewing the roles/editor grant for least-privilege compliance.

The roles/editor primitive role grants broad permissions that overlap with many of the specific roles already granted (e.g., storage.admin, cloudsql.admin). While this may be intentional for bootstrap convenience, it's worth verifying whether such broad access is required, or if the specific roles alone would suffice.

Comment on lines 1 to +2
#!/bin/sh
set -e
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

POSIX shell declared but bash-specific syntax used throughout.

The shebang specifies #!/bin/sh for POSIX compatibility, but the script uses &>/dev/null (a bash-specific redirect) on multiple lines (300, 308, 318, 359, 367, 381, 394, 510, 523). On systems where /bin/sh is dash, ash, or another strict POSIX shell, these redirections will fail.

🔧 Proposed fix: Use POSIX-compliant redirections

Replace all occurrences of &>/dev/null with >/dev/null 2>&1:

-if gcloud resource-manager tags keys describe "$GCP_ORGANIZATION_ID/$GCP_TAG_KEY_SHORT_NAME" &>/dev/null; then
+if gcloud resource-manager tags keys describe "$GCP_ORGANIZATION_ID/$GCP_TAG_KEY_SHORT_NAME" >/dev/null 2>&1; then

Apply the same pattern to lines 308, 318, 359, 367, 381, 394, 510, and 523.

🤖 Prompt for AI Agents
In `@teams/kernel/iac/bootstrap/project-setup.sh` around lines 1 - 2, The script
declares a POSIX shell with "#!/bin/sh" but uses bash-only redirections
"&>/dev/null"; replace every "&>/dev/null" occurrence (e.g., the redirections
used in commands around lines referenced in the review) with the POSIX-compliant
form ">/dev/null 2>&1" so the script is portable under dash/ash; search for the
string "&>/dev/null" and update those instances in the script (project-setup.sh)
to the recommended redirect syntax.

Comment on lines 52 to 54
```bash
bash teams/kernel/iac/project-setup.sh --gcp-project-id=$GCP_PROJECT_ID --gcp-billing-account-id=$GCP_BILLING_ACCOUNT_ID --domain=$DOMAIN --github-username=$GITHUB_USERNAME --github-repository=$GITHUB_REPOSITORY
sh {FOLDER_PATH}/project-setup.sh --owner-account-email=$OWNER_ACCOUNT_EMAIL --gcp-organization-id=$GCP_ORGANIZATION_ID --gcp-billing-account-id=$GCP_BILLING_ACCOUNT_ID --domain-name=$DOMAIN_NAME --github-username=$GITHUB_USERNAME --github-repository=$GITHUB_REPOSITORY --neon-api-key=$NEON_API_KEY --neon-project-location=$NEON_PROJECT_LOCATION --mongodb-atlas-org-id=$MONGODB_ATLAS_ORG_ID --mongodb-atlas-public-key=$MONGODB_ATLAS_PUBLIC_KEY --mongodb-atlas-private-key=$MONGODB_ATLAS_PRIVATE_KEY --nx-cloud-access-token-read-write=$NX_CLOUD_ACCESS_TOKEN_READ_WRITE --nx-cloud-access-token-read=$NX_CLOUD_ACCESS_TOKEN_READ
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

rg -n "mongodb-atlas-group-id|MONGODB_ATLAS_GROUP_ID" teams/kernel/iac/bootstrap/project-setup.sh

Repository: amaralc/explore

Length of output: 88


🏁 Script executed:

head -n 30 teams/kernel/iac/bootstrap/project-setup.sh | cat -n

Repository: amaralc/explore

Length of output: 2137


🏁 Script executed:

sed -n '25p' teams/kernel/iac/bootstrap/project-setup.sh

Repository: amaralc/explore

Length of output: 730


Remove unused --mongodb-atlas-group-id from the script's expected parameters list.

The script's header comments (lines 6–21) list --mongodb-atlas-group-id as an expected parameter, but it is never used in the script logic and is omitted from the script's own example command (line 25). The README is consistent with the script's documented example, so the inconsistency should be resolved by removing --mongodb-atlas-group-id from the header comments.

🤖 Prompt for AI Agents
In `@teams/kernel/iac/bootstrap/README.md` around lines 52 - 54, Remove the unused
parameter mention --mongodb-atlas-group-id from the README header comments so
the documented expected parameters match the script and example invocation;
locate the header block that lists script flags (references to
--mongodb-atlas-group-id and MONGODB_ATLAS_GROUP_ID) and delete that flag and
any associated variable name from the list, ensuring the remaining parameters
(e.g., --mongodb-atlas-public-key, --mongodb-atlas-private-key) remain intact
and the example command and header are consistent.

@sonarqubecloud
Copy link

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.

Target Condition: Zero manual steps to release, fully automated CI/CD pipeline

1 participant