diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.tekton/centos-bootc-integration-tests.yaml b/.tekton/centos-bootc-integration-tests.yaml new file mode 100644 index 00000000..c1560515 --- /dev/null +++ b/.tekton/centos-bootc-integration-tests.yaml @@ -0,0 +1,61 @@ +apiVersion: tekton.dev/v1 +kind: Pipeline +metadata: + name: testing-farm +spec: + description: >- + Expects a list of container images to be provided via the SNAPSHOT parameter. + A secret containing the testing-farm API token should be made available via a secret with the name `testing-farm-secret` containing a key `testing-farm-token`. + params: + - name: SNAPSHOT + description: A list of container images that should undergo testing + type: string + - name: GIT_URL + description: URL of the GIT repository that contains the tests. + type: string + - name: GIT_REF + default: "main" + description: Branch of the git repository used containing the tests + type: string + - name: COMPOSE + default: "Fedora-Rawhide" + description: Compose to use for the system-under-test. + type: string + - name: ARCH + default: "x86_64" + description: Comma-separated list of architectures to run against. + type: string + - name: TIMEOUT + default: "720" + description: Set the timeout for the request in minutes. If the test takes longer than this, it will be terminated. + type: string + - name: TESTING_FARM_API_URL + default: https://api.dev.testing-farm.io/v0.1 + description: The testing-farm instance API to use + type: string + tasks: + - name: testing-farm + taskRef: + resolver: git + params: + - name: url + value: https://github.com/centos/centos-bootc/ + - name: revision + value: main + - name: pathInRepo + value: .tekton/testing-farm.yaml + params: + - name: SNAPSHOT + value: $(params.SNAPSHOT) + - name: GIT_URL + value: $(params.GIT_URL) + - name: GIT_REF + value: $(params.GIT_REF) + - name: COMPOSE + value: $(params.COMPOSE) + - name: ARCH + value: $(params.ARCH) + - name: TIMEOUT + value: $(params.TIMEOUT) + - name: TESTING_FARM_API_URL + value: $(params.TESTING_FARM_API_URL) diff --git a/.tekton/testing-farm.yaml b/.tekton/testing-farm.yaml new file mode 100644 index 00000000..adbcedf3 --- /dev/null +++ b/.tekton/testing-farm.yaml @@ -0,0 +1,63 @@ +apiVersion: tekton.dev/v1 +kind: Task +metadata: + name: testing-farm +spec: + description: Initiate testing-farm test given a list of container images + params: + - name: SNAPSHOT + description: A list of container images that should undergo testing + - name: GIT_URL + description: URL of the GIT repository that contains the tests. + - name: GIT_REF + default: "main" + description: Branch of the git repository used containing the tests + - name: COMPOSE + default: "Fedora-Rawhide" + description: Compose to use for the system-under-test. + - name: ARCH + default: "x86_64" + description: Comma-separated list of architectures to run against. + - name: TIMEOUT + default: "720" + description: Set the timeout for the request in minutes. If the test takes longer than this, it will be terminated. + - name: TESTING_FARM_API_URL + default: https://api.dev.testing-farm.io/v0.1 + description: The testing-farm instance API to use + volumes: + - name: testing-farm-secret + secret: + secretName: testing-farm-secret + steps: + - image: quay.io/testing-farm/cli:latest + volumeMounts: + - name: testing-farm-secret + mountPath: "/etc/secrets" + readOnly: true + env: + - name: SNAPSHOT + value: $(params.SNAPSHOT) + - name: GIT_URL + value: $(params.GIT_URL) + - name: GIT_REF + value: $(params.GIT_REF) + - name: COMPOSE + value: $(params.COMPOSE) + - name: ARCH + value: $(params.ARCH) + - name: TIMEOUT + value: $(params.TIMEOUT) + - name: TESTING_FARM_API_URL + value: $(params.TESTING_FARM_API_URL) + script: | + #!/usr/bin/env bash + + export TESTING_FARM_API_TOKEN=$(cat /etc/secrets/testing-farm-token) + + testing-farm request \ + --environment SNAPSHOT="$(echo ${SNAPSHOT} | base64 -w 0)" \ + --git-url "${GIT_URL}" \ + --git-ref "${GIT_REF}" \ + --compose "${COMPOSE}" \ + --arch "${ARCH}" \ + --timeout "${TIMEOUT}" diff --git a/plans/main.fmf b/plans/main.fmf new file mode 100644 index 00000000..39d406f9 --- /dev/null +++ b/plans/main.fmf @@ -0,0 +1,30 @@ +summary: Example of working with Snapshots from RHTAP + +prepare: + - name: Install packages + how: install + package: + # For working with the SNAPSHOT var + - jq + # Just for interacting with the images + - podman + +execute: + # Note, the ' character works here because the ${SNAPSHOT} is not a shell + # environment variable. it is treated by tmt as a tmt variable which is + # injected into the script before it is evaluated by bash. + script: | + echo "This is where the test script goes." + + echo "The base64 encoded snapshot is: ${SNAPSHOT}" + echo -n "The base64 decoded snapshot is: " + echo $SNAPSHOT | base64 -d + + echo "It contains the following container images:" + + IMAGES=$(echo '${SNAPSHOT}' | base64 -d | jq -r '.components[].containerImage') + + # Then, perform some check + for IMAGE in $IMAGES; do + podman run $IMAGE cat /etc/os-release + done