Skip to content

Commit

Permalink
feat(ci): add comprehensive CI workflow
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
vdemeester authored and waveywaves committed Feb 19, 2025
1 parent 852c443 commit 845dd31
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 51 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: ci

on: [pull_request] # yamllint disable-line rule:truthy

Check warning on line 3 in .github/workflows/ci.yaml

View workflow job for this annotation

GitHub Actions / lint

3:20 [comments] too few spaces before comment

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull-request.number || github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

permissions:
contents: read
checks: write # Used to annotate code in the PR

Check warning on line 15 in .github/workflows/ci.yaml

View workflow job for this annotation

GitHub Actions / lint

15:17 [comments] too few spaces before comment

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: "go.mod"
- name: build
run: |
go build -v ./...
linting:
needs: [build]
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: "go.mod"
- name: gofmt
run: |
gofmt_out=$(gofmt -d $(find * -name '*.go' ! -path 'vendor/*' ! -path 'third_party/*'))
if [[ -n "$gofmt_out" ]]; then
failed=1
fi
echo "$gofmt_out"
- name: golangci-lint
uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.0
with:
version: v1.62.2
args: --timeout=10m
- name: yamllint
run: |
apt update && apt install -y yamllint
yamllint -c .yamllint $(find . -path ./vendor -prune -o -type f -regex ".*y[a]ml" -print | tr '\n' ' ')
- name: check-license
run: |
go install github.com/google/[email protected]
go-licenses check ./...
tests:
needs: [build]
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: "go.mod"
- name: build
run: |
make test-unit-verbose-and-race
generated:
needs: [build]
name: Check generated code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: "go.mod"
- name: generated
run: |
./hack/verify-codegen.sh
multi-arch-build:
needs: [build]
name: Multi-arch build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: "go.mod"
- uses: ko-build/[email protected]
- name: ko-resolve
run: |
cat <<EOF > .ko.yaml
defaultBaseImage: cgr.dev/chainguard/static
baseImageOverrides:
# Use the combined base image for images that should include Windows support.
# 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.
github.com/tektoncd/pipeline/cmd/entrypoint: ghcr.io/tektoncd/pipeline/github.com/tektoncd/pipeline/combined-base-image:latest
github.com/tektoncd/pipeline/cmd/nop: ghcr.io/tektoncd/pipeline/github.com/tektoncd/pipeline/combined-base-image:latest
github.com/tektoncd/pipeline/cmd/workingdirinit: ghcr.io/tektoncd/pipeline/github.com/tektoncd/pipeline/combined-base-image:latest
github.com/tektoncd/pipeline/cmd/git-init: cgr.dev/chainguard/git
EOF
KO_DOCKER_REPO=example.com ko resolve -l 'app.kubernetes.io/component!=resolvers' --platform=all --push=false -R -f config 1>/dev/null
KO_DOCKER_REPO=example.com ko resolve --platform=all --push=false -f config/resolvers 1>/dev/null
e2e-tests:
needs: [build]
uses: ./.github/workflows/e2e-matrix.yml
27 changes: 8 additions & 19 deletions .github/workflows/e2e-matrix.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: Tekton Integration
# Adapted from https://github.com/mattmoor/mink/blob/master/.github/workflows/minkind.yaml

on: [ pull_request ]
on: [workflow_call]

defaults:
run:
shell: bash

jobs:
e2e-tests:
concurrency:
group: ${{ github.workflow }}-${{ matrix.k8s-name }}-${{ matrix.feature-flags }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
name: e2e tests
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -36,33 +39,20 @@ jobs:
- feature-flags: beta
env-file: prow-beta
env:
GOPATH: ${{ github.workspace }}
GO111MODULE: on
KO_DOCKER_REPO: registry.local:5000/tekton
CLUSTER_DOMAIN: c${{ github.run_id }}.local
ARTIFACTS: ${{ github.workspace }}/artifacts

steps:
- name: Check out code onto GOPATH
uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
path: ${{ github.workspace }}/src/github.com/tektoncd/pipeline


- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: 1.22.5
go-version-file: "go.mod"
- uses: ko-build/[email protected]

- name: Install Dependencies
working-directory: ./
run: |
echo '::group:: install ko'
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
chmod +x ./ko
sudo mv ko /usr/local/bin
echo '::endgroup::'
echo '::group:: install go-junit-report'
go install github.com/jstemmer/[email protected]
echo '::endgroup::'
Expand All @@ -74,7 +64,6 @@ jobs:
echo "${GOPATH}/bin" >> "$GITHUB_PATH"
- name: Run tests
working-directory: ${{ github.workspace }}/src/github.com/tektoncd/pipeline
run: |
./hack/setup-kind.sh \
--registry-url $(echo ${KO_DOCKER_REPO} | cut -d'/' -f 1) \
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/golangci-lint.yaml

This file was deleted.

7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ vendor:
$Q ./hack/update-deps.sh

## Tests
TEST_UNIT_TARGETS := test-unit-verbose test-unit-race
test-unit-verbose: ARGS=-v
test-unit-race: ARGS=-race
TEST_UNIT_TARGETS := test-unit-verbose test-unit-race test-unit-verbose-and-race
test-unit-verbose: ARGS=-v
test-unit-race: ARGS=-race
test-unit-verbose-and-race: ARGS=-v -race
$(TEST_UNIT_TARGETS): test-unit
.PHONY: $(TEST_UNIT_TARGETS) test-unit
test-unit: ## Run unit tests
Expand Down
4 changes: 2 additions & 2 deletions config/config-feature-flags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ data:
# Setting this flag to "true" will enable the CEL evaluation in WhenExpression
enable-cel-in-whenexpression: "false"
# Setting this flag to "true" will enable the use of StepActions in Steps
# This feature is in preview mode and not implemented yet. Please check #7259 for updates.
enable-step-actions: "false"
# This feature is in beta and enabled by default.
enable-step-actions: "true"
# Setting this flag to "true" will enable the use of Artifacts in Steps
# This feature is in preview mode and not implemented yet. Please check #7693 for updates.
enable-artifacts: "false"
Expand Down
2 changes: 1 addition & 1 deletion docs/stepactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ weight: 201

## Overview
> :seedling: **`StepActions` is an [beta](additional-configs.md#beta-features) feature.**
> The `enable-step-actions` feature flag must be set to `"true"` to specify a `StepAction` in a `Step`.
> Step actions are enabled by default. You can disable them by setting the `enable-step-actions` feature flag to `"false"`.
A `StepAction` is the reusable and scriptable unit of work that is performed by a `Step`.

Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/config/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ var (
DefaultEnableStepActions = PerFeatureFlag{
Name: EnableStepActions,
Stability: BetaAPIFields,
Enabled: DefaultBetaFeatureEnabled,
Enabled: DefaultStableFeatureEnabled,
}

// DefaultEnableArtifacts is the default PerFeatureFlag value for EnableArtifacts
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/config/feature_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
SetSecurityContext: config.DefaultSetSecurityContext,
Coschedule: config.DefaultCoschedule,
EnableParamEnum: config.DefaultEnableParamEnum.Enabled,
EnableStepActions: true,
DisableInlineSpec: config.DefaultDisableInlineSpec,
},
fileName: "feature-flags-bundles-and-custom-tasks",
Expand All @@ -152,6 +153,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
SetSecurityContext: config.DefaultSetSecurityContext,
Coschedule: config.DefaultCoschedule,
EnableParamEnum: config.DefaultEnableParamEnum.Enabled,
EnableStepActions: true,
DisableInlineSpec: config.DefaultDisableInlineSpec,
},
fileName: "feature-flags-beta-api-fields",
Expand Down

0 comments on commit 845dd31

Please sign in to comment.