|
| 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 |
0 commit comments