Skip to content
Draft
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
65 changes: 63 additions & 2 deletions .tekton/on-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:

# The branch or tag we are targeting (ie: main, refs/tags/*)
pipelinesascode.tekton.dev/on-target-branch: "[main, rh-main]"
# The path we are targeting to build the image
# Paths that trigger the pipeline on change
pipelinesascode.tekton.dev/on-path-change: "[src/**, metrics_lib/**, requirements.yaml, pyproject.toml, Dockerfile, docker/**, .dockerignore]"
# Fetch the git-clone task from hub, we are able to reference later on it
# with taskRef and it will automatically be embedded into our pipeline.
Expand All @@ -26,6 +26,8 @@ spec:
value: "{{ repo_url }}"
- name: revision
value: "{{ revision }}"
- name: skip-integration-test
value: "false"
- name: image-expires-after
value: 5d
- name: output-image
Expand All @@ -38,6 +40,9 @@ spec:
params:
- name: repo_url
- name: revision
- name: skip-integration-test
default: "false"
type: string
- name: output-image
description: Fully Qualified Output Image
type: string
Expand Down Expand Up @@ -146,7 +151,9 @@ spec:
value: "ignore"
- name: AGENT_MORPHEUS_TRACING_ENABLED
value: "false"
image: docker.io/condaforge/miniforge3:latest
- name: LANGCHAIN_TRACING_V2
value: "false"
image: docker.io/condaforge/miniforge3@sha256:f1f537ff80646e3aaf84e64abf6249cdc3f20889aa0a8d41535e62925c959f64
workingDir: $(workspaces.source.path)
volumeMounts:
- name: env-file-volume
Expand Down Expand Up @@ -202,6 +209,60 @@ spec:
make test-unit

print_banner "LINT AND TEST COMPLETE"
- name: set-image-in-kustomize
runAfter:
- buildah-pvc
when:
- input: "$(params.skip-integration-test)"
operator: notin
values: ["true"]
workspaces:
- name: source
workspace: source
params:
- name: IMAGE_URL
value: $(params.output-image)
- name: KUSTOMIZE_PATH
value: kustomize/overlays/developer
taskSpec:
workspaces:
- name: source
params:
- name: IMAGE_URL
- name: KUSTOMIZE_PATH
steps:
- name: set-image
image: registry.k8s.io/kustomize/kustomize:v5.0.1
workingDir: $(workspaces.source.path)
script: |
#!/bin/sh
set -ex
# Edit the kustomization file to use the newly built image for the integration test.
# The image name 'agent-morpheus-rh' is derived from the deployment name in the test script.
cd $(params.KUSTOMIZE_PATH)
kustomize edit set image agent-morpheus-rh=$(params.IMAGE_URL)
- name: integration-test
taskRef:
resolver: cluster
params:
- name: kind
value: task
- name: name
value: agent-morpheus-integration-test
- name: namespace
value: ruben-morpheus
runAfter:
- set-image-in-kustomize
workspaces:
- name: source
workspace: source
params:
- name: pr-number
value: "{{ pull_request_number }}"
when:
- input: "$(params.skip-integration-test)"
operator: notin
values: ["true"]
workspaces:
- name: source
volumeClaimTemplate:
Expand Down
67 changes: 67 additions & 0 deletions .tekton/tasks/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: agent-morpheus-integration-test
spec:
description: >-
Runs the end-to-end integration test for the Agent Morpheus application.
This task executes the main test script which handles setup, deployment,
testing, and cleanup.

params:
- name: pr-number
description: "Pull Request number, used to create a unique temporary namespace."
type: string
- name: verbose
description: "If set to true, enables verbose debug logging in the task script."
type: string
default: "false"

workspaces:
- name: source
description: "The workspace containing the application's source code."

stepTemplate:
env:
- name: PR_NUMBER
value: "$(params.pr-number)"
- name: SOURCE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: AGENT_MORPHEUS_TRACING_ENABLED
value: "false"
- name: LANGCHAIN_TRACING_V2
value: "false"
- name: VERBOSE
value: "$(params.verbose)"

steps:
- name: run-integration-test
image: quay.io/openshift/origin-cli:latest
workingDir: "$(workspaces.source.path)"
script: |
#!/bin/bash
set -euo pipefail

main() {
readonly TEST_SCRIPT_PATH="e2e/run-integration-test.sh"

echo "--- [ Running Integration Test Script: ${TEST_SCRIPT_PATH} ] ---"

if [[ ! -f "${TEST_SCRIPT_PATH}" ]]; then
echo "Error: Test script not found at ${TEST_SCRIPT_PATH}" >&2

# Only show debug info if the debug mode is enabled.
if [[ "${VERBOSE:-false}" == "true" ]]; then
echo "Current directory contents (debug mode):" >&2
ls -lah
fi
exit 1
fi

chmod +x "${TEST_SCRIPT_PATH}"
exec "${TEST_SCRIPT_PATH}" "$@"
}

main "$@"
42 changes: 42 additions & 0 deletions .tekton/tasks/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: namespace-manager
rules:
- apiGroups: ["project.openshift.io"]
resources: ["projects", "projectrequests"]
verbs: ["create", "delete", "get", "list"]
- apiGroups: [""]
resources: ["namespaces"]
verbs: ["create", "delete", "get", "list"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list", "create", "update", "patch"]
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list", "create", "update", "patch", "delete"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "create", "update", "patch", "delete"]
- apiGroups: [""]
resources: ["services"]
verbs: ["get", "list", "create", "update", "patch", "delete"]
- apiGroups: ["rbac.authorization.k8s.io"]
resources: ["rolebindings"]
verbs: ["get", "list", "create", "update", "patch", "delete"]
- apiGroups: ["monitoring.coreos.com"]
resources: ["servicemonitors"]
verbs: ["get", "list", "create", "update", "patch", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: pipeline-namespace-manager
subjects:
- kind: ServiceAccount
name: pipeline
namespace: ruben-morpheus
roleRef:
kind: ClusterRole
name: namespace-manager
apiGroup: rbac.authorization.k8s.io
Loading