-
Notifications
You must be signed in to change notification settings - Fork 133
fix(KFLUXSPRT-8173): use taskGitRevision SHA for pipeline metadata #2314
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
Draft
seanconroy2021
wants to merge
1
commit into
konflux-ci:development
Choose a base branch
from
seanconroy2021:KFLUXSPRT-8173
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+510
−6
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
246 changes: 246 additions & 0 deletions
246
tasks/managed/collect-data/tests/test-collect-data-print-pipeline-ref-api-fail.yaml
This file contains hidden or 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,246 @@ | ||
| --- | ||
| apiVersion: tekton.dev/v1 | ||
| kind: Pipeline | ||
| metadata: | ||
| name: test-collect-data-print-pipeline-ref-api-fail | ||
| spec: | ||
| description: | | ||
| Run the collect-data task with a non-SHA taskGitRevision and a failing GitHub API call, | ||
| verify that the task does not fail and sha defaults to unknown | ||
| params: | ||
| - name: ociStorage | ||
| description: The OCI repository where the Trusted Artifacts are stored. | ||
| type: string | ||
| - name: ociArtifactExpiresAfter | ||
| description: Expiration date for the trusted artifacts created in the | ||
| OCI repository. An empty string means the artifacts do not expire. | ||
| type: string | ||
| default: "1d" | ||
| - name: orasOptions | ||
| description: oras options to pass to Trusted Artifacts calls | ||
| type: string | ||
| default: "--insecure" | ||
| - name: trustedArtifactsDebug | ||
| description: Flag to enable debug logging in trusted artifacts. Set to a non-empty string to enable. | ||
| type: string | ||
| default: "" | ||
| - name: dataDir | ||
| description: The location where data will be stored | ||
| type: string | ||
| tasks: | ||
| - name: setup | ||
| taskSpec: | ||
| volumes: | ||
| - name: workdir | ||
| emptyDir: {} | ||
| stepTemplate: | ||
| volumeMounts: | ||
| - mountPath: /var/workdir | ||
| name: workdir | ||
| env: | ||
| - name: IMAGE_EXPIRES_AFTER | ||
| value: $(params.ociArtifactExpiresAfter) | ||
| - name: "ORAS_OPTIONS" | ||
| value: "$(params.orasOptions)" | ||
| - name: "DEBUG" | ||
| value: "$(params.trustedArtifactsDebug)" | ||
| steps: | ||
| - name: create-crs | ||
| image: quay.io/konflux-ci/release-service-utils@sha256:440c27f13adab931460a9371df82d3757b77f7ccc1b7604d737e0c78760a95c9 | ||
| script: | | ||
| #!/usr/bin/env bash | ||
| set -eux | ||
|
|
||
| mkdir -p "$(params.dataDir)/$(context.pipelineRun.uid)" | ||
| cd "$(params.dataDir)/$(context.pipelineRun.uid)" | ||
| 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 | ||
| policy: foo | ||
| pipeline: | ||
| pipelineRef: | ||
| params: | ||
| - name: url | ||
| value: 'https://github.com/fail-catalog/some-service-catalog.git' | ||
| - name: revision | ||
| value: development | ||
| - name: pathInRepo | ||
| value: pipelines/rh-advisories/rh-advisories.yaml | ||
| resolver: git | ||
| serviceAccountName: release-service-account | ||
| timeouts: | ||
| pipeline: 5h0m0s | ||
| 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) | ||
| - name: orasOptions | ||
| value: $(params.orasOptions) | ||
| - name: ociStorage | ||
| value: $(params.ociStorage) | ||
| - name: dataDir | ||
| value: $(params.dataDir) | ||
| - name: trustedArtifactsDebug | ||
| value: $(params.trustedArtifactsDebug) | ||
| - name: taskGitUrl | ||
| value: "http://localhost" | ||
| - name: taskGitRevision | ||
| value: "development" | ||
| runAfter: | ||
| - setup | ||
| - name: check-result | ||
| params: | ||
| - name: releasePipelineMetadata | ||
| value: "$(tasks.run-task.results.releasePipelineMetadata)" | ||
| - name: sourceDataArtifact | ||
| value: "$(tasks.run-task.results.sourceDataArtifact)=$(params.dataDir)" | ||
| - name: subdirectory | ||
| value: $(tasks.run-task.results.subdirectory) | ||
| - name: dataDir | ||
| value: $(params.dataDir) | ||
| runAfter: | ||
| - run-task | ||
| taskSpec: | ||
| params: | ||
| - name: releasePipelineMetadata | ||
| type: string | ||
| - name: subdirectory | ||
| type: string | ||
| - name: sourceDataArtifact | ||
| type: string | ||
| - name: dataDir | ||
| type: string | ||
| volumes: | ||
| - name: workdir | ||
| emptyDir: {} | ||
| stepTemplate: | ||
| volumeMounts: | ||
| - mountPath: /var/workdir | ||
| name: workdir | ||
| env: | ||
| - name: IMAGE_EXPIRES_AFTER | ||
| value: $(params.ociArtifactExpiresAfter) | ||
| - name: "ORAS_OPTIONS" | ||
| value: "$(params.orasOptions)" | ||
| - name: "DEBUG" | ||
| value: "$(params.trustedArtifactsDebug)" | ||
| steps: | ||
| - name: use-trusted-artifact | ||
| ref: | ||
| name: use-trusted-artifact | ||
| params: | ||
| - name: workDir | ||
| value: $(params.dataDir) | ||
| - name: sourceDataArtifact | ||
| value: $(params.sourceDataArtifact) | ||
| - name: check-result | ||
| image: quay.io/konflux-ci/release-service-utils@sha256:440c27f13adab931460a9371df82d3757b77f7ccc1b7604d737e0c78760a95c9 | ||
| env: | ||
| - name: PIPELINE_METADATA | ||
| value: '$(params.releasePipelineMetadata)' | ||
| script: | | ||
| #!/usr/bin/env bash | ||
| set -eux | ||
|
|
||
| if [ "$(wc -l < "$(params.dataDir)/mock_curl.txt")" != 1 ]; then | ||
| echo Error: curl-with-retry was expected to be called 1 time. Actual calls: | ||
| cat "$(params.dataDir)/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}" == 'fail-catalog' | ||
| test "${repo}" == 'some-service-catalog' | ||
| test "${revision}" == 'development' | ||
| test "${pathinrepo}" == 'pipelines/rh-advisories/rh-advisories.yaml' | ||
| test "${sha}" == 'unknown' | ||
|
|
||
| finally: | ||
| - name: cleanup | ||
| taskSpec: | ||
| steps: | ||
| - name: delete-crs | ||
| image: quay.io/konflux-ci/release-service-utils@sha256:440c27f13adab931460a9371df82d3757b77f7ccc1b7604d737e0c78760a95c9 | ||
| 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.