Skip to content

Commit b2d104e

Browse files
committed
Fix: CI and e2e test failures
Signed-off-by: Shubham Bhardwaj <shubbhar@redhat.com>
1 parent 1dab28d commit b2d104e

File tree

11 files changed

+565
-11
lines changed

11 files changed

+565
-11
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: golangci-lint
4646
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
4747
with:
48-
version: v2.1.6
48+
version: v2.9.0
4949
only-new-issues: true
5050
args: --timeout=10m
5151
- name: yamllint

.github/workflows/codeql-analysis.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [main]
16+
branches:
17+
- main
18+
- release-*
1719
pull_request:
1820
# The branches below must be a subset of the branches above
19-
branches: [main]
21+
branches:
22+
- main
23+
- release-*
2024
schedule:
2125
- cron: '30 20 * * 2'
2226

@@ -38,11 +42,11 @@ jobs:
3842

3943
steps:
4044
- name: Checkout repository
41-
uses: actions/checkout@v4
45+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4246

4347
# Initializes the CodeQL tools for scanning.
4448
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v3
49+
uses: github/codeql-action/init@45580472a5bb82c4681c4ac726cfdb60060c2ee1 # v3.32.4
4650
with:
4751
languages: ${{ matrix.language }}
4852
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -51,7 +55,7 @@ jobs:
5155
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5256

5357
# setup cache to speed up the action
54-
- uses: actions/cache@v4
58+
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
5559
with:
5660
path: |
5761
~/.cache/go-build
@@ -81,4 +85,4 @@ jobs:
8185
make bin/tkn
8286
8387
- name: Perform CodeQL Analysis
84-
uses: github/codeql-action/analyze@v3
88+
uses: github/codeql-action/analyze@45580472a5bb82c4681c4ac726cfdb60060c2ee1 # v3.32.4

.github/workflows/e2e-matrix.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Tekton Integration
2+
# Adapted from https://github.com/mattmoor/mink/blob/master/.github/workflows/minkind.yaml
3+
4+
on: [workflow_call]
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
jobs:
11+
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
15+
name: e2e tests
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false # Keep running if one leg fails.
19+
matrix:
20+
k8s-name:
21+
- k8s-oldest
22+
- k8s-plus-one
23+
24+
include:
25+
- k8s-name: k8s-oldest
26+
k8s-version: v1.28.x
27+
- k8s-name: k8s-plus-one
28+
k8s-version: v1.29.x
29+
env:
30+
KO_DOCKER_REPO: registry.local:5000/tekton
31+
CLUSTER_DOMAIN: c${{ github.run_id }}.local
32+
ARTIFACTS: ${{ github.workspace }}/artifacts
33+
34+
steps:
35+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
36+
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
37+
with:
38+
go-version-file: "go.mod"
39+
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
40+
41+
- name: Install Dependencies
42+
working-directory: ./
43+
run: |
44+
echo '::group:: install go-junit-report'
45+
go install github.com/jstemmer/go-junit-report@v0.9.1
46+
echo '::endgroup::'
47+
48+
echo '::group:: created required folders'
49+
mkdir -p "${ARTIFACTS}"
50+
echo '::endgroup::'
51+
52+
echo '::group:: fetch setup-kind.sh from plumbing'
53+
curl -sL https://raw.githubusercontent.com/tektoncd/plumbing/main/tekton/images/kind-e2e/setup-kind.sh \
54+
-o ./hack/setup-kind.sh
55+
chmod +x ./hack/setup-kind.sh
56+
echo '::endgroup::'
57+
58+
echo "${GOPATH}/bin" >> "$GITHUB_PATH"
59+
60+
- name: Run tests
61+
run: |
62+
./hack/setup-kind.sh \
63+
--registry-url $(echo ${KO_DOCKER_REPO} | cut -d'/' -f 1) \
64+
--cluster-suffix c${{ github.run_id }}.local \
65+
--nodes 3 \
66+
--k8s-version ${{ matrix.k8s-version }} \
67+
--e2e-script ./test/e2e-tests.sh \
68+
--e2e-env ./test/e2e-tests-kind-prow.env
69+
70+
- name: Upload test results
71+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
72+
with:
73+
name: ${{ matrix.k8s-version }}-${{ matrix.feature-flags }}
74+
path: ${{ env.ARTIFACTS }}
75+
76+
- uses: chainguard-dev/actions/kind-diag@4ed96e952ef2982fe89a50f3c40e9643bb9fe803 # v1.6.3
77+
if: ${{ failure() }}
78+
with:
79+
artifact-name: ${{ matrix.k8s-version }}-${{ matrix.feature-flags }}-logs
80+
81+
- name: Dump Artifacts
82+
if: ${{ failure() }}
83+
run: |
84+
if [[ -d ${{ env.ARTIFACTS }} ]]; then
85+
cd ${{ env.ARTIFACTS }}
86+
for x in $(find . -type f); do
87+
echo "::group:: artifact $x"
88+
cat $x
89+
echo '::endgroup::'
90+
done
91+
fi

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ lint-yaml: ${YAML_FILES} ; $(info $(M) running yamllint…) ## runs yamllint on
118118
@yamllint -c .yamllint $(YAML_FILES)
119119

120120
## Tests
121-
TEST_UNIT_TARGETS := test-unit-verbose test-unit-race
121+
TEST_UNIT_TARGETS := test-unit-verbose test-unit-race test-unit-verbose-and-race
122122
test-unit-verbose: ARGS=-v
123123
test-unit-race: ARGS=-race
124+
test-unit-verbose-and-race: ARGS=-v -race
124125
$(TEST_UNIT_TARGETS): test-unit
125126
.PHONY: $(TEST_UNIT_TARGETS) test-unit
126127
test-unit: ; $(info $(M) running unit tests…) ## Run unit tests

hack/update-deps.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,15 @@ fi
5656
go mod tidy
5757
go mod vendor
5858

59+
# github.com/alibabacloud-go/cr-20160607@v1.0.1 ships without a LICENSE file
60+
# at the tagged release, but the source repo is Apache-2.0 licensed.
61+
# Copy from the sibling module which shares the same license.
62+
if [[ -f vendor/github.com/alibabacloud-go/cr-20181201/LICENSE ]] && \
63+
[[ -d vendor/github.com/alibabacloud-go/cr-20160607/client ]]; then
64+
cp vendor/github.com/alibabacloud-go/cr-20181201/LICENSE \
65+
vendor/github.com/alibabacloud-go/cr-20160607/LICENSE
66+
cp vendor/github.com/alibabacloud-go/cr-20181201/LICENSE \
67+
vendor/github.com/alibabacloud-go/cr-20160607/client/LICENSE
68+
fi
69+
5970
update_licenses third_party/VENDOR-LICENSE "./cmd/*"

test/e2e-tests-kind-prow.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
E2E_SKIP_CLUSTER_CREATION=true
22
KO_DOCKER_REPO=registry.local:5000
33
ARTIFACTS=/workspace/source/artifacts
4+
5+
# Pin Tekton component versions to ones that:
6+
# 1. Use ghcr.io (gcr.io is deprecated and returns 403)
7+
# 2. Still include ClusterTask CRD (removed in v0.71.0+)
8+
RELEASE_YAML_PIPELINE=https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.70.0/release.yaml
9+
RELEASE_YAML_TRIGGERS=https://storage.googleapis.com/tekton-releases/triggers/previous/v0.30.0/release.yaml
10+
RELEASE_YAML_TRIGGERS_INTERCEPTORS=https://storage.googleapis.com/tekton-releases/triggers/previous/v0.30.0/interceptors.yaml

test/e2e-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ else
174174
export TEST_CLIENT_BINARY="${PWD}/tkn"
175175
fi
176176

177-
go_test_e2e ./test/e2e/... || failed=1
177+
go_test_e2e -timeout=20m ./test/e2e/... || failed=1
178178
(( failed )) && fail_test
179179

180180
success

test/e2e/pipeline/pipeline_test.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package pipeline
2020
import (
2121
"context"
2222
"encoding/json"
23+
"regexp"
2324
"strconv"
2425
"strings"
2526
"testing"
@@ -46,6 +47,22 @@ const (
4647
tePipelineName = "output-pipeline"
4748
)
4849

50+
// normalizeAge replaces timing-dependent age strings (e.g. "1 second ago",
51+
// "40 seconds ago") with a fixed placeholder so that assertions don't flake
52+
// due to clock skew between generating expected output and running the command.
53+
var ageRegexp = regexp.MustCompile(`\d+ (?:second|minute|hour|day)s? ago`)
54+
55+
func normalizeAge(s string) string {
56+
return ageRegexp.ReplaceAllString(s, "--- ago")
57+
}
58+
59+
func assertContainsNormalized(t *testing.T, actual, expected string) {
60+
t.Helper()
61+
if !strings.Contains(normalizeAge(actual), normalizeAge(expected)) {
62+
t.Fatalf("expected stdout to contain (age-normalized):\n%s\ngot:\n%s", expected, actual)
63+
}
64+
}
65+
4966
func TestPipelinesE2E(t *testing.T) {
5067
t.Parallel()
5168
c, namespace := framework.Setup(t)
@@ -200,8 +217,8 @@ Waiting for logs to be available...
200217
res.Assert(t, icmd.Expected{
201218
ExitCode: 0,
202219
Err: icmd.None,
203-
Out: expected,
204220
})
221+
assertContainsNormalized(t, res.Stdout(), expected)
205222
})
206223

207224
t.Run("Validate interactive pipeline logs, with follow mode (-f) ", func(t *testing.T) {
@@ -472,8 +489,8 @@ Waiting for logs to be available...
472489
res.Assert(t, icmd.Expected{
473490
ExitCode: 0,
474491
Err: icmd.None,
475-
Out: expected,
476492
})
493+
assertContainsNormalized(t, res.Stdout(), expected)
477494
})
478495
}
479496

test/e2e/pipeline/start_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ package pipeline
1919

2020
import (
2121
"testing"
22+
"time"
2223

2324
"github.com/AlecAivazis/survey/v2/terminal"
2425
"github.com/Netflix/go-expect"
26+
"github.com/tektoncd/cli/test/builder"
2527
"github.com/tektoncd/cli/test/cli"
2628
"github.com/tektoncd/cli/test/framework"
2729
"github.com/tektoncd/cli/test/helper"
30+
"github.com/tektoncd/cli/test/wait"
2831
"gotest.tools/v3/assert"
2932
knativetest "knative.dev/pkg/test"
3033
)
@@ -77,6 +80,24 @@ func TestPipelineInteractiveStartE2E(t *testing.T) {
7780
})
7881
})
7982

83+
// Wait for the PipelineRun started above to appear and complete before checking logs.
84+
// The API server may take a moment to sync the new PipelineRun object.
85+
var pipelineRunGeneratedName string
86+
for i := 0; i < 10; i++ {
87+
prList := builder.GetPipelineRunListWithName(c, "output-pipeline", true)
88+
if len(prList.Items) > 0 {
89+
pipelineRunGeneratedName = prList.Items[0].Name
90+
break
91+
}
92+
time.Sleep(2 * time.Second)
93+
}
94+
if pipelineRunGeneratedName == "" {
95+
t.Fatal("PipelineRun for output-pipeline not found after polling")
96+
}
97+
if err := wait.ForPipelineRunState(c, pipelineRunGeneratedName, 5*time.Minute, wait.PipelineRunSucceed(pipelineRunGeneratedName), "PipelineRunSucceeded"); err != nil {
98+
t.Fatalf("Error waiting for PipelineRun to Succeed: %s", err)
99+
}
100+
80101
t.Run("Validate pipeline logs, with follow mode (-f) and --last ", func(t *testing.T) {
81102
res := tkn.Run(t, "pipeline", "logs", "--last", "-f")
82103
expected := "\n\ntest-e2e\n\n"

0 commit comments

Comments
 (0)