-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(RELEASE-1239): print pipeline ref info (#636)
- collect, print and record info about git resolver metadata for running pipeline. - data can be obtained from the result 'releasePipelineMetadata' - an example of usage of this data can be seen here: https://shorturl.at/cyPTD Signed-off-by: Martin Malina <[email protected]> Signed-off-by: Scott Hebert <[email protected]>
- Loading branch information
Showing
6 changed files
with
419 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
set -eux | ||
|
||
# mocks to be injected into task step scripts | ||
curl() { | ||
# Output the call to stderr | ||
echo "Mock curl called with:" "$@" >&2 | ||
echo "$@" >> "$(workspaces.data.path)/mock_curl.txt" | ||
echo '{ "sha": "12345"}' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 179 additions & 0 deletions
179
tasks/collect-data/tests/test-collect-data-print-pipeline-ref-nongit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
name: test-collect-data-print-pipeline-ref-nongit | ||
spec: | ||
description: | | ||
Run the collect-data task and verify that the pipeline ref info is not available when not using a | ||
git resolver | ||
workspaces: | ||
- name: tests-workspace | ||
tasks: | ||
- name: setup | ||
taskSpec: | ||
steps: | ||
- name: create-crs | ||
image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
script: | | ||
#!/usr/bin/env bash | ||
set -eux | ||
cat > release << EOF | ||
apiVersion: appstudio.redhat.com/v1alpha1 | ||
kind: Release | ||
metadata: | ||
name: release-sample | ||
namespace: default | ||
spec: | ||
snapshot: foo | ||
releasePlan: foo | ||
EOF | ||
kubectl apply -f release | ||
cat > releaseplan << EOF | ||
apiVersion: appstudio.redhat.com/v1alpha1 | ||
kind: ReleasePlan | ||
metadata: | ||
name: releaseplan-sample | ||
namespace: default | ||
spec: | ||
application: foo | ||
target: foo | ||
EOF | ||
kubectl apply -f releaseplan | ||
cat > releaseplanadmission << EOF | ||
apiVersion: appstudio.redhat.com/v1alpha1 | ||
kind: ReleasePlanAdmission | ||
metadata: | ||
name: releaseplanadmission-sample | ||
namespace: default | ||
spec: | ||
applications: | ||
- foo | ||
origin: foo | ||
data: | ||
singleComponentMode: true | ||
one: | ||
two: three | ||
four: | ||
- five | ||
- six | ||
policy: foo | ||
pipeline: | ||
pipelineRef: | ||
resolver: cluster | ||
params: | ||
- name: name | ||
value: release-pipeline | ||
- name: namespace | ||
value: default | ||
- name: kind | ||
value: pipeline | ||
EOF | ||
kubectl apply -f releaseplanadmission | ||
cat > releaseserviceconfig << EOF | ||
apiVersion: appstudio.redhat.com/v1alpha1 | ||
kind: ReleaseServiceConfig | ||
metadata: | ||
name: releaseserviceconfig-sample | ||
namespace: default | ||
spec: | ||
EOF | ||
kubectl apply -f releaseserviceconfig | ||
cat > snapshot << EOF | ||
apiVersion: appstudio.redhat.com/v1alpha1 | ||
kind: Snapshot | ||
metadata: | ||
name: snapshot-sample | ||
namespace: default | ||
spec: | ||
application: foo | ||
components: | ||
- name: name | ||
containerImage: newimage | ||
EOF | ||
kubectl apply -f snapshot | ||
- name: run-task | ||
taskRef: | ||
name: collect-data | ||
params: | ||
- name: release | ||
value: default/release-sample | ||
- name: releasePlan | ||
value: default/releaseplan-sample | ||
- name: releasePlanAdmission | ||
value: default/releaseplanadmission-sample | ||
- name: releaseServiceConfig | ||
value: default/releaseserviceconfig-sample | ||
- name: snapshot | ||
value: default/snapshot-sample | ||
- name: subdirectory | ||
value: $(context.pipelineRun.uid) | ||
runAfter: | ||
- setup | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
- name: check-result | ||
params: | ||
- name: releasePipelineMetadata | ||
value: "$(tasks.run-task.results.releasePipelineMetadata)" | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
runAfter: | ||
- run-task | ||
taskSpec: | ||
params: | ||
- name: releasePipelineMetadata | ||
type: string | ||
workspaces: | ||
- name: data | ||
steps: | ||
- name: check-result | ||
image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
env: | ||
- name: PIPELINE_METADATA | ||
value: '$(params.releasePipelineMetadata)' | ||
script: | | ||
#!/usr/bin/env bash | ||
set -eux | ||
touch "$(workspaces.data.path)/mock_curl.txt" | ||
if [ "$(wc -l < "$(workspaces.data.path)/mock_curl.txt")" != 0 ]; then | ||
echo Error: curl was expected to be called 0 times. Actual calls: | ||
cat "$(workspaces.data.path)/mock_curl.txt" | ||
exit 1 | ||
fi | ||
org=$(jq -r '.org' <<< "$PIPELINE_METADATA") | ||
repo=$(jq -r '.repo' <<< "$PIPELINE_METADATA") | ||
revision=$(jq -r '.revision' <<< "$PIPELINE_METADATA") | ||
pathinrepo=$(jq -r '.pathinrepo' <<< "$PIPELINE_METADATA") | ||
sha=$(jq -r '.sha' <<< "$PIPELINE_METADATA") | ||
test "${org}" == 'unknown' | ||
test "${repo}" == 'unknown' | ||
test "${revision}" == 'unknown' | ||
test "${pathinrepo}" == 'unknown' | ||
test "${sha}" == 'unknown' | ||
finally: | ||
- name: cleanup | ||
taskSpec: | ||
steps: | ||
- name: delete-crs | ||
image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
script: | | ||
#!/usr/bin/env sh | ||
set -eux | ||
kubectl delete release release-sample | ||
kubectl delete releaseplan releaseplan-sample | ||
kubectl delete releaseplanadmission releaseplanadmission-sample | ||
kubectl delete releaseserviceconfig releaseserviceconfig-sample | ||
kubectl delete snapshot snapshot-sample |
Oops, something went wrong.