Skip to content

Commit

Permalink
Merge pull request #331 from xinredhat/RHTAP-3343
Browse files Browse the repository at this point in the history
run nested e2e pipelines from fork/branch
  • Loading branch information
xinredhat authored Dec 3, 2024
2 parents bb00020 + f89e5f7 commit e5025f8
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions integration-tests/pipelines/e2e-main-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@ spec:
value: $(tasks.test-metadata.results.job-spec)
script: |
#!/usr/bin/env bash
FORK=$(jq -r '.git.source_repo_org' <<< $JOB_SPEC)
BRANCH=$(jq -r '.git.source_repo_branch' <<< $JOB_SPEC)
curl -o $(results.pict-file.path) https://raw.githubusercontent.com/$FORK/rhtap-cli/refs/heads/$BRANCH/integration-tests/pict-models/default.pict
GIT_REPO="$(jq -r '.git.repo // empty' <<< $JOB_SPEC)"
if [[ "${GIT_REPO}" = "rhtap-cli" ]]; then
REPO_ORG=$(jq -r '.git.source_repo_org' <<< $JOB_SPEC)
BRANCH=$(jq -r '.git.source_repo_branch' <<< $JOB_SPEC)
else
REPO_ORG="redhat-appstudio"
BRANCH="main"
fi
curl -o $(results.pict-file.path) https://raw.githubusercontent.com/$REPO_ORG/rhtap-cli/refs/heads/$BRANCH/integration-tests/pict-models/default.pict
- name: generate-configs
runAfter:
- get-pict-file
Expand Down Expand Up @@ -82,22 +89,42 @@ spec:
value: $(tasks.test-metadata.results.job-spec)
- name: CONFIGS_JSON
value: $(tasks.generate-configs.results.configs-json)
- name: KONFLUX_APPLICATION_NAME
valueFrom:
fieldRef:
fieldPath: metadata.labels['appstudio.openshift.io/application']
- name: KONFLUX_COMPONENT_NAME
valueFrom:
fieldRef:
fieldPath: metadata.labels['appstudio.openshift.io/component']
script: |
#!/usr/bin/env bash
set -x
set -euxo pipefail
GIT_REPO="$(jq -r '.git.repo // empty' <<< $JOB_SPEC)"
if [[ "${GIT_REPO}" = "rhtap-cli" ]]; then
REPO_ORG=$(jq -r '.git.source_repo_org' <<< $JOB_SPEC)
BRANCH=$(jq -r '.git.source_repo_branch' <<< $JOB_SPEC)
else
REPO_ORG="redhat-appstudio"
BRANCH="main"
fi
echo "Running tests for OCP versions:"
echo "$CONFIGS_JSON" | jq -r '.[][] | select(.key == "OCP").value'
pids=()
while IFS= read -r version; do
(
pipeline_run_name=$(tkn pipeline start -f https://raw.githubusercontent.com/redhat-appstudio/rhtap-cli/refs/heads/main/integration-tests/pipelines/rhtap-cli-e2e.yaml \
pipeline_run_name=$(tkn pipeline start -f https://raw.githubusercontent.com/$REPO_ORG/rhtap-cli/refs/heads/$BRANCH/integration-tests/pipelines/rhtap-cli-e2e.yaml \
--param ocp-version="$version"\
--param job-spec="$JOB_SPEC"\
--param konflux-test-infra-secret="$(params.konflux-test-infra-secret)" \
--use-param-defaults \
--labels "appstudio.openshift.io/component=rhtap-cli" \
--labels "appstudio.openshift.io/application=rhtap-cli" \
--labels "appstudio.openshift.io/component=${KONFLUX_COMPONENT_NAME}" \
--labels "appstudio.openshift.io/application=${KONFLUX_APPLICATION_NAME}" \
--labels "pipelines.appstudio.openshift.io/type=$(context.pipelineRun.name)" \
--labels "test.appstudio.openshift.io/scenario=pr-e2e-tests" \
--prefix-name "e2e-$version"\
Expand All @@ -114,11 +141,12 @@ spec:
) &
pid="$!"
pids+=("$pid")
done < <(echo "$CONFIGS_JSON" | jq -r '.[][] | select(.key == "OCP").value');
done < <(echo "$CONFIGS_JSON" | jq -r '.[][] | select(.key == "OCP").value')
for pid in "${pids[@]}"; do
wait "$pid"
return_code=$?
if [ ! $return_code -eq 0 ]; then
if [ $return_code -ne 0 ]; then
echo "One or more pipelineruns failed. Exiting with non-zero code."
oc get pipelineruns
exit 1
Expand Down

0 comments on commit e5025f8

Please sign in to comment.