Skip to content

Commit ae13f76

Browse files
committed
Run Integration tests on microshift
1 parent c62bed9 commit ae13f76

8 files changed

Lines changed: 171 additions & 22 deletions

File tree

.github/workflows/microshift.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Integration Tests on microshift
2+
3+
permissions:
4+
contents: read
5+
packages: write
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- main
11+
- release-*
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
defaults:
18+
run:
19+
shell: bash
20+
21+
jobs:
22+
tekton-triggers-integration-tests-microshift:
23+
runs-on: ubuntu-24.04
24+
name: Integration Tests on microshift
25+
strategy:
26+
fail-fast: false
27+
28+
env:
29+
SHELL: /bin/bash
30+
GOPATH: ${{ github.workspace }}
31+
GO111MODULE: on
32+
# KO_DOCKER_REPO: ghcr.io/${{ github.repository_owner }}/
33+
KO_DOCKER_REPO: ko.local
34+
CLUSTER_DOMAIN: ${{ github.run_id }}.local
35+
ARTIFACTS: ${{ github.workspace }}/artifacts
36+
SKIP_INITIALIZE: true
37+
SKIP_SECURITY_CTX: true
38+
SKIP_KNATIVE_EG: true
39+
DOCKER_HOST: unix:///run/podman/podman.sock
40+
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
44+
with:
45+
path: ${{ github.workspace }}/src/github.com/tektoncd/triggers
46+
47+
- name: Set up Go
48+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
49+
with:
50+
cache-dependency-path: "${{ github.workspace }}/src/github.com/tektoncd/triggers/go.sum"
51+
go-version-file: "${{ github.workspace }}/src/github.com/tektoncd/triggers/go.mod"
52+
53+
- name: Install Podman
54+
uses: gacts/install-podman@v1
55+
run: |
56+
sudo podman system service -t 5000 &
57+
58+
59+
- name: Install dependencies
60+
working-directory: ./
61+
run: |
62+
echo '::group::install ko'
63+
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
64+
echo '::group:: install go-junit-report'
65+
go install github.com/jstemmer/go-junit-report@v0.9.1
66+
echo '::endgroup::'
67+
chmod +x ./ko
68+
sudo mv ko /usr/local/bin
69+
echo '::endgroup::'
70+
71+
echo '::group::create required folders'
72+
mkdir -p "${ARTIFACTS}"
73+
echo '::endgroup::'
74+
75+
echo "${GOPATH}/bin" >> "$GITHUB_PATH"
76+
77+
# - name: Log in to the Container registry
78+
# uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
79+
# with:
80+
# registry: ghcr.io
81+
# username: ${{ github.actor }}
82+
# password: ${{ secrets.GITHUB_TOKEN }}
83+
84+
- name: Run tests
85+
working-directory: ${{ github.workspace }}/src/github.com/tektoncd/triggers
86+
run: |
87+
curl -L -o minc https://github.com/minc-org/minc/releases/latest/download/minc_linux_amd64
88+
chmod +x minc
89+
curl https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml | yq 'del(.spec.template.spec.containers[]?.securityContext.runAsUser, .spec.template.spec.containers[]?.securityContext.runAsGroup)' > release
90+
export RELEASE_YAML=$(realpath release)
91+
./minc config set provider podman
92+
./minc create --log-level debug
93+
export KUBECONFIG=$HOME/.kube/config
94+
${{ github.workspace }}/src/github.com/tektoncd/triggers/test/gh-e2e-tests.sh
95+
96+
- name: Upload test results
97+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
98+
if: ${{ failure() }}
99+
with:
100+
path: ${{ env.ARTIFACTS }}

docs/getting-started/pipeline.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,14 @@ spec:
148148
containers:
149149
- image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/event_display
150150
name: web
151+
securityContext:
152+
allowPrivilegeEscalation: false
153+
readOnlyRootFilesystem: true
154+
runAsNonRoot: true
155+
runAsUser: 65532
156+
runAsGroup: 65532
157+
capabilities:
158+
drop:
159+
- "ALL"
160+
seccompProfile:
161+
type: RuntimeDefault

test/e2e-common.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# Check if we have a specific RELEASE_YAML global environment variable to use
2727
# instead of detecting the latest released one from tektoncd/pipeline releases
2828
RELEASE_YAML=${RELEASE_YAML:-}
29-
3029
source $(dirname $0)/../vendor/github.com/tektoncd/plumbing/scripts/e2e-tests.sh
3130

3231
function install_pipeline_crd() {
@@ -52,17 +51,37 @@ function install_pipeline_crd() {
5251

5352
function install_triggers_crd() {
5453
echo ">> Deploying Tekton Triggers"
55-
ko apply -f config/ || fail_test "Tekton Triggers installation failed"
54+
ko resolve -f config/ > rel.yaml || fail_test "Tekton Triggers build failed"
55+
56+
if [ "${SKIP_SECURITY_CTX}" == "true" ]; then
57+
yq 'del(.spec.template.spec.containers[]?.securityContext.runAsUser, .spec.template.spec.containers[]?.securityContext.runAsGroup)' rel.yaml > release.yaml
58+
else
59+
cat rel.yaml > release.yaml
60+
fi
61+
62+
rm rel.yaml
63+
kubectl apply -f release.yaml || fail_test "Tekton Triggers installation failed"
5664

5765
# Wait for the Interceptors CRD to be available before adding the core-interceptors
5866
kubectl wait --for=condition=Established --timeout=30s crds/clusterinterceptors.triggers.tekton.dev
59-
ko apply -f config/interceptors || fail_test "Core interceptors installation failed"
67+
ko resolve -f config/interceptors > rel.yaml || fail_test "Core interceptors build failed"
68+
69+
if [ "${SKIP_SECURITY_CTX}" == "true" ]; then
70+
kubectl patch configmap config-defaults-triggers -n tekton-pipelines --type='merge' -p='{"data":{"default-run-as-user":"","default-fs-group":"", "default-run-as-group":""}}'
71+
yq 'del(.spec.template.spec.containers[]?.securityContext.runAsUser, .spec.template.spec.containers[]?.securityContext.runAsGroup)' rel.yaml > release.yaml
72+
else
73+
cat rel.yaml > release.yaml
74+
fi
75+
76+
rm rel.yaml
77+
kubectl apply -f release.yaml || fail_test "Core interceptors installation failed"
6078

6179
# Make sure that eveything is cleaned up in the current namespace.
6280
for res in eventlistener triggertemplate triggerbinding clustertriggerbinding; do
6381
kubectl delete --ignore-not-found=true ${res}.triggers.tekton.dev --all
6482
done
6583

84+
rm release.yaml
6685
# Wait for pods to be running in the namespaces we are deploying to
6786
wait_until_pods_running tekton-pipelines || fail_test "Tekton Triggers did not come up"
6887

test/e2e-tests-examples.sh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,27 @@ main() {
202202
cleanup
203203
info "Test Successful"
204204
done
205-
# To test Knative Serving example
206-
info "Knative Example Test Started"
207-
current_example="custom-resource"
208-
echo "*** Example ${current_example_version}/${current_example} ***";
209-
apply_files
210-
check_eventlistener
211-
curl_knative_service
212-
cleanup
213-
info "Knative Example Test Successful"
205+
if [ "${SKIP_KNATIVE_EG}" == "false" ]; then
206+
# To test Knative Serving example
207+
info "Knative Example Test Started"
208+
current_example="custom-resource"
209+
echo "*** Example ${current_example_version}/${current_example} ***";
210+
kubectl delete events -n default --all
211+
apply_files
212+
sleep 60
213+
kubectl get deployment el-custom-resource-listener-00001-deployment -n default
214+
kubectl get deployment el-custom-resource-listener-00001-deployment -n default -o yaml
215+
kubectl get pod -n default
216+
kubectl get pod -n default -l app=el-custom-resource-listener-00001
217+
kubectl get el custom-resource-listener
218+
kubectl get el custom-resource-listener -o yaml
219+
kubectl logs -f deployments/el-custom-resource-listener-00001-deployment -c queue-proxy
220+
kubectl get events
221+
check_eventlistener
222+
curl_knative_service
223+
cleanup
224+
info "Knative Example Test Successful"
225+
fi
214226
done
215227

216228
echo; echo "*** Completed Examples Test Successfully ***"; echo;

test/e2e-tests-yaml.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ main() {
4747
kubectl create namespace getting-started
4848
for op in apply delete;do
4949
for file in $(find ${REPO_ROOT_DIR}/docs/getting-started -name *.yaml | sort); do
50-
kubectl ${op} -f ${file}
50+
if [ "${SKIP_SECURITY_CTX}" == "true" ]; then
51+
yq 'del(.spec.spec.containers[]?.securityContext.runAsUser, .spec.spec.containers[]?.securityContext.runAsGroup)' ${file} | kubectl ${op} -f -
52+
else
53+
kubectl ${op} -f ${file}
54+
fi
5155
done
5256
done
5357
kubectl delete namespace getting-started

test/e2e-tests.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616

1717
# This script calls out to scripts in tektoncd/plumbing to setup a cluster
1818
# and deploy Tekton Pipelines to it for running integration tests.
19+
set -e
1920

2021
source $(dirname $0)/e2e-common.sh
2122
# Script entry point.
2223

2324
# Setting defaults
2425
failed=0
25-
SKIP_INITIALIZE=${SKIP_INITIALIZE:="false"}
26+
export SKIP_INITIALIZE=${SKIP_INITIALIZE:="false"}
27+
export SKIP_SECURITY_CTX=${SKIP_SECURITY_CTX:="false"}
28+
export SKIP_KNATIVE_EG=${SKIP_KNATIVE_EG:="false"}
2629

2730

2831
if [ "${SKIP_INITIALIZE}" != "true" ]; then
@@ -34,18 +37,19 @@ install_pipeline_crd
3437
install_triggers_crd
3538

3639
header "Running yaml tests"
37-
$(dirname $0)/e2e-tests-yaml.sh || failed=1
40+
$(dirname $0)/e2e-tests-yaml.sh || ( failed=1 && echo "failed yaml tests" )
3841

3942
header "Running ingress tests"
40-
$(dirname $0)/e2e-tests-ingress.sh || failed=1
43+
$(dirname $0)/e2e-tests-ingress.sh || ( failed=1 && echo "failed ingress tests" )
4144

4245
# Run the integration tests
4346
header "Running Go e2e tests"
44-
go_test_e2e -timeout=20m ./test || failed=1
45-
go_test_e2e -timeout=20m ./cmd/... || failed=1
47+
go_test_e2e -timeout=20m ./test || ( failed=1 && echo "failed integration tests" )
48+
go_test_e2e -timeout=20m ./cmd/... || ( failed=1 && echo "failed integration tests" )
49+
4650

4751
header "Running examples tests"
48-
$(dirname $0)/e2e-tests-examples.sh || failed=1
52+
$(dirname $0)/e2e-tests-examples.sh || ( failed=1 && echo "failed example tests" )
4953

5054
(( failed )) && fail_test
5155
success

test/eventlistener_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,6 @@ func TestEventListenerCreate(t *testing.T) {
493493
}
494494
}
495495

496-
fmt.Printf("\nel.Spec.Resources.KubernetesResource.ServiceType: %v", el.Spec.Resources.KubernetesResource.ServiceType)
497-
fmt.Printf("\nel.Spec.Resources.KubernetesResource.ServicePort: %v", *el.Spec.Resources.KubernetesResource.ServicePort)
498-
499496
// Send POST request to EventListener sink
500497
var resp *http.Response
501498
if err := WaitFor(func() (bool, error) {

test/presubmit-tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323

2424
# Markdown linting failures don't show up properly in Gubernator resulting
2525
# in a net-negative contributor experience.
26+
set -x
2627
export DISABLE_MD_LINTING=1
2728
export DISABLE_MD_LINK_CHECK=1
2829

2930
source $(dirname $0)/../vendor/github.com/tektoncd/plumbing/scripts/presubmit-tests.sh
3031

32+
go install github.com/jstemmer/go-junit-report/v2@latest
3133

3234
function post_build_tests() {
3335
return_code=0

0 commit comments

Comments
 (0)