Skip to content

Commit 74e34c4

Browse files
committed
fix(ci): force telemetry on for acceptance-telemetry job
- Set HOOKDECK_CLI_TELEMETRY_DISABLED=0 so repo/org defaults cannot disable headers - AssertTelemetryConsistent: clearer fatal when all telemetry headers empty - run_parallel.sh and README match CI Made-with: Cursor
1 parent 8f52178 commit 74e34c4

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

.github/workflows/test-acceptance.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ jobs:
3939
run: go test -tags="${{ matrix.tags }}" ./test/acceptance/... -v -timeout 12m
4040

4141
# Telemetry proxy tests require the real telemetry header; matrix jobs set
42-
# HOOKDECK_CLI_TELEMETRY_DISABLED=1. This job runs only -tags=telemetry without
43-
# disabling telemetry (same as local when HOOKDECK_CLI_TELEMETRY_DISABLED is unset).
42+
# HOOKDECK_CLI_TELEMETRY_DISABLED=1. This job runs -tags=telemetry with
43+
# HOOKDECK_CLI_TELEMETRY_DISABLED=0 so telemetry is on even if the repo sets a global opt-out.
4444
acceptance-telemetry:
4545
runs-on: ubuntu-latest
4646
env:
4747
ACCEPTANCE_SLICE: "0"
4848
HOOKDECK_CLI_TESTING_API_KEY: ${{ secrets.HOOKDECK_CLI_TESTING_API_KEY }}
49+
# Explicitly allow telemetry: repo/org env may set HOOKDECK_CLI_TELEMETRY_DISABLED=1 globally.
50+
HOOKDECK_CLI_TELEMETRY_DISABLED: "0"
4951
steps:
5052
- name: Check out code
5153
uses: actions/checkout@v3

test/acceptance/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ HOOKDECK_CLI_TESTING_API_KEY_3=key_for_slice2
5050

5151
CI runs **three parallel matrix jobs**, each with its own API key (`HOOKDECK_CLI_TESTING_API_KEY`, `HOOKDECK_CLI_TESTING_API_KEY_2`, `HOOKDECK_CLI_TESTING_API_KEY_3`). Those jobs set **`HOOKDECK_CLI_TELEMETRY_DISABLED=1`** so the CLI does not send telemetry during normal acceptance tests.
5252

53-
A **fourth job** (`acceptance-telemetry` in `.github/workflows/test-acceptance.yml`) does **not** disable telemetry. It runs `go test -tags=telemetry` only (all proxy tests that assert `X-Hookdeck-CLI-Telemetry`, including listen, live under the `telemetry` build tag). It uses `HOOKDECK_CLI_TESTING_API_KEY` and `ACCEPTANCE_SLICE=0` (same project as slice 0; tests use unique resource names).
53+
A **fourth job** (`acceptance-telemetry` in `.github/workflows/test-acceptance.yml`) sets **`HOOKDECK_CLI_TELEMETRY_DISABLED=0`** so the CLI sends `X-Hookdeck-CLI-Telemetry` even if the repository or organization defines `HOOKDECK_CLI_TELEMETRY_DISABLED=1` for other jobs. It runs `go test -tags=telemetry` only (all proxy tests that assert that header, including listen, live under the `telemetry` build tag). It uses `HOOKDECK_CLI_TESTING_API_KEY` and `ACCEPTANCE_SLICE=0` (same project as slice 0; tests use unique resource names).
5454

5555
No test-name list in the workflow—tests are partitioned by **feature tags** (see [Parallelisation](#parallelisation)).
5656

@@ -74,10 +74,10 @@ ACCEPTANCE_SLICE=1 HOOKDECK_CLI_TELEMETRY_DISABLED=1 go test -tags="request even
7474
# Slice 2 (same tags as CI job 2)
7575
ACCEPTANCE_SLICE=2 HOOKDECK_CLI_TELEMETRY_DISABLED=1 go test -tags="attempt metrics issue transformation" ./test/acceptance/... -v -timeout 12m
7676

77-
# Telemetry (same as CI acceptance-telemetry: do not set HOOKDECK_CLI_TELEMETRY_DISABLED)
78-
ACCEPTANCE_SLICE=0 go test -tags=telemetry ./test/acceptance/... -v -timeout 12m
77+
# Telemetry (same as CI acceptance-telemetry: force telemetry on)
78+
ACCEPTANCE_SLICE=0 HOOKDECK_CLI_TELEMETRY_DISABLED=0 go test -tags=telemetry ./test/acceptance/... -v -timeout 12m
7979
```
80-
For slice 1 set `HOOKDECK_CLI_TESTING_API_KEY_2`; for slice 2 set `HOOKDECK_CLI_TESTING_API_KEY_3` (or set `HOOKDECK_CLI_TESTING_API_KEY` to that key). For telemetry, use the slice 0 key and leave `HOOKDECK_CLI_TELEMETRY_DISABLED` unset.
80+
For slice 1 set `HOOKDECK_CLI_TESTING_API_KEY_2`; for slice 2 set `HOOKDECK_CLI_TESTING_API_KEY_3` (or set `HOOKDECK_CLI_TESTING_API_KEY` to that key). For telemetry, use the slice 0 key and set `HOOKDECK_CLI_TELEMETRY_DISABLED=0` (overrides a global opt-out).
8181

8282
**Project list tests** (`TestProjectListShowsType`, `TestProjectListJSONOutput`) require a **CLI key**, not an API or CI key: only keys created via interactive login can list or switch projects. Set `HOOKDECK_CLI_TESTING_CLI_KEY` in your `.env` (or environment) to run these tests; if unset, they are skipped with a clear message.
8383

@@ -86,7 +86,7 @@ From the **repository root**, run the script that runs three matrix slices plus
8686
```bash
8787
./test/acceptance/run_parallel.sh
8888
```
89-
Requires `HOOKDECK_CLI_TESTING_API_KEY`, `HOOKDECK_CLI_TESTING_API_KEY_2`, and `HOOKDECK_CLI_TESTING_API_KEY_3` in `.env` or the environment. The script sets `HOOKDECK_CLI_TELEMETRY_DISABLED=1` for matrix slices only; the telemetry run leaves it unset.
89+
Requires `HOOKDECK_CLI_TESTING_API_KEY`, `HOOKDECK_CLI_TESTING_API_KEY_2`, and `HOOKDECK_CLI_TESTING_API_KEY_3` in `.env` or the environment. The script sets `HOOKDECK_CLI_TELEMETRY_DISABLED=1` for matrix slices and `HOOKDECK_CLI_TELEMETRY_DISABLED=0` for the telemetry run (same as CI).
9090

9191
### Run manual tests (requires human authentication):
9292
```bash

test/acceptance/helpers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ func AssertTelemetryConsistent(t *testing.T, recorded []RecordedRequest, expecte
157157
require.Equal(t, invocationID, p.InvocationID, "request %d (%s %s): invocation_id should be consistent", i, r.Method, r.Path)
158158
require.Equal(t, commandPath, p.CommandPath, "request %d (%s %s): command_path should be consistent", i, r.Method, r.Path)
159159
}
160+
if invocationID == "" && len(recorded) > 0 {
161+
t.Fatalf("telemetry: %d HTTP request(s) recorded but X-Hookdeck-CLI-Telemetry was empty on every one (unset HOOKDECK_CLI_TELEMETRY_DISABLED / config telemetry_disabled for these tests)", len(recorded))
162+
}
160163
require.Equal(t, expectedCommandPath, commandPath, "command_path should match expected")
161164
require.NotEmpty(t, invocationID, "at least one request should have invocation_id")
162165
}

test/acceptance/run_parallel.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Requires HOOKDECK_CLI_TESTING_API_KEY, HOOKDECK_CLI_TESTING_API_KEY_2, and HOOKDECK_CLI_TESTING_API_KEY_3 in environment or test/acceptance/.env.
44
# Run from the repository root.
55
#
6-
# Matrix slices set HOOKDECK_CLI_TELEMETRY_DISABLED=1. The telemetry slice unsets it and runs
6+
# Matrix slices set HOOKDECK_CLI_TELEMETRY_DISABLED=1. The telemetry slice sets it to 0 (matches CI).
77
# -tags=telemetry (telemetry_test.go and telemetry_listen_test.go).
88
#
99
# Output: each slice writes to a log file so you can see which run produced what.
@@ -47,8 +47,8 @@ run_slice2() {
4747

4848
run_telemetry() {
4949
(
50-
unset HOOKDECK_CLI_TELEMETRY_DISABLED
5150
export ACCEPTANCE_SLICE=0
51+
export HOOKDECK_CLI_TELEMETRY_DISABLED=0
5252
go test -tags=telemetry ./test/acceptance/... -v -timeout 12m
5353
) > "$TELEMETRY_LOG" 2>&1
5454
}

0 commit comments

Comments
 (0)