Skip to content

Commit 7f355ec

Browse files
committed
Add tests for Konflux
Assisted-by: Claude Code
1 parent 8fca2aa commit 7f355ec

File tree

4 files changed

+359
-88
lines changed

4 files changed

+359
-88
lines changed

.github/workflows/gating.yaml

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -91,91 +91,3 @@ jobs:
9191
# * DL3041 - Specify version with dnf install -y <package>-<version>
9292
ignore: DL3041
9393
failure-threshold: warning
94-
95-
image-build:
96-
name: Container Image Build
97-
needs: hadolint
98-
runs-on: ubuntu-latest
99-
env:
100-
IMAGE_NAME: waiverdb
101-
REGISTRY: quay.io/factory2
102-
GH_REGISTRY: ghcr.io/${{ github.actor }}
103-
104-
steps:
105-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
106-
107-
- name: Install uv
108-
uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7
109-
with:
110-
python-version: "3.13"
111-
enable-cache: true
112-
113-
- name: Install system dependencies
114-
uses: nick-invision/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
115-
with:
116-
timeout_minutes: 10
117-
retry_wait_seconds: 30
118-
max_attempts: 3
119-
command: >-
120-
sudo apt-get update
121-
&& sudo apt-get install
122-
libkrb5-dev
123-
libldap2-dev
124-
libsasl2-dev
125-
126-
- name: Update the Application Version
127-
run: |
128-
NEW_VERSION="$(./get-version.sh)"
129-
uv version "$NEW_VERSION"
130-
131-
- name: Get image tag from git branch
132-
run: |
133-
export TAG=$(sed 's/[^0-9a-zA-Z_.-]/__/g' <<< "$GITHUB_REF_NAME") &&
134-
echo "VERSION_TAG=$TAG" >> $GITHUB_ENV
135-
136-
- name: Build Image
137-
id: build-image
138-
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2
139-
with:
140-
image: ${{ env.IMAGE_NAME }}
141-
tags: >-
142-
${{ env.VERSION_TAG }}
143-
${{ github.ref == 'refs/heads/master' && 'latest' || '' }}
144-
${{ github.sha }}
145-
containerfiles: Dockerfile
146-
build-args: |
147-
GITHUB_SHA=${{ github.sha }}
148-
EXPIRES_AFTER=${{ github.ref == 'refs/heads/master' && 'never' || '30d' }}
149-
150-
- name: Log in to the image registry
151-
if: github.event_name == 'push' && github.actor != 'dependabot[bot]'
152-
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # v1
153-
with:
154-
registry: ${{ secrets.REGISTRY_USER && env.REGISTRY || env.GH_REGISTRY }}
155-
username: ${{ secrets.REGISTRY_USER || github.actor }}
156-
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
157-
158-
- name: Push Image
159-
if: github.event_name == 'push' && github.actor != 'dependabot[bot]'
160-
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2
161-
with:
162-
image: ${{ steps.build-image.outputs.image }}
163-
tags: ${{ steps.build-image.outputs.tags }}
164-
registry: ${{ secrets.REGISTRY_USER && env.REGISTRY || env.GH_REGISTRY }}
165-
166-
- name: Install Chromium for functional tests
167-
run: |
168-
sudo apt-get -y update &&
169-
sudo apt-get -y install chromium-browser
170-
171-
- name: Test Image
172-
run: |
173-
.github/run-functional-tests.sh "${{ steps.build-image.outputs.image }}:${{ github.sha }}"
174-
175-
- name: Upload pytest logs
176-
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
177-
if: failure()
178-
with:
179-
name: pytest-logs
180-
path: /tmp/pytest-of-runner/
181-
retention-days: 14
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
apiVersion: tekton.dev/v1
3+
kind: Task
4+
metadata:
5+
name: functional-tests
6+
labels:
7+
app.kubernetes.io/version: "0.1"
8+
annotations:
9+
tekton.dev/pipelines.minVersion: "0.12.1"
10+
tekton.dev/tags: test,functional,integration
11+
spec:
12+
description: >-
13+
Runs functional integration tests for WaiverDB using podman-compose
14+
to orchestrate the application container with PostgreSQL and Keycloak.
15+
16+
params:
17+
- name: IMAGE_URL
18+
description: Fully qualified image name to test
19+
type: string
20+
- name: IMAGE_DIGEST
21+
description: Image digest to test
22+
type: string
23+
- name: SOURCE_ARTIFACT
24+
description: The Trusted Artifact URI pointing to the application source code
25+
type: string
26+
default: ""
27+
28+
results:
29+
- name: TEST_OUTPUT
30+
description: Test output summary
31+
32+
stepTemplate:
33+
env:
34+
- name: IMAGE_URL
35+
value: $(params.IMAGE_URL)
36+
- name: IMAGE_DIGEST
37+
value: $(params.IMAGE_DIGEST)
38+
- name: SOURCE_ARTIFACT
39+
value: $(params.SOURCE_ARTIFACT)
40+
41+
steps:
42+
- name: use-trusted-artifact
43+
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:4e39fb97f4444c2946944482df47b39c5bbc195c54c6560b0647635f553ab23d
44+
args:
45+
- use
46+
- $(params.SOURCE_ARTIFACT)=/var/workdir/source
47+
volumeMounts:
48+
- name: workdir
49+
mountPath: /var/workdir
50+
51+
- name: install-dependencies
52+
image: registry.access.redhat.com/ubi9/ubi:latest
53+
workingDir: /var/workdir/source
54+
script: |
55+
#!/bin/bash
56+
set -euo pipefail
57+
58+
echo "Installing system dependencies..."
59+
dnf install -y \
60+
chromium \
61+
python3.13 \
62+
python3.13-pip \
63+
podman \
64+
git
65+
66+
# Install uv for Python package management
67+
curl -LsSf https://astral.sh/uv/install.sh | sh
68+
export PATH="/root/.local/bin:$PATH"
69+
70+
echo "Dependencies installed successfully"
71+
volumeMounts:
72+
- name: workdir
73+
mountPath: /var/workdir
74+
securityContext:
75+
runAsUser: 0
76+
77+
- name: run-functional-tests
78+
image: registry.access.redhat.com/ubi9/ubi:latest
79+
workingDir: /var/workdir/source
80+
script: |
81+
#!/bin/bash
82+
set -euo pipefail
83+
84+
export PATH="/root/.local/bin:$PATH"
85+
86+
# Use the built image for testing
87+
IMAGE_WITH_DIGEST="${IMAGE_URL}@${IMAGE_DIGEST}"
88+
echo "Testing image: ${IMAGE_WITH_DIGEST}"
89+
90+
# Update docker-compose.yml to use the built image
91+
sed -i "s| build: .*| image: ${IMAGE_WITH_DIGEST}|" docker-compose.yml
92+
echo "Updated docker-compose.yml:"
93+
grep -E " image:| build: " docker-compose.yml
94+
95+
# Setup cleanup trap
96+
cleanup() {
97+
echo "Cleaning up containers..."
98+
uvx --with podman-compose podman-compose down || true
99+
}
100+
trap cleanup EXIT
101+
102+
# Pull required images
103+
echo "Pulling images with podman-compose..."
104+
uvx --with podman-compose podman-compose --verbose pull
105+
106+
# Start services
107+
echo "Starting services with podman-compose..."
108+
uvx --with podman-compose podman-compose --verbose up --no-build -d
109+
110+
# Run functional tests
111+
echo "Running functional tests..."
112+
uvx --with tox-uv tox -e functional -- --driver=Chrome
113+
114+
echo "Functional tests completed successfully"
115+
volumeMounts:
116+
- name: workdir
117+
mountPath: /var/workdir
118+
securityContext:
119+
runAsUser: 0
120+
# Required for podman to create containers
121+
privileged: true
122+
123+
volumes:
124+
- name: workdir
125+
emptyDir: {}

.tekton/waiverdb-pull-request.yaml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,122 @@ spec:
539539
operator: in
540540
values:
541541
- "false"
542+
- name: functional-tests
543+
params:
544+
- name: IMAGE_URL
545+
value: $(tasks.build-image-index.results.IMAGE_URL)
546+
- name: IMAGE_DIGEST
547+
value: $(tasks.build-image-index.results.IMAGE_DIGEST)
548+
- name: SOURCE_ARTIFACT
549+
value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
550+
runAfter:
551+
- build-image-index
552+
taskSpec:
553+
params:
554+
- name: IMAGE_URL
555+
type: string
556+
- name: IMAGE_DIGEST
557+
type: string
558+
- name: SOURCE_ARTIFACT
559+
type: string
560+
default: ""
561+
results:
562+
- name: TEST_OUTPUT
563+
description: Test output summary
564+
stepTemplate:
565+
env:
566+
- name: IMAGE_URL
567+
value: $(params.IMAGE_URL)
568+
- name: IMAGE_DIGEST
569+
value: $(params.IMAGE_DIGEST)
570+
- name: SOURCE_ARTIFACT
571+
value: $(params.SOURCE_ARTIFACT)
572+
steps:
573+
- name: use-trusted-artifact
574+
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:9b180776a41d9a22a1c51539f1647c60defbbd55b44bbebdd4130e33512d8b0d
575+
args:
576+
- use
577+
- $(params.SOURCE_ARTIFACT)=/var/workdir/source
578+
volumeMounts:
579+
- name: workdir
580+
mountPath: /var/workdir
581+
- name: install-dependencies
582+
image: registry.access.redhat.com/ubi9/ubi:latest
583+
workingDir: /var/workdir/source
584+
script: |
585+
#!/bin/bash
586+
set -euo pipefail
587+
588+
echo "Installing system dependencies..."
589+
dnf install -y \
590+
chromium \
591+
python3.13 \
592+
python3.13-pip \
593+
podman \
594+
git
595+
596+
# Install uv for Python package management
597+
curl -LsSf https://astral.sh/uv/install.sh | sh
598+
export PATH="/root/.local/bin:$PATH"
599+
600+
echo "Dependencies installed successfully"
601+
volumeMounts:
602+
- name: workdir
603+
mountPath: /var/workdir
604+
securityContext:
605+
runAsUser: 0
606+
- name: run-functional-tests
607+
image: registry.access.redhat.com/ubi9/ubi:latest
608+
workingDir: /var/workdir/source
609+
script: |
610+
#!/bin/bash
611+
set -euo pipefail
612+
613+
export PATH="/root/.local/bin:$PATH"
614+
615+
# Use the built image for testing
616+
IMAGE_WITH_DIGEST="${IMAGE_URL}@${IMAGE_DIGEST}"
617+
echo "Testing image: ${IMAGE_WITH_DIGEST}"
618+
619+
# Update docker-compose.yml to use the built image
620+
sed -i "s| build: .*| image: ${IMAGE_WITH_DIGEST}|" docker-compose.yml
621+
echo "Updated docker-compose.yml:"
622+
grep -E " image:| build: " docker-compose.yml
623+
624+
# Setup cleanup trap
625+
cleanup() {
626+
echo "Cleaning up containers..."
627+
uvx --with podman-compose podman-compose down || true
628+
}
629+
trap cleanup EXIT
630+
631+
# Pull required images
632+
echo "Pulling images with podman-compose..."
633+
uvx --with podman-compose podman-compose --verbose pull
634+
635+
# Start services
636+
echo "Starting services with podman-compose..."
637+
uvx --with podman-compose podman-compose --verbose up --no-build -d
638+
639+
# Run functional tests
640+
echo "Running functional tests..."
641+
uvx --with tox-uv tox -e functional -- --driver=Chrome
642+
643+
echo "Functional tests completed successfully"
644+
volumeMounts:
645+
- name: workdir
646+
mountPath: /var/workdir
647+
securityContext:
648+
runAsUser: 0
649+
privileged: true
650+
volumes:
651+
- name: workdir
652+
emptyDir: {}
653+
when:
654+
- input: $(params.skip-checks)
655+
operator: in
656+
values:
657+
- "false"
542658
- name: apply-tags
543659
params:
544660
- name: IMAGE_URL
@@ -554,6 +670,7 @@ spec:
554670
- rpms-signature-scan
555671
- sast-shell-check
556672
- sast-unicode-check
673+
- functional-tests
557674
- build-image-index
558675
taskRef:
559676
params:

0 commit comments

Comments
 (0)