Skip to content

Commit dc06135

Browse files
committed
fix: consistent versioned binary names in releases, fix flaky CI test
- goreleaser: both iwdp-mcp and iwdp-cli now use same naming pattern with version ({name}_{version}_{os}_{arch}) - run.sh: resolve latest version via GitHub API for versioned asset URLs - simulator tests: increase TargetWaitTimeout to 2s on CI runners
1 parent ca0c8ca commit dc06135

4 files changed

Lines changed: 18 additions & 20 deletions

File tree

.goreleaser.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,17 @@ builds:
2222
- arm64
2323

2424
archives:
25-
- id: default
26-
builds:
27-
- iwdp-mcp
28-
- iwdp-cli
29-
format_overrides:
30-
- goos: darwin
31-
format: zip
32-
files:
33-
- LICENSE
34-
- README.md
35-
36-
- id: raw-iwdp-mcp
25+
- id: iwdp-mcp
3726
builds:
3827
- iwdp-mcp
3928
format: binary
40-
name_template: "iwdp-mcp_{{ .Os }}_{{ .Arch }}"
29+
name_template: "iwdp-mcp_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
4130

42-
- id: raw-iwdp-cli
31+
- id: iwdp-cli
4332
builds:
4433
- iwdp-cli
4534
format: binary
46-
name_template: "iwdp-cli_{{ .Os }}_{{ .Arch }}"
35+
name_template: "iwdp-cli_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
4736

4837
changelog:
4938
sort: asc

internal/tools/tools_simulator_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ func getSimClient(t *testing.T) *webkit.Client {
3030
}
3131

3232
simOnce.Do(func() {
33+
// CI runners are slower — give iwdp more time to send Target.targetCreated.
34+
webkit.TargetWaitTimeout = 2 * time.Second
3335
simClient, simErr = webkit.NewClient(context.Background(), wsURL)
3436
})
3537
if simErr != nil {

internal/webkit/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ type Client struct {
4040
Dialer *websocket.Dialer
4141
}
4242

43+
// TargetWaitTimeout controls how long NewClient waits for a Target.targetCreated
44+
// event before falling back to direct (non-Target) mode. Default is 100ms which
45+
// is enough for local iwdp connections. Increase for slower environments (CI).
46+
var TargetWaitTimeout = 100 * time.Millisecond
47+
4348
// NewClient creates a new WebKit Inspector Protocol client connected to the given WebSocket URL.
4449
// If the endpoint uses Target-based routing (ios-webkit-debug-proxy), the client
4550
// automatically wraps/unwraps messages via Target.sendMessageToTarget.
@@ -66,7 +71,7 @@ func NewClientWithDialer(ctx context.Context, wsURL string, dialer *websocket.Di
6671
select {
6772
case <-c.targetReady:
6873
// Target routing enabled
69-
case <-time.After(100 * time.Millisecond):
74+
case <-time.After(TargetWaitTimeout):
7075
// No Target event — use direct mode (e.g., mock servers in tests)
7176
case <-ctx.Done():
7277
_ = c.Close()

scripts/run.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ if [ ! -f "$BINARY" ]; then
2121
aarch64) ARCH="arm64" ;;
2222
esac
2323

24-
ASSET="${BINARY_NAME}_${OS}_${ARCH}"
25-
URL="https://github.com/${REPO}/releases/latest/download/${ASSET}"
24+
# Resolve latest version tag (e.g. "v0.1.0" → "0.1.0")
25+
VERSION="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"v?([^"]+)".*/\1/')"
26+
ASSET="${BINARY_NAME}_${VERSION}_${OS}_${ARCH}"
27+
URL="https://github.com/${REPO}/releases/download/v${VERSION}/${ASSET}"
2628

27-
echo "Downloading ${BINARY_NAME} from ${URL}..." >&2
29+
echo "Downloading ${BINARY_NAME} v${VERSION} from ${URL}..." >&2
2830
mkdir -p "$INSTALL_DIR"
2931
curl -fsSL "$URL" -o "$BINARY"
3032
chmod +x "$BINARY"
31-
echo "Installed ${BINARY_NAME} to ${BINARY}" >&2
33+
echo "Installed ${BINARY_NAME} v${VERSION} to ${BINARY}" >&2
3234
fi
3335

3436
exec "$BINARY" "$@"

0 commit comments

Comments
 (0)