Skip to content

Commit fac30dc

Browse files
committed
fix: CI
1 parent 223ed75 commit fac30dc

5 files changed

Lines changed: 145 additions & 28 deletions

File tree

.github/workflows/format.yml

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,32 @@ jobs:
2828
- name: Run format
2929
id: format
3030
continue-on-error: true
31-
run: bun run format
31+
shell: bash
3232
working-directory: packages/cli
33+
run: |
34+
set -o pipefail
35+
bun run format 2>&1 | tee "$GITHUB_WORKSPACE/format-output.txt"
36+
37+
- name: Upload format output
38+
if: always()
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: format-output
42+
path: format-output.txt
43+
retention-days: 7
3344

3445
- name: Process results
3546
id: result
47+
shell: bash
3648
run: |
37-
if [ "${{ steps.format.outcome }}" == "success" ]; then
38-
echo "status=Passed" >> $GITHUB_OUTPUT
39-
echo "details=" >> $GITHUB_OUTPUT
49+
set -euo pipefail
50+
if [ "${{ steps.format.outcome }}" = "success" ]; then
51+
echo "status=Passed" >> "$GITHUB_OUTPUT"
52+
echo "details=Format passed" >> "$GITHUB_OUTPUT"
4053
else
41-
echo "status=Failed" >> $GITHUB_OUTPUT
42-
echo "details=Formatting issues found" >> $GITHUB_OUTPUT
54+
FILES=$(grep -c "^\[warn\]" format-output.txt 2>/dev/null || echo "0")
55+
echo "status=Failed" >> "$GITHUB_OUTPUT"
56+
echo "details=${FILES} files need formatting" >> "$GITHUB_OUTPUT"
4357
fi
4458
4559
- name: Update PR comment
@@ -52,6 +66,8 @@ jobs:
5266
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
5367
with:
5468
script: |
69+
const fs = require("fs");
70+
5571
const marker = "<!-- ci-summary -->";
5672
const detailsMarker = "<!-- details-section -->";
5773
const section = process.env.SECTION;
@@ -62,6 +78,22 @@ jobs:
6278
const { owner, repo } = context.repo;
6379
const issue_number = context.payload.pull_request.number;
6480
81+
let output = "";
82+
try {
83+
output = fs.readFileSync("format-output.txt", "utf8");
84+
} catch (_) {
85+
output = "(format-output.txt not found)";
86+
}
87+
88+
const MAX_CHARS = 60000;
89+
if (output.length > MAX_CHARS) {
90+
output = [
91+
"(truncated; showing last " + MAX_CHARS + " chars)",
92+
"",
93+
output.slice(-MAX_CHARS),
94+
].join("\n");
95+
}
96+
6597
const comments = await github.paginate(github.rest.issues.listComments, {
6698
owner, repo, issue_number, per_page: 100,
6799
});
@@ -95,10 +127,25 @@ jobs:
95127
}
96128
}
97129
98-
rows[section] = status;
99-
100-
if (status === "Failed" && details) {
101-
existingDetails[section] = `<details>\n<summary><strong>${section}</strong></summary>\n\n${details}\n\n[View run](${runUrl})\n\n</details>`;
130+
const resultText = status === "Passed" ? "Passed" : "Failed";
131+
rows[section] = status === "Passed" ? resultText : `[${resultText}](${runUrl}) - ${details}`;
132+
133+
if (status === "Failed") {
134+
const detailsBlock = [
135+
`<details>`,
136+
`<summary><strong>${section}</strong> - ${resultText}</summary>`,
137+
"",
138+
details || "",
139+
"",
140+
`[View run](${runUrl})`,
141+
"",
142+
"```text",
143+
output,
144+
"```",
145+
"</details>",
146+
].join("\n").replace(/\n\n\n+/g, "\n\n");
147+
148+
existingDetails[section] = detailsBlock;
102149
} else {
103150
delete existingDetails[section];
104151
}

.github/workflows/lint.yml

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,33 @@ jobs:
2828
- name: Run lint
2929
id: lint
3030
continue-on-error: true
31-
run: |
32-
bun run lint 2>&1 | tee lint-output.txt
33-
echo "exit_code=${PIPESTATUS[0]}" >> $GITHUB_OUTPUT
31+
shell: bash
3432
working-directory: packages/cli
33+
run: |
34+
set -o pipefail
35+
bun run lint 2>&1 | tee "$GITHUB_WORKSPACE/lint-output.txt"
36+
37+
- name: Upload lint output
38+
if: always()
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: lint-output
42+
path: lint-output.txt
43+
retention-days: 7
3544

3645
- name: Process results
3746
id: result
47+
shell: bash
3848
run: |
39-
if [ "${{ steps.lint.outcome }}" == "success" ]; then
40-
echo "status=Passed" >> $GITHUB_OUTPUT
41-
echo "details=" >> $GITHUB_OUTPUT
49+
set -euo pipefail
50+
if [ "${{ steps.lint.outcome }}" = "success" ]; then
51+
echo "status=Passed" >> "$GITHUB_OUTPUT"
52+
echo "details=Lint passed" >> "$GITHUB_OUTPUT"
4253
else
43-
ERRORS=$(grep -c " error " packages/cli/lint-output.txt 2>/dev/null || echo "0")
44-
WARNINGS=$(grep -c " warning " packages/cli/lint-output.txt 2>/dev/null || echo "0")
45-
echo "status=Failed" >> $GITHUB_OUTPUT
46-
echo "details=${ERRORS} errors, ${WARNINGS} warnings" >> $GITHUB_OUTPUT
54+
ERRORS=$(grep -c " error " lint-output.txt 2>/dev/null || echo "0")
55+
WARNINGS=$(grep -c " warning " lint-output.txt 2>/dev/null || echo "0")
56+
echo "status=Failed" >> "$GITHUB_OUTPUT"
57+
echo "details=${ERRORS} errors, ${WARNINGS} warnings" >> "$GITHUB_OUTPUT"
4758
fi
4859
4960
- name: Update PR comment
@@ -56,6 +67,8 @@ jobs:
5667
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
5768
with:
5869
script: |
70+
const fs = require("fs");
71+
5972
const marker = "<!-- ci-summary -->";
6073
const detailsMarker = "<!-- details-section -->";
6174
const section = process.env.SECTION;
@@ -66,6 +79,22 @@ jobs:
6679
const { owner, repo } = context.repo;
6780
const issue_number = context.payload.pull_request.number;
6881
82+
let output = "";
83+
try {
84+
output = fs.readFileSync("lint-output.txt", "utf8");
85+
} catch (_) {
86+
output = "(lint-output.txt not found)";
87+
}
88+
89+
const MAX_CHARS = 60000;
90+
if (output.length > MAX_CHARS) {
91+
output = [
92+
"(truncated; showing last " + MAX_CHARS + " chars)",
93+
"",
94+
output.slice(-MAX_CHARS),
95+
].join("\n");
96+
}
97+
6998
const comments = await github.paginate(github.rest.issues.listComments, {
7099
owner, repo, issue_number, per_page: 100,
71100
});
@@ -99,10 +128,25 @@ jobs:
99128
}
100129
}
101130
102-
rows[section] = status;
103-
104-
if (status === "Failed" && details) {
105-
existingDetails[section] = `<details>\n<summary><strong>${section}</strong></summary>\n\n${details}\n\n[View run](${runUrl})\n\n</details>`;
131+
const resultText = status === "Passed" ? "Passed" : "Failed";
132+
rows[section] = status === "Passed" ? resultText : `[${resultText}](${runUrl}) - ${details}`;
133+
134+
if (status === "Failed") {
135+
const detailsBlock = [
136+
`<details>`,
137+
`<summary><strong>${section}</strong> - ${resultText}</summary>`,
138+
"",
139+
details || "",
140+
"",
141+
`[View run](${runUrl})`,
142+
"",
143+
"```text",
144+
output,
145+
"```",
146+
"</details>",
147+
].join("\n").replace(/\n\n\n+/g, "\n\n");
148+
149+
existingDetails[section] = detailsBlock;
106150
} else {
107151
delete existingDetails[section];
108152
}

.github/workflows/release.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,22 @@ jobs:
197197
"PR artifacts require download via GitHub CLI (no direct install URL):",
198198
"```bash",
199199
`gh run download ${runId} -n cli-preview-${version} -R ${repoFull}`,
200+
"```",
200201
"",
201-
`bun add -g ./dotns-cli-${version}.tgz`,
202-
"# or",
202+
"Then install:",
203+
"```bash",
204+
"# npm (recommended, works everywhere)",
203205
`npm install -g ./dotns-cli-${version}.tgz`,
204206
"",
207+
"# bun (requires absolute path)",
208+
"# macOS/Linux:",
209+
`bun add -g "$(pwd)/dotns-cli-${version}.tgz"`,
210+
"# Windows PowerShell:",
211+
`# bun add -g "$PWD\\dotns-cli-${version}.tgz"`,
212+
"```",
213+
"",
214+
"Verify:",
215+
"```bash",
205216
"dotns --version",
206217
"```"
207218
].join("\n");
@@ -270,13 +281,26 @@ jobs:
270281
271282
cat > release-body.md <<EOF
272283
## Installation
284+
285+
Download the release:
273286
\`\`\`bash
274287
gh release download ${TAG} -p "*.tgz" -R ${REPO}
288+
\`\`\`
275289
276-
bun add -g ./dotns-cli-${VERSION}.tgz
277-
# or
290+
Install:
291+
\`\`\`bash
292+
# npm (recommended, works everywhere)
278293
npm install -g ./dotns-cli-${VERSION}.tgz
279294
295+
# bun (requires absolute path)
296+
# macOS/Linux:
297+
bun add -g "\$(pwd)/dotns-cli-${VERSION}.tgz"
298+
# Windows PowerShell:
299+
# bun add -g "\$PWD\\dotns-cli-${VERSION}.tgz"
300+
\`\`\`
301+
302+
Verify:
303+
\`\`\`bash
280304
dotns --version
281305
\`\`\`
282306
EOF

packages/cli/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
dist
3+
.papi

packages/cli/src/cli/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env node
12
import { createProgram } from "./program";
23
import { CliExit } from "./exit";
34

0 commit comments

Comments
 (0)