Repository navigation
104 lines (100 loc) · 4.37 KB
/
Copy pathci.yml
File metadata and controls
104 lines (100 loc) · 4.37 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
# The engines field claims ">=18". Until this matrix existed, that claim was evidenced by
# exactly one moving `lts/*` on Ubuntu — so a syntax or API that only exists in a newer
# Node would ship green, and the first person to hear about it would be a user on 18.
test:
name: test (node ${{ matrix.node }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: ["18", "20", "22", "24"]
include:
# macOS is the other platform this is actually used on daily. One version is
# enough: what differs there is the filesystem and process behaviour the lock,
# the atomic writes and the daemon probes depend on — not the language level.
- os: macos-latest
node: "20"
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node }}
- run: npm ci
- run: npm run build
# `npm test`, not a copy of its glob. The duplicate silently stopped running the
# browser-client tests the moment they moved into dist/web/client/app, and CI stayed
# green while a whole directory went unexecuted.
- run: npm test
# What a user actually installs, rather than what the repository happens to contain: the
# packed tarball, unpacked into an isolated HOME, exercised through its published bins.
pack-smoke:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: "lts/*"
- run: npm ci
- run: npm run build
- name: Install the packed artifact into an isolated HOME
run: |
set -euo pipefail
# Output is captured and matched in memory, never piped into `grep -q` or `head`.
# Those exit as soon as they have what they need, which closes the pipe under a
# `docket` that is still writing — SIGPIPE, exit 141, and with `pipefail` that is
# a failed step reporting nothing about what actually went wrong.
tarball="$(npm pack --silent | tail -1)"
scratch="$(mktemp -d)"
export HOME="$scratch"
export DOCKET_DATA_DIR="$scratch/data"
npm install -g "$PWD/$tarball"
docket help > /dev/null
docket import /dev/stdin <<'EOF'
# Docket
- [ ] packed artifact smoke test
EOF
listed="$(docket list --all)"
grep -q "packed artifact smoke test" <<< "$listed"
exported="$(docket export --format json)"
grep -q "packed artifact smoke test" <<< "$exported"
status="$(docket status)"
grep -q "^Mode: local" <<< "$status"
echo "packed artifact works end to end"
# The documented build path — `npm run build` inside the image — was never executed by CI,
# which is how the Dockerfile came to copy one of the three tsconfigs it needs.
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Build the image
run: docker build -t docket:ci .
- name: The documented commands must work inside it
run: |
set -euo pipefail
docker run -d --name docket-ci -v docket-ci-data:/data docket:ci
for i in $(seq 1 30); do
if docker exec docket-ci wget -q --spider http://127.0.0.1:8788/api/v1/health; then break; fi
sleep 1
done
health="$(docker exec docket-ci wget -qO- http://127.0.0.1:8788/api/v1/health)"
grep -q '"ok":true' <<< "$health"
# docs/headless.md's first instruction to a new self-hoster. It needs `docket` on
# PATH inside the runtime image, which the image did not have.
#
# Captured whole, then matched: `… | head -1` closes the pipe after the first of
# this command's four lines, and the SIGPIPE that kills the writer is exit 141.
pairing="$(docker exec docket-ci docket devices pair)"
grep -qE '^[A-Z0-9]{6}$' <<< "$(head -1 <<< "$pairing")"
# Non-root, on the volume the compose file actually uses.
whoami_out="$(docker exec docket-ci id)"
grep -q 'uid=100(docket)' <<< "$whoami_out"
docker rm -f docket-ci
docker volume rm docket-ci-data