Skip to content

Commit

Permalink
Merge tag '2.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremychoi committed Dec 6, 2024
2 parents a5f7b87 + 386fab1 commit 5306abb
Show file tree
Hide file tree
Showing 52 changed files with 3,351 additions and 211 deletions.
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
16 changes: 9 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
language_version: python3
exclude: \.csv$
- id: end-of-file-fixer
- id: debug-statements
language_version: python3

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.0.1
rev: v3.14.0
hooks:
- id: reorder-python-imports
language_version: python3
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.12.1
hooks:
- id: black
args:
Expand All @@ -26,7 +27,7 @@ repos:
require_serial: true

- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0
rev: v2.38.4
hooks:
- id: pyupgrade
language_version: python3
Expand All @@ -37,20 +38,21 @@ 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)
# R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)

- repo: https://github.com/PyCQA/pylint
#rev: v3.0.3
rev: v2.17.4
rev: v2.17.7
hooks:
- id: pylint
exclude: ^tests/
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=o,w,q,f,fp,i,e
- --disable=E0401,W1201,W1203,C0114,C0115,C0116,C0411,W0107,W0511,W0702,R0801,R1705,R1710
language_version: python3
225 changes: 225 additions & 0 deletions .tekton/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
---
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-nessus
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)

- name: copy-nessus-secret
runAfter:
- provision-eaas-space-nessus
taskSpec:
steps:
- name: copy-nessus-secret
image: registry.redhat.io/openshift4/ose-cli:latest
env:
- name: KUBECONFIG
value: /tmp/kubeconfig
- name: EAAS_KUBECONFIG_VALUE
valueFrom:
secretKeyRef:
name: $(tasks.provision-eaas-space-nessus.results.secretRef)
key: kubeconfig
workingDir: /workspace
script: |
#!/bin/bash -ex
# initial request will default to in-cluster k8s config
oc whoami
oc get secret sfowler-nessus-pull-secret -o yaml > /tmp/nessus-pull-secret.yaml
sed '/namespace:/d' /tmp/nessus-pull-secret.yaml > /tmp/new-secret.yaml
# second request should use newly provisioned eaas creds + namespace
echo "$EAAS_KUBECONFIG_VALUE" > "$KUBECONFIG"
oc whoami
oc apply -f /tmp/new-secret.yaml
- 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 integrations tests can't reference Tasks in the same PR AFAICT
# so need to repeat them inline, rather than define in a separate file
- 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
- 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 git
python3.12 -m ensurepip
pip3 install -r requirements.txt -r requirements-dev.txt
pytest -s e2e-tests/test_integration.py --json-report --json-report-summary --json-report-file $(results.TEST_RESULTS.path)
cat $(results.TEST_RESULTS.path)
- name: run-e2e-tests-nessus
runAfter:
- copy-nessus-secret
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-nessus.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
# XXX temp!
oc get secret sfowler-nessus-pull-secret
yum install -y python3.12 git
python3.12 -m ensurepip
pip3 install -r requirements.txt -r requirements-dev.txt
pytest -sv e2e-tests/test_nessus.py --json-report --json-report-summary --json-report-file $(results.TEST_RESULTS.path)
cat $(results.TEST_RESULTS.path)
Loading

0 comments on commit 5306abb

Please sign in to comment.