-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse prefetched pip dependencies in Konflux integration tests (#308)
* Add Tekton task for prefetching dependencies - Adds `prefetch-get-refs` Tekton task to retrieve prefetched dependencies - Integrates the task into the run-e2e-tests integration test pipeline - Integrates the task into the run-e2e-tests-nessus integration test pipeline - Explicitly install setuptools for Python 3.12 compatibility See: #308
- Loading branch information
Showing
6 changed files
with
162 additions
and
5 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
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 @@ | ||
#!/bin/bash -e | ||
|
||
# The file cachi2/output/.build-config.json specifies where cachi2 expects to find | ||
# the project sources. By default, Konflux points them to /var/workdir/source. | ||
# Create a symbolic link from /workspace to /var/workdir/source | ||
|
||
mkdir -p /var/workdir/ | ||
ln -s /workspace /var/workdir/source | ||
echo "Symbolic link created: /workspace to /var/workdir/source" | ||
cachi2 --log-level="debug" inject-files /cachi2/output |
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,11 @@ | ||
#!/bin/bash -e | ||
|
||
if [ -f "/cachi2/cachi2.env" ]; then | ||
echo "Sourcing Cachi2 environment" | ||
source /cachi2/cachi2.env | ||
|
||
# Python 3.12 doesn't include setuptools and wheel by default in 'ensurepip', | ||
# so we manually install them to make them available for building | ||
# prefetched dependencies | ||
PIP_NO_INDEX= pip3 download setuptools wheel --dest "$PIP_FIND_LINKS" | ||
fi |
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,58 @@ | ||
--- | ||
# yaml-language-server: $schema=https://json.schemastore.org/yamllint.json | ||
apiVersion: tekton.dev/v1 | ||
kind: Task | ||
metadata: | ||
name: prefetch-get-refs | ||
spec: | ||
description: Fetches references for Cachi2 prefetch dependencies | ||
results: | ||
- name: PREFETCH_CACHI2_ARTIFACT | ||
description: The OCI artifact containing the Cachi2 prefetched dependencies | ||
params: | ||
- name: SNAPSHOT | ||
description: The JSON string of the Snapshot | ||
steps: | ||
- name: prefetch-get-refs | ||
image: quay.io/konflux-qe-incubator/konflux-qe-tools:latest | ||
env: | ||
- name: SNAPSHOT | ||
value: $(params.SNAPSHOT) | ||
- name: KONFLUX_COMPONENT_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.labels['appstudio.openshift.io/component'] | ||
- name: PREFETCH_CACHI2_ARTIFACT_FILE | ||
value: $(results.PREFETCH_CACHI2_ARTIFACT.path) | ||
script: | | ||
#!/bin/bash | ||
set -euo pipefail | ||
echo "Starting prefetch-get-refs task..." | ||
# Extract the container image for the specified component from the snapshot | ||
COMPONENT_CONTAINER_IMAGE=$(jq -r --arg COMPONENT_NAME "$KONFLUX_COMPONENT_NAME" ' | ||
.components[] | select(.name == $COMPONENT_NAME) | .containerImage' <<< "$SNAPSHOT") | ||
if [[ -z "$COMPONENT_CONTAINER_IMAGE" || "$COMPONENT_CONTAINER_IMAGE" == "null" ]]; then | ||
echo "Error: Could not determine container image for component: $KONFLUX_COMPONENT_NAME" | ||
exit 1 | ||
fi | ||
echo "Component container image: $COMPONENT_CONTAINER_IMAGE" | ||
echo "Downloading Cosign metadata..." | ||
cosign download attestation "$COMPONENT_CONTAINER_IMAGE" > cosign_metadata.json || { | ||
echo "Error: Failed to download Cosign metadata" | ||
exit 1 | ||
} | ||
CACHI2_SOURCE_ARTIFACT="$(jq -r \ | ||
'.payload | @base64d | fromjson | .predicate.buildConfig.tasks[] | | ||
select(.name == "prefetch-dependencies") | .results[] | select(.name == "CACHI2_ARTIFACT") | .value' \ | ||
cosign_metadata.json)" | ||
echo "Cachi2 source artifact: $CACHI2_SOURCE_ARTIFACT" | ||
# Write the result to Tekton results file | ||
echo -n "$CACHI2_SOURCE_ARTIFACT" > "$PREFETCH_CACHI2_ARTIFACT_FILE" |