Skip to content

Commit 17de5fd

Browse files
committed
feat: add end-to-end test suite
Build and run the actual binary as a subprocess against mock GitHub meta and doco-cd servers. Tests cover the full pipeline including config loading from env vars, secret file support, HMAC forwarding, signal handling, and rejection scenarios. Uses a minimal isolated environment for subprocesses to prevent host env vars from leaking into tests. Also adds GITHUB_META_URL env var override (useful for GitHub Enterprise or integration testing) and a dedicated E2E CI job.
1 parent 8b7cadc commit 17de5fd

3 files changed

Lines changed: 613 additions & 2 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ jobs:
5252
- uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1
5353
- run: golangci-lint run
5454

55+
e2e:
56+
name: E2E
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
60+
- uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1
61+
- run: go test ./e2e/ -tags e2e -v -timeout 60s
62+
5563
docker:
5664
name: Docker build
5765
runs-on: ubuntu-latest

cmd/proxy/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
proxy "github.com/strayer/doco-cd-webhook-proxy/internal/proxy"
1616
)
1717

18-
const githubMetaURL = "https://api.github.com/meta"
18+
const defaultGitHubMetaURL = "https://api.github.com/meta"
1919

2020
func main() {
2121
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
@@ -27,13 +27,18 @@ func main() {
2727
os.Exit(1)
2828
}
2929

30+
metaURL := os.Getenv("GITHUB_META_URL")
31+
if metaURL == "" {
32+
metaURL = defaultGitHubMetaURL
33+
}
34+
3035
ln, err := net.Listen("tcp", cfg.ListenAddr)
3136
if err != nil {
3237
slog.Error("failed to listen", "addr", cfg.ListenAddr, "error", err)
3338
os.Exit(1)
3439
}
3540

36-
if err := run(ctx, cfg, githubMetaURL, ln); err != nil {
41+
if err := run(ctx, cfg, metaURL, ln); err != nil {
3742
slog.Error("fatal", "error", err)
3843
os.Exit(1)
3944
}

0 commit comments

Comments
 (0)