Skip to content

Commit afce644

Browse files
committed
.github/workflows: add a build and test workflows
This commit introduces a new GitHub Actions workflow for building and testing the Go project. The workflow includes jobs for building the Go binary, running unit tests with verbose and race conditions, verifying generated code, and checking multi-architecture builds. Additionally, the e2e-matrix workflow is updated to trigger on ~workflow_call~ instead of ~pull_request~. The Makefile is also updated to include a new target for running unit tests with both verbose and race conditions. Signed-off-by: Vincent Demeester <[email protected]>
1 parent 4006b00 commit afce644

File tree

3 files changed

+89
-4
lines changed

3 files changed

+89
-4
lines changed

.github/workflows/build-and-test.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and Tests
2+
3+
on: [ pull_request ]
4+
5+
defaults:
6+
run:
7+
shell: bash
8+
9+
jobs:
10+
build:
11+
name: build go binary
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
- name: Set up Go 1.22
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: 1.22.5
20+
- name: build
21+
run: |
22+
go build ./...
23+
tests:
24+
needs: [ build ]
25+
name: test go
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
- name: Set up Go 1.22
31+
uses: actions/setup-go@v5
32+
with:
33+
go-version: 1.22.5
34+
- name: build
35+
run: |
36+
make test-unit-verbose-and-race
37+
generated:
38+
needs: [ build ]
39+
name: check if generated code is up-to-date
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
- name: Set up Go 1.22
45+
uses: actions/setup-go@v5
46+
with:
47+
go-version: 1.22.5
48+
- name: generated
49+
run: |
50+
./hack/verify-codegen.sh
51+
multi-arch-build:
52+
needs: [ build ]
53+
name: check if multi-arch build works
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v4
58+
- name: Set up Go 1.22
59+
uses: actions/setup-go@v5
60+
with:
61+
go-version: 1.22.5
62+
- uses: ko-build/[email protected]
63+
- name: ko-resolve
64+
run: |
65+
cat <<EOF > .ko.yaml
66+
defaultBaseImage: cgr.dev/chainguard/static
67+
baseImageOverrides:
68+
# Use the combined base image for images that should include Windows support.
69+
# NOTE: Make sure this list of images to use the combined base image is in sync with what's in tekton/publish.yaml's 'create-ko-yaml' Task.
70+
github.com/tektoncd/pipeline/cmd/entrypoint: ghcr.io/tektoncd/pipeline/github.com/tektoncd/pipeline/combined-base-image:latest
71+
github.com/tektoncd/pipeline/cmd/nop: ghcr.io/tektoncd/pipeline/github.com/tektoncd/pipeline/combined-base-image:latest
72+
github.com/tektoncd/pipeline/cmd/workingdirinit: ghcr.io/tektoncd/pipeline/github.com/tektoncd/pipeline/combined-base-image:latest
73+
74+
github.com/tektoncd/pipeline/cmd/git-init: cgr.dev/chainguard/git
75+
EOF
76+
77+
KO_DOCKER_REPO=example.com ko resolve -l 'app.kubernetes.io/component!=resolvers' --platform=all --push=false -R -f config 1>/dev/null
78+
KO_DOCKER_REPO=example.com ko resolve --platform=all --push=false -f config/resolvers 1>/dev/null
79+
e2e-tests:
80+
needs:
81+
- build
82+
- tests
83+
uses: ./.github/workflows/e2e-matrix.yml

.github/workflows/e2e-matrix.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: Tekton Integration
22
# Adapted from https://github.com/mattmoor/mink/blob/master/.github/workflows/minkind.yaml
33

4-
on: [ pull_request ]
4+
# on: [ pull_request ]
5+
on: [workflow_call]
56

67
defaults:
78
run:

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ vendor:
8484
$Q ./hack/update-deps.sh
8585

8686
## Tests
87-
TEST_UNIT_TARGETS := test-unit-verbose test-unit-race
88-
test-unit-verbose: ARGS=-v
89-
test-unit-race: ARGS=-race
87+
TEST_UNIT_TARGETS := test-unit-verbose test-unit-race test-unit-verbose-and-race
88+
test-unit-verbose: ARGS=-v
89+
test-unit-race: ARGS=-race
90+
test-unit-verbose-and-race: ARGS=-v -race
9091
$(TEST_UNIT_TARGETS): test-unit
9192
.PHONY: $(TEST_UNIT_TARGETS) test-unit
9293
test-unit: ## Run unit tests

0 commit comments

Comments
 (0)