Skip to content

Commit 2d79f48

Browse files
committed
Add CI dogfood workflow
1 parent 250e9af commit 2d79f48

3 files changed

Lines changed: 105 additions & 3 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: '1.24'
27+
28+
- name: Unit tests
29+
run: go test ./...
30+
31+
- name: Build pipekit
32+
run: make build
33+
34+
- name: Integration tests
35+
run: go test ./integration/... -v
36+
37+
- name: Export env from JSON
38+
run: |
39+
./dist/pipekit env from-json --flatten --uppercase-keys --to-github <<'JSON'
40+
{
41+
"name": "pipekit",
42+
"ci": {
43+
"platform": "github-actions",
44+
"purpose": "dogfood"
45+
}
46+
}
47+
JSON
48+
49+
- name: Assert exported env in later step
50+
run: |
51+
./dist/pipekit assert env-exists NAME CI_PLATFORM CI_PURPOSE
52+
test "$NAME" = "pipekit"
53+
test "$CI_PLATFORM" = "github-actions"
54+
test "$CI_PURPOSE" = "dogfood"
55+
56+
- name: Export outputs from JSON
57+
id: json_outputs
58+
run: |
59+
./dist/pipekit env from-json --uppercase-keys --to-github-output <<'JSON'
60+
{
61+
"artifact": "pipekit",
62+
"channel": "ci"
63+
}
64+
JSON
65+
66+
- name: Assert exported outputs in later step
67+
env:
68+
ARTIFACT: ${{ steps.json_outputs.outputs.ARTIFACT }}
69+
CHANNEL: ${{ steps.json_outputs.outputs.CHANNEL }}
70+
run: |
71+
./dist/pipekit assert env-exists ARTIFACT CHANNEL
72+
test "$ARTIFACT" = "pipekit"
73+
test "$CHANNEL" = "ci"
74+
75+
- name: Export cache key
76+
id: cache_key
77+
run: ./dist/pipekit cache-key from-files go.sum --prefix "go-" --to-github-output cache_key
78+
79+
- name: Assert cache key output in later step
80+
env:
81+
CACHE_KEY: ${{ steps.cache_key.outputs.cache_key }}
82+
run: |
83+
./dist/pipekit assert env-exists CACHE_KEY
84+
case "$CACHE_KEY" in
85+
go-*) ;;
86+
*) echo "cache key missing go- prefix: $CACHE_KEY"; exit 1 ;;
87+
esac
88+
89+
- name: Dogfood JSON, mask, exec, and summary
90+
run: |
91+
printf '{"module":"github.com/AxeForging/pipekit","kind":"ci"}\n' > pipekit-ci.json
92+
test "$(./dist/pipekit json get pipekit-ci.json --path '.module' --raw)" = "github.com/AxeForging/pipekit"
93+
./dist/pipekit assert json-path --file pipekit-ci.json --path '.kind' --expected "ci"
94+
./dist/pipekit mask github "secret-ci-value"
95+
./dist/pipekit exec --attempts 2 --delay 1s --mask "secret-[a-z-]+" --tee pipekit-ci.log -- sh -c 'echo token=secret-ci-value'
96+
./dist/pipekit summary badge --label "pipekit" --status success --to-github-summary
97+
./dist/pipekit summary section --title "pipekit CI log" --to-github-summary < pipekit-ci.log

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
go-version: '1.24'
2424

2525
- name: Run tests
26-
run: go test ./...
26+
run: make test-integration
2727

2828
- name: Run GoReleaser
2929
uses: goreleaser/goreleaser-action@v6

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all build clean test lint tidy version release-check
1+
.PHONY: all build clean test test-integration lint tidy version release-check
22

33
GOOS_ARCH := linux/amd64 linux/arm64 linux/386 linux/arm darwin/amd64 darwin/arm64 windows/amd64 windows/arm64 windows/386
44
DIST_DIR := dist
@@ -45,6 +45,11 @@ test:
4545
go test ./... -v
4646
@echo "All tests passed."
4747

48+
test-integration: build
49+
@echo "Running integration tests against dist/pipekit..."
50+
go test ./integration/... -v
51+
@echo "Integration tests passed."
52+
4853
lint:
4954
@echo "Running linter..."
5055
golangci-lint run --timeout=5m
@@ -71,7 +76,7 @@ tag:
7176
git tag -a $(VERSION) -m "Release $(VERSION)"
7277
@echo "Tag created. Push with: git push origin $(VERSION)"
7378

74-
release-check: build
79+
release-check: test-integration
7580
@echo "Running tests..."
7681
go test ./...
7782
@echo "All tests passed. Ready for release $(VERSION)"

0 commit comments

Comments
 (0)