-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (94 loc) · 4.64 KB
/
Copy pathci.yml
File metadata and controls
106 lines (94 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
# Least-privilege: read-only repo contents; no other scopes needed for lint+test
permissions:
contents: read
jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# ── shellcheck ──────────────────────────────────────────────────────────
# ubuntu-latest ships shellcheck preinstalled; no install step needed.
# Target scripts explicitly: bin/ entries lack .sh extensions so a glob
# on *.sh would miss them.
# NOTE: runs before Node setup — shellcheck needs no node_modules.
- name: shellcheck — bin/* and install/uninstall scripts
id: shellcheck
run: |
shellcheck \
bin/bgrun \
bin/bgstatus \
bin/bgtail \
bin/bgclean \
bin/_bgrunner.sh \
install.sh \
uninstall.sh
echo "result=passed" >> "$GITHUB_OUTPUT"
# ── Node setup ──────────────────────────────────────────────────────────
- name: Set up Node 24
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "24"
cache: npm
# ── Dependency install ──────────────────────────────────────────────────
- name: npm ci
run: npm ci
# ── Syntax gate ─────────────────────────────────────────────────────────
- name: node --check plugin/bgrun-wake.js
id: node_check
run: |
node --check plugin/bgrun-wake.js
echo "result=passed" >> "$GITHUB_OUTPUT"
# ── Smoke test suite ─────────────────────────────────────────────────────
- name: Run smoke tests (plugin/bgrun-wake.test.js)
id: tests
run: |
output=$(npm test 2>&1)
echo "$output"
# Extract pass/fail counts for summary
passed=$(echo "$output" | grep -oP 'Passed:\s*\K[0-9]+' || echo "?")
failed=$(echo "$output" | grep -oP 'Failed:\s*\K[0-9]+' || echo "?")
echo "passed=${passed}" >> "$GITHUB_OUTPUT"
echo "failed=${failed}" >> "$GITHUB_OUTPUT"
# Propagate the original exit code
echo "$output" | grep -q "Failed: 0" || exit 1
# ── Packaging sanity gate ────────────────────────────────────────────────
- name: npm pack --dry-run (files allowlist sanity)
id: pack
run: |
pack_output=$(npm pack --dry-run 2>&1)
echo "$pack_output"
file_count=$(echo "$pack_output" | grep -oP 'total files:\s*\K[0-9]+' || echo "?")
echo "file_count=${file_count}" >> "$GITHUB_OUTPUT"
# ── Step summary (always rendered, even on failure) ──────────────────────
- name: Write run summary
if: always()
env:
SHELLCHECK_RESULT: ${{ steps.shellcheck.outcome }}
NODE_CHECK_RESULT: ${{ steps.node_check.outcome }}
TEST_PASSED: ${{ steps.tests.outputs.passed }}
TEST_FAILED: ${{ steps.tests.outputs.failed }}
PACK_FILES: ${{ steps.pack.outputs.file_count }}
TESTS_OUTCOME: ${{ steps.tests.outcome }}
PACK_OUTCOME: ${{ steps.pack.outcome }}
run: |
{
echo "## CI — ${{ github.workflow }} — ${{ job.status }}"
echo ""
echo "| Check | Result |"
echo "|---|---|"
echo "| shellcheck | \`${SHELLCHECK_RESULT}\` |"
echo "| node --check | \`${NODE_CHECK_RESULT}\` |"
echo "| smoke tests | \`${TESTS_OUTCOME}\` — passed: **${TEST_PASSED}**, failed: **${TEST_FAILED}** |"
echo "| npm pack --dry-run | \`${PACK_OUTCOME}\` — ${PACK_FILES} files in tarball |"
echo ""
echo "Ref: \`${{ github.sha }}\`"
} >> "$GITHUB_STEP_SUMMARY"