Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ jobs:
steps:
- uses: actions/checkout@v5

- name: Determine Bun version
id: bun-version
run: echo "BUN_VERSION=$(cat package.json | grep 'bun-types' | head -1 | awk -F'"' '{print $4}')" >> $GITHUB_OUTPUT
Comment on lines +15 to +17
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Replace fragile grep/awk parsing with jq.

This step has the same brittle shell parsing issue as in typecheck.yml. Use jq for reliable JSON parsing, and consider extracting this logic to a reusable composite action to avoid duplication.

Apply this diff:

-      - name: Determine Bun version
-        id: bun-version
-        run: echo "BUN_VERSION=$(cat package.json | grep 'bun-types' | head -1 | awk -F'"' '{print $4}')" >> $GITHUB_OUTPUT
+      - name: Determine Bun version
+        id: bun-version
+        run: echo "BUN_VERSION=$(jq -r '.workspaces.catalog["bun-types"]' package.json)" >> $GITHUB_OUTPUT

Optional: Create a composite action at .github/actions/setup-bun/action.yml to encapsulate both the version determination and setup steps, reducing duplication across workflows.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Determine Bun version
id: bun-version
run: echo "BUN_VERSION=$(cat package.json | grep 'bun-types' | head -1 | awk -F'"' '{print $4}')" >> $GITHUB_OUTPUT
- name: Determine Bun version
id: bun-version
run: echo "BUN_VERSION=$(jq -r '.workspaces.catalog[\"bun-types\"]' package.json)" >> $GITHUB_OUTPUT
🤖 Prompt for AI Agents
.github/workflows/test.yml lines 15-17: the current step uses fragile grep/awk
parsing of package.json; replace it with a jq-based command that reliably
extracts the "bun-types" version from dependencies or devDependencies and writes
BUN_VERSION to $GITHUB_OUTPUT, ensure the runner has jq available (or add an
action to install it), and (optionally) factor this logic into a reusable
composite action at .github/actions/setup-bun/action.yml that exposes the
version and performs Bun setup so other workflows can reuse it.


- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.2.22
bun-version: ${{ steps.bun-version.outputs.BUN_VERSION }}

- name: Install dependencies
run: bun install --frozen-lockfile
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ jobs:
steps:
- uses: actions/checkout@v5

- name: Determine Bun version
id: bun-version
run: echo "BUN_VERSION=$(cat package.json | grep 'bun-types' | head -1 | awk -F'"' '{print $4}')" >> $GITHUB_OUTPUT
Comment on lines +15 to +17
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Replace fragile grep/awk parsing with jq.

The current shell pipeline is brittle and may break with JSON formatting changes, comments, or multiple occurrences of "bun-types". Use jq for reliable JSON parsing.

Apply this diff:

-      - name: Determine Bun version
-        id: bun-version
-        run: echo "BUN_VERSION=$(cat package.json | grep 'bun-types' | head -1 | awk -F'"' '{print $4}')" >> $GITHUB_OUTPUT
+      - name: Determine Bun version
+        id: bun-version
+        run: echo "BUN_VERSION=$(jq -r '.workspaces.catalog["bun-types"]' package.json)" >> $GITHUB_OUTPUT

This approach:

  • Correctly parses JSON structure
  • Directly accesses the catalog entry
  • Fails explicitly if the field is missing
  • Is resilient to formatting changes
🤖 Prompt for AI Agents
.github/workflows/typecheck.yml lines 15-17: replace the fragile grep/awk
pipeline with a jq-based extraction of the bun-types version from package.json;
read package.json with jq to select the catalog entry value (failing if
missing), and echo that value into $GITHUB_OUTPUT as BUN_VERSION so the step
reliably parses JSON and errors explicitly when the field is absent.


- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.2.22
bun-version: ${{ steps.bun-version.outputs.BUN_VERSION }}

- name: Install dependencies
run: bun install --frozen-lockfile
Expand Down
Loading