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

Konflux onboard e2e #239

Merged
merged 10 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
41 changes: 0 additions & 41 deletions .github/workflows/build-and-push.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/build-image.yml

This file was deleted.

23 changes: 18 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ permissions:
contents: read

jobs:
test:

lint:
runs-on: ubuntu-latest

steps:
Expand All @@ -24,9 +23,23 @@ jobs:
run: |
python3 -m ensurepip --upgrade
pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
- name: Test with pytest
run: |
pytest
- name: Lint with pre-commit hook
run: |
pre-commit run --all-files --show-diff-on-failure

unit-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install dependencies
run: |
python3 -m ensurepip --upgrade
pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
- name: Test with pytest
run: |
pytest tests
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ repos:
# W0603 - Using the global statement
# C0114,C0115,C0116 - docstring checks. Disabled because of pydocstyle checks
# W0107 - unnecessary pass
# W0511: fixme
# W0702: No exception type(s) specified (bare-except)
# R0801: Similar lines in 2 files. Disabled because it flags any file even those which are unrelated
# R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
Expand All @@ -51,6 +52,6 @@ repos:
args:
- --max-line-length=120
- --min-public-methods=0
- --good-names=q,f,fp,i,e
- --disable=E0401,W1201,W1203,C0114,C0115,C0116,C0411,W0107,W0702,R0801,R1705,R1710
- --good-names=w,q,f,fp,i,e
- --disable=E0401,W1201,W1203,C0114,C0115,C0116,C0411,W0107,W0511,W0702,R0801,R1705,R1710
language_version: python3
135 changes: 135 additions & 0 deletions .tekton/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: rapidast-e2e
spec:
params:
- name: repo_url
default: github.com/RedHatProductSecurity/rapidast
- name: revision
default: "development"
- description: 'Snapshot of the application'
name: SNAPSHOT
default: |-
'{
"components": [
{
"name":"rapidast",
"containerImage": "quay.io/redhatproductsecurity/rapidast:latest",
"source":{
"git":{
"url":"[email protected]:RedHatProductSecurity/rapidast.git",
"revision":"development",
}
}
}
]
}'
type: string

tasks:
- name: parse-metadata
taskRef:
resolver: git
params:
- name: url
value: https://github.com/konflux-ci/integration-examples
- name: revision
value: main
- name: pathInRepo
value: tasks/test_metadata.yaml
params:
- name: SNAPSHOT
value: $(params.SNAPSHOT)

- name: provision-eaas-space
runAfter:
- parse-metadata
taskRef:
resolver: git
params:
- name: url
value: https://github.com/konflux-ci/build-definitions.git
- name: revision
value: main
- name: pathInRepo
value: task/provision-env-with-ephemeral-namespace/0.1/provision-env-with-ephemeral-namespace.yaml
params:
- name: KONFLUXNAMESPACE
value: $(context.pipelineRun.namespace)
- name: PIPELINERUN_NAME
value: $(context.pipelineRun.name)
- name: PIPELINERUN_UID
value: $(context.pipelineRun.uid)

# XXX not supported to use workspaces in integration tests:
# * https://issues.redhat.com/browse/STONEINTG-895
#
# - name: clone-repository
# runAfter:
# - parse-metadata
# params:
# - name: url
# value: "$(tasks.parse-metadata.results.source-git-url)"
# - name: revision
# value: "$(tasks.parse-metadata.results.source-git-revision)"
# taskRef:
# name: git-clone
# workspaces:
# - name: output
# workspace: source

- name: run-e2e-tests
runAfter:
- provision-eaas-space
taskSpec:
volumes:
- name: credentials
emptyDir: {}
results:
- name: TEST_RESULTS
description: e2e test results
steps:

# XXX not supported to use workspaces in integration tests:
# * https://issues.redhat.com/browse/STONEINTG-895
- name: clone-repository
image: quay.io/konflux-ci/git-clone:latest
script: |
git config --global --add safe.directory /workspace
git clone "$(tasks.parse-metadata.results.source-git-url)" /workspace
pushd /workspace
git checkout "$(tasks.parse-metadata.results.source-git-revision)"

- name: test
image: registry.redhat.io/openshift4/ose-cli:latest
env:
- name: KUBECONFIG
value: /tmp/kubeconfig
- name: KUBECONFIG_VALUE
valueFrom:
secretKeyRef:
name: $(tasks.provision-eaas-space.results.secretRef)
key: kubeconfig
- name: RAPIDAST_CLEANUP
value: "false" # namespace will be cleaned up automatically
- name: RAPIDAST_IMAGE
value: $(tasks.parse-metadata.results.component-container-image)
- name: RAPIDAST_SERVICEACCOUNT
value: namespace-manager # created by provision-env-with-ephemeral-namespace
workingDir: /workspace
volumeMounts:
- name: credentials
mountPath: /credentials
script: |
#!/bin/bash -ex

echo "$KUBECONFIG_VALUE" > "$KUBECONFIG"
oc whoami

yum install -y python3.12
python3.12 -m ensurepip
pip3 install -r requirements.txt -r requirements-dev.txt
pytest -s e2e-tests --json-report --json-report-summary --json-report-file $(results.TEST_RESULTS.path)
cat $(results.TEST_RESULTS.path)
Loading
Loading