Skip to content

Commit 4301f93

Browse files
authored
Merge pull request #210 from hookdeck/fix/test-npm-install-package-path
fix: test-npm-install use local install and shared verify script
2 parents e5c25e6 + 6e66dc5 commit 4301f93

File tree

5 files changed

+177
-71
lines changed

5 files changed

+177
-71
lines changed

.github/actions/test-npm-install/action.yml

Lines changed: 21 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -42,81 +42,31 @@ runs:
4242
echo "Testing with npm tag: $VERSION (no polling needed)"
4343
fi
4444
45-
- name: Install hookdeck-cli
45+
- name: Install hookdeck-cli (local, no global)
4646
shell: bash
4747
run: |
4848
VERSION="${{ inputs.version }}"
49-
echo "Installing hookdeck-cli${VERSION}..."
50-
npm install -g "hookdeck-cli${VERSION}"
49+
INSTALL_DIR="${RUNNER_TEMP}/hookdeck-cli-install-test"
50+
mkdir -p "$INSTALL_DIR"
51+
cd "$INSTALL_DIR"
52+
# Explicit package.json so npm installs here (not in repo root if runner cwd leaks)
53+
echo '{"name":"hookdeck-cli-install-test","version":"1.0.0","private":true}' > package.json
54+
# npm install needs package@version; tags already have @ (e.g. @latest, @beta)
55+
if [[ "$VERSION" == @* ]]; then
56+
PKG_SPEC="hookdeck-cli${VERSION}"
57+
else
58+
PKG_SPEC="hookdeck-cli@${VERSION}"
59+
fi
60+
echo "Installing ${PKG_SPEC} into $INSTALL_DIR..."
61+
npm install "$PKG_SPEC"
62+
# Required by test-npm-install-verify.sh in the next step
63+
echo "INSTALL_DIR=$INSTALL_DIR" >> "$GITHUB_ENV"
5164
5265
- name: Verify installation
5366
shell: bash
67+
env:
68+
PLATFORM: ${{ inputs.platform }}
5469
run: |
55-
echo "Checking hookdeck binary location..."
56-
which hookdeck || (echo "hookdeck not in PATH" && exit 1)
57-
58-
echo "Checking hookdeck version..."
59-
hookdeck --version
60-
61-
- name: Test wrapper script
62-
shell: bash
63-
run: |
64-
echo "Testing wrapper script execution..."
65-
hookdeck --help > /dev/null
66-
echo "✓ Wrapper script works"
67-
68-
- name: Verify package structure
69-
shell: bash
70-
run: |
71-
HOOKDECK_PATH=$(which hookdeck)
72-
HOOKDECK_DIR=$(dirname "$HOOKDECK_PATH")
73-
PACKAGE_DIR=$(dirname "$HOOKDECK_DIR")
74-
75-
echo "Package directory: $PACKAGE_DIR"
76-
77-
echo "Checking for wrapper script..."
78-
if [ -f "$PACKAGE_DIR/bin/hookdeck.js" ]; then
79-
echo "✓ Wrapper script found"
80-
else
81-
echo "✗ Wrapper script not found"
82-
exit 1
83-
fi
84-
85-
echo "Checking for binaries directory..."
86-
if [ -d "$PACKAGE_DIR/binaries" ]; then
87-
echo "✓ Binaries directory found"
88-
echo "Binaries included:"
89-
ls -la "$PACKAGE_DIR/binaries" || true
90-
else
91-
echo "✗ Binaries directory not found"
92-
exit 1
93-
fi
94-
95-
# Check platform-specific binary
96-
PLATFORM="${{ inputs.platform }}"
97-
case "$PLATFORM" in
98-
darwin)
99-
if [ -f "$PACKAGE_DIR/binaries/darwin-amd64/hookdeck" ] || [ -f "$PACKAGE_DIR/binaries/darwin-arm64/hookdeck" ]; then
100-
echo "✓ macOS binary found"
101-
else
102-
echo "✗ macOS binary not found"
103-
exit 1
104-
fi
105-
;;
106-
linux)
107-
if [ -f "$PACKAGE_DIR/binaries/linux-amd64/hookdeck" ]; then
108-
echo "✓ Linux binary found"
109-
else
110-
echo "✗ Linux binary not found"
111-
exit 1
112-
fi
113-
;;
114-
win32)
115-
if [ -f "$PACKAGE_DIR/binaries/win32-amd64/hookdeck.exe" ]; then
116-
echo "✓ Windows binary found"
117-
else
118-
echo "✗ Windows binary not found"
119-
exit 1
120-
fi
121-
;;
122-
esac
70+
# INSTALL_DIR is set by the previous step via GITHUB_ENV
71+
chmod +x test-scripts/test-npm-install-verify.sh
72+
./test-scripts/test-npm-install-verify.sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ default_cassette.yaml
1616
__debug_bin
1717
node_modules/
1818
.env
19+
test-scripts/.install-test/

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,21 @@ docker run --rm -it \
11461146
http://host.docker.internal:1234
11471147
```
11481148

1149+
### Testing the published npm package
1150+
1151+
To verify that the published npm package installs correctly and has the expected layout (wrapper script and platform binaries), use the local test script. It installs into a controlled directory (no global install) and runs the same checks as the `test-npm-install` CI workflow.
1152+
1153+
```sh
1154+
# Test with @latest (default)
1155+
./test-scripts/test-npm-install-local.sh
1156+
1157+
# Test with a specific version or tag
1158+
./test-scripts/test-npm-install-local.sh 1.7.1
1159+
./test-scripts/test-npm-install-local.sh @beta
1160+
```
1161+
1162+
Install output is written to `test-scripts/.install-test/` (gitignored).
1163+
11491164
## Releasing
11501165

11511166
This section describes the release process for the Hookdeck CLI.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Local test: install hookdeck-cli into a controlled directory and verify (no global install).
3+
# Runs the same verification as the test-npm-install CI action.
4+
#
5+
# Usage: ./test-scripts/test-npm-install-local.sh [version]
6+
# version: optional, e.g. @latest, @beta, or 1.7.1 (default: @latest)
7+
#
8+
# Installs into test-scripts/.install-test/ (gitignored). No side effects on global npm.
9+
10+
set -e
11+
12+
VERSION="${1:-@latest}"
13+
# npm install needs package@version; tags already have @ (e.g. @latest, @beta)
14+
if [[ "$VERSION" == @* ]]; then
15+
PKG_SPEC="hookdeck-cli${VERSION}"
16+
else
17+
PKG_SPEC="hookdeck-cli@${VERSION}"
18+
fi
19+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20+
INSTALL_DIR="$SCRIPT_DIR/.install-test"
21+
22+
echo "Installing ${PKG_SPEC} into $INSTALL_DIR (local only)..."
23+
mkdir -p "$INSTALL_DIR"
24+
cd "$INSTALL_DIR"
25+
# Isolate from repo: npm would otherwise use repo root's package.json
26+
echo '{"name":"hookdeck-cli-install-test","version":"1.0.0","private":true}' > package.json
27+
npm install "$PKG_SPEC"
28+
echo ""
29+
30+
export INSTALL_DIR="$(pwd)"
31+
"$SCRIPT_DIR/test-npm-install-verify.sh"
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/bin/bash
2+
# Verify hookdeck-cli npm package (wrapper, binaries, platform binary).
3+
# Single source of truth for npm install verification; run locally or from CI.
4+
# Uses a local install directory only (no global install).
5+
#
6+
# Usage:
7+
# INSTALL_DIR=/path/to/install ./test-scripts/test-npm-install-verify.sh
8+
#
9+
# INSTALL_DIR = directory where "npm install hookdeck-cli@<version>" was run
10+
# (must contain node_modules/hookdeck-cli)
11+
#
12+
# PLATFORM = optional; darwin|linux|win32 (auto-detected from uname if not set)
13+
#
14+
# Running locally (from repo root):
15+
# INSTALL_DIR=$(mktemp -d)
16+
# (cd "$INSTALL_DIR" && echo '{"name":"verify-test","private":true}' > package.json && npm install hookdeck-cli@latest)
17+
# INSTALL_DIR="$INSTALL_DIR" ./test-scripts/test-npm-install-verify.sh
18+
# rm -rf "$INSTALL_DIR"
19+
20+
set -e
21+
22+
if [ -z "$INSTALL_DIR" ]; then
23+
echo "✗ INSTALL_DIR is required (directory containing node_modules/hookdeck-cli)"
24+
echo " Example: INSTALL_DIR=/tmp/hookdeck-cli-test ./test-scripts/test-npm-install-verify.sh"
25+
exit 1
26+
fi
27+
28+
PACKAGE_DIR="$INSTALL_DIR/node_modules/hookdeck-cli"
29+
if [ ! -d "$PACKAGE_DIR" ]; then
30+
echo "✗ Package not found at $PACKAGE_DIR"
31+
echo " Run 'npm install hookdeck-cli@<version>' inside INSTALL_DIR first."
32+
exit 1
33+
fi
34+
35+
echo "Verifying hookdeck-cli at $PACKAGE_DIR"
36+
echo ""
37+
38+
echo "Checking wrapper script..."
39+
if [ ! -f "$PACKAGE_DIR/bin/hookdeck.js" ]; then
40+
echo "✗ Wrapper script not found at $PACKAGE_DIR/bin/hookdeck.js"
41+
exit 1
42+
fi
43+
echo "✓ Wrapper script found"
44+
echo ""
45+
46+
echo "Running wrapper (version)..."
47+
node "$PACKAGE_DIR/bin/hookdeck.js" --version
48+
echo ""
49+
50+
echo "Running wrapper (--help)..."
51+
node "$PACKAGE_DIR/bin/hookdeck.js" --help > /dev/null
52+
echo "✓ Wrapper script works"
53+
echo ""
54+
55+
echo "Checking for binaries directory..."
56+
if [ ! -d "$PACKAGE_DIR/binaries" ]; then
57+
echo "✗ Binaries directory not found at $PACKAGE_DIR/binaries"
58+
exit 1
59+
fi
60+
echo "✓ Binaries directory found"
61+
ls -la "$PACKAGE_DIR/binaries"
62+
echo ""
63+
64+
# Platform: use env if set (e.g. from CI matrix), else detect from uname
65+
if [ -n "$PLATFORM" ]; then
66+
echo "Checking platform-specific binary (platform: $PLATFORM from env)..."
67+
else
68+
case "$(uname -s)" in
69+
Darwin) PLATFORM=darwin ;;
70+
Linux) PLATFORM=linux ;;
71+
MINGW*|MSYS*|CYGWIN*) PLATFORM=win32 ;;
72+
*) echo "✗ Unsupported platform: $(uname -s)" && exit 1 ;;
73+
esac
74+
echo "Checking platform-specific binary (platform: $PLATFORM auto-detected)..."
75+
fi
76+
77+
case "$PLATFORM" in
78+
darwin)
79+
if [ -f "$PACKAGE_DIR/binaries/darwin-amd64/hookdeck" ] || [ -f "$PACKAGE_DIR/binaries/darwin-arm64/hookdeck" ]; then
80+
echo "✓ macOS binary found"
81+
else
82+
echo "✗ macOS binary not found"
83+
exit 1
84+
fi
85+
;;
86+
linux)
87+
if [ -f "$PACKAGE_DIR/binaries/linux-amd64/hookdeck" ]; then
88+
echo "✓ Linux binary found"
89+
else
90+
echo "✗ Linux binary not found"
91+
exit 1
92+
fi
93+
;;
94+
win32)
95+
if [ -f "$PACKAGE_DIR/binaries/win32-amd64/hookdeck.exe" ]; then
96+
echo "✓ Windows binary found"
97+
else
98+
echo "✗ Windows binary not found"
99+
exit 1
100+
fi
101+
;;
102+
*)
103+
echo "✗ Unknown PLATFORM: $PLATFORM"
104+
exit 1
105+
;;
106+
esac
107+
108+
echo ""
109+
echo "✓ All verification checks passed!"

0 commit comments

Comments
 (0)