Skip to content

Commit 1eadef6

Browse files
vdemeestertekton-robot
authored andcommitted
feat(ci): add comprehensive CI workflow
This commit introduces a new CI workflow in `.github/workflows/ci.yaml` that handles build, linting, testing, and calls the e2e workflows. It optimizes the CI pipeline by including caching mechanisms and consolidates previously separate workflows. The following changes have been made: * Added a multi-stage CI workflow named `ci`. * Introduced linting steps using tools like `gofmt`, `golangci-lint`, `yamllint` and `go-license` check. * Incorporated build, unit tests, and generated code verification. * Added a multi-arch build support configuration. * Consolidated end-to-end tests via a workflow call in `e2e-matrix.yml`. Additionally, the redundant `golangci-lint.yaml` workflow has been removed. Support for a new test target `test-unit-verbose-and-race` is introduced in the `Makefile`, and the Go toolchain in `go.mod` is updated from `go 1.22.3` to `go 1.22.7`. Signed-off-by: Vincent Demeester <[email protected]> (cherry picked from commit fe892bf)
1 parent f4b7102 commit 1eadef6

File tree

3 files changed

+122
-22
lines changed

3 files changed

+122
-22
lines changed

.github/workflows/ci.yaml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: ci
2+
3+
on: [pull_request] # yamllint disable-line rule:truthy
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.event.pull-request.number || github.ref }}
7+
cancel-in-progress: true
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
permissions:
14+
contents: read
15+
checks: write # Used to annotate code in the PR
16+
17+
jobs:
18+
build:
19+
name: build
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
24+
with:
25+
go-version-file: "go.mod"
26+
- name: build
27+
run: |
28+
go build -v ./...
29+
linting:
30+
needs: [build]
31+
name: lint
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
36+
with:
37+
go-version-file: "go.mod"
38+
- name: gofmt
39+
run: |
40+
gofmt_out=$(gofmt -d $(find * -name '*.go' ! -path 'vendor/*' ! -path 'third_party/*'))
41+
if [[ -n "$gofmt_out" ]]; then
42+
failed=1
43+
fi
44+
echo "$gofmt_out"
45+
- name: golangci-lint
46+
uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.0
47+
with:
48+
version: v1.57.2
49+
args: --timeout=10m
50+
- name: yamllint
51+
run: |
52+
apt update && apt install -y yamllint
53+
yamllint -c .yamllint $(find . -path ./vendor -prune -o -type f -regex ".*y[a]ml" -print | tr '\n' ' ')
54+
- name: check-license
55+
run: |
56+
go install github.com/google/[email protected]
57+
go-licenses check ./...
58+
tests:
59+
needs: [build]
60+
name: test
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
64+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
65+
with:
66+
go-version-file: "go.mod"
67+
- name: build
68+
run: |
69+
make test-unit-verbose-and-race
70+
generated:
71+
needs: [build]
72+
name: Check generated code
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
76+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
77+
with:
78+
go-version-file: "go.mod"
79+
- name: generated
80+
run: |
81+
./hack/verify-codegen.sh
82+
multi-arch-build:
83+
needs: [build]
84+
name: Multi-arch build
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
88+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
89+
with:
90+
go-version-file: "go.mod"
91+
- uses: ko-build/[email protected]
92+
- name: ko-resolve
93+
run: |
94+
cat <<EOF > .ko.yaml
95+
defaultBaseImage: cgr.dev/chainguard/static
96+
baseImageOverrides:
97+
# Use the combined base image for images that should include Windows support.
98+
# 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.
99+
github.com/tektoncd/pipeline/cmd/entrypoint: ghcr.io/tektoncd/pipeline/github.com/tektoncd/pipeline/combined-base-image:latest
100+
github.com/tektoncd/pipeline/cmd/nop: ghcr.io/tektoncd/pipeline/github.com/tektoncd/pipeline/combined-base-image:latest
101+
github.com/tektoncd/pipeline/cmd/workingdirinit: ghcr.io/tektoncd/pipeline/github.com/tektoncd/pipeline/combined-base-image:latest
102+
103+
github.com/tektoncd/pipeline/cmd/git-init: cgr.dev/chainguard/git
104+
EOF
105+
106+
KO_DOCKER_REPO=example.com ko resolve -l 'app.kubernetes.io/component!=resolvers' --platform=all --push=false -R -f config 1>/dev/null
107+
KO_DOCKER_REPO=example.com ko resolve --platform=all --push=false -f config/resolvers 1>/dev/null
108+
e2e-tests:
109+
needs: [build]
110+
uses: ./.github/workflows/e2e-matrix.yml

.github/workflows/e2e-matrix.yml

+8-19
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
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: [workflow_call]
55

66
defaults:
77
run:
88
shell: bash
99

1010
jobs:
1111
e2e-tests:
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ matrix.k8s-name }}-${{ matrix.feature-flags }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
1215
name: e2e tests
1316
runs-on: ubuntu-latest
1417
strategy:
@@ -36,33 +39,20 @@ jobs:
3639
- feature-flags: beta
3740
env-file: prow-beta
3841
env:
39-
GOPATH: ${{ github.workspace }}
40-
GO111MODULE: on
4142
KO_DOCKER_REPO: registry.local:5000/tekton
4243
CLUSTER_DOMAIN: c${{ github.run_id }}.local
4344
ARTIFACTS: ${{ github.workspace }}/artifacts
4445

4546
steps:
46-
- name: Check out code onto GOPATH
47-
uses: actions/checkout@v4
47+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
48+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
4849
with:
49-
path: ${{ github.workspace }}/src/github.com/tektoncd/pipeline
50-
51-
52-
- name: Set up Go 1.22
53-
uses: actions/setup-go@v5
54-
with:
55-
go-version: 1.22.5
50+
go-version-file: "go.mod"
51+
- uses: ko-build/[email protected]
5652

5753
- name: Install Dependencies
5854
working-directory: ./
5955
run: |
60-
echo '::group:: install ko'
61-
curl -L https://github.com/ko-build/ko/releases/download/v0.15.4/ko_0.15.4_Linux_x86_64.tar.gz | tar xzf - ko
62-
chmod +x ./ko
63-
sudo mv ko /usr/local/bin
64-
echo '::endgroup::'
65-
6656
echo '::group:: install go-junit-report'
6757
go install github.com/jstemmer/[email protected]
6858
echo '::endgroup::'
@@ -74,7 +64,6 @@ jobs:
7464
echo "${GOPATH}/bin" >> "$GITHUB_PATH"
7565
7666
- name: Run tests
77-
working-directory: ${{ github.workspace }}/src/github.com/tektoncd/pipeline
7867
run: |
7968
./hack/setup-kind.sh \
8069
--registry-url $(echo ${KO_DOCKER_REPO} | cut -d'/' -f 1) \

Makefile

+4-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ vendor:
8383
$Q ./hack/update-deps.sh
8484

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

0 commit comments

Comments
 (0)