Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests to uhc-auth-proxy build pipeline #88

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .tekton/uhc-auth-proxy-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,74 @@ spec:
workspaces:
- name: basic-auth
workspace: git-auth
#unit tests
- name: clone-repository-oci-ta
params:
- name: url
value: $(params.git-url)
- name: revision
value: $(params.revision)
- name: ociStorage
# needs to be unique storage name
value: $(params.output-image).git
runAfter:
- init
taskRef:
params:
- name: name
value: git-clone-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-git-clone-oci-ta@sha256:0f4360ce144d46171ebd2e8f4d4575539a0600e02208ba5fc9beeb2c27ddfd4c
- name: kind
value: task
resolver: bundles
workspaces:
# use the git-auth workspace for credentials
- name: basic-auth
workspace: git-auth
- name: task-running-unit-tasks
# make sure the task runs after the artifact is created
runAfter:
- clone-repository-oci-ta
params:
# store the trusted artifact
- name: SOURCE_ARTIFACT
value: $(tasks.clone-repository-oci-ta.results.SOURCE_ARTIFACT)
taskSpec:
params:
- description: The Trusted Artifact URI pointing to the artifact with the application source code.
name: SOURCE_ARTIFACT
type: string
volumes:
# New volume to store a copy of the source code accessible only to this Task.
- name: workdir
emptyDir: {}
stepTemplate:
volumeMounts:
- mountPath: /var/workdir
name: workdir
steps:
# Add the trusted artifact to the task volume
- name: use-trusted-artifact
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:8391272c4e5011120e9e7fee2c1f339e9405366110bf239dadcbc21e953ce099
args:
- use
- $(params.SOURCE_ARTIFACT)=/var/workdir/source
- name: task-run
# set the working directory to value from previous step
workingDir: /var/workdir/source
# Use image that suites your use case
image: registry.access.redhat.com/ubi8/go-toolset:latest
securityContext:
# If the task step needs write access to the volume, set the runAsUser to 0 (root).
runAsUser: 0
script: |
#!/bin/bash
set -ex
# Execute the task
echo "Run unit tests"
bash konflux_unit_test.sh

- name: prefetch-dependencies
params:
- name: input
Expand Down
14 changes: 14 additions & 0 deletions konflux_unit_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -exv

export GO111MODULE="on"
go test -v -race --coverprofile=coverage.txt --covermode=atomic ./...
result=$?

if [ $result -ne 0 ]; then
echo '====================================='
echo '==== ✖ ERROR: UNIT TEST FAILED ===='
echo '====================================='
exit 1
fi