diff --git a/.github/workflows/ci-hub-support-builder.yaml b/.github/workflows/ci-hub-support-builder.yaml new file mode 100644 index 0000000..9c6a8bb --- /dev/null +++ b/.github/workflows/ci-hub-support-builder.yaml @@ -0,0 +1,53 @@ +name: ci-hub-support-builder + +on: + push: + tags: [ 'ci-hub-support-v*' ] + pull_request: + branches: [ main ] + paths: ['ci-hub-support/**', '.github\/workflows\/ci-hub-support*' ] + +jobs: + build: + name: build + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build image for PR + if: ${{ github.event_name == 'pull_request' }} + env: + CI_HUB_SUPPORT: ghcr.io/devtools-qe-incubator/ci-hub-support + CI_HUB_SUPPORT_V: pr-${{ github.event.number }} + run: | + make ci-hub-support-oci-build + make ci-hub-support-oci-save + echo "image=${CI_HUB_SUPPORT}:${CI_HUB_SUPPORT_V}" >> "$GITHUB_ENV" + + - name: Build image for Release + if: ${{ github.event_name == 'push' }} + run: | + make ci-hub-support-oci-build + make ci-hub-support-oci-save + echo "image=$(sed -n 1p ci-hub-support/release-info):v$(sed -n 2p ci-hub-support/release-info)" >> "$GITHUB_ENV" + + - name: Create image metadata + run: | + echo ${{ env.image }} > ci-hub-support-image + echo ${{ github.event_name }} > ci-hub-support-build-event + + - name: Upload ci-hub-support + uses: actions/upload-artifact@v4 + with: + name: ci-hub-support + path: ci-hub-support* + + + + + + + + + \ No newline at end of file diff --git a/.github/workflows/ci-hub-support-pusher.yml b/.github/workflows/ci-hub-support-pusher.yml new file mode 100644 index 0000000..c77c3eb --- /dev/null +++ b/.github/workflows/ci-hub-support-pusher.yml @@ -0,0 +1,51 @@ +name: ci-hub-support-pusher + +on: + workflow_run: + workflows: + - ci-hub-support-builder + types: + - completed + +jobs: + push: + name: push + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-24.04 + permissions: + contents: read + packages: write + steps: + - name: Download ci-hub-support assets + uses: actions/download-artifact@v4 + with: + name: ci-hub-support + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + - name: Get ci-hub-support build informaiton + run: | + echo "source_event=$(cat ci-hub-support-build-event)" >> "$GITHUB_ENV" + echo "image=$(cat ci-hub-support-image)" >> "$GITHUB_ENV" + + - name: Log in to ghcr.io + if: ${{ env.source_event == 'pull_request' }} + uses: redhat-actions/podman-login@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Log in quay.io + if: ${{ env.source_event == 'push' }} + uses: redhat-actions/podman-login@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_IO_USERNAME }} + password: ${{ secrets.QUAY_IO_PASSWORD }} + + - name: Push ci-hub-support + run: | + podman load -i ci-hub-support.tar + podman push ${{ env.image }} + \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fbab0e0 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +CONTAINER_MANAGER ?= podman + +#### ci-hub-support #### + +.PHONY: ci-hub-support-oci-build ci-hub-support-oci-save ci-hub-support-oci-load ci-hub-support-oci-push + +# Variables +CI_HUB_SUPPORT ?= $(shell sed -n 1p ci-hub-support/release-info) +CI_HUB_SUPPORT_V ?= v$(shell sed -n 2p ci-hub-support/release-info) +CI_HUB_SUPPORT_SAVE ?= ci-hub-support + +ci-hub-support-oci-build: CONTEXT=ci-hub-support +ci-hub-support-oci-build: MANIFEST=$(CI_HUB_SUPPORT):$(CI_HUB_SUPPORT_V) +ci-hub-support-oci-build: + ${CONTAINER_MANAGER} build -t $(MANIFEST) -f $(CONTEXT)/Containerfile $(CONTEXT) + +ci-hub-support-oci-save: + ${CONTAINER_MANAGER} save -o $(CI_HUB_SUPPORT_SAVE).tar $(CI_HUB_SUPPORT):$(CI_HUB_SUPPORT_V) + +sci-hub-support-oci-load: + ${CONTAINER_MANAGER} load -i $(CI_HUB_SUPPORT_SAVE).tar + +ci-hub-support-oci-push: +ifndef IMAGE + IMAGE = $(CI_HUB_SUPPORT):$(CI_HUB_SUPPORT_V) +endif + ${CONTAINER_MANAGER} push $(IMAGE) + + + \ No newline at end of file diff --git a/base-pipeline.yaml b/base-pipeline.yaml deleted file mode 100644 index 5eaebbf..0000000 --- a/base-pipeline.yaml +++ /dev/null @@ -1,45 +0,0 @@ -kind: Pipeline -apiVersion: tekton.dev/v1beta1 -metadata: - name: base-pipeline -spec: - params: - - description: 'Snapshot of the application' - name: SNAPSHOT - default: '{"components": [{"name":"test-app", "containerImage": "quay.io/example/repo:latest"}]}' - type: string - - description: 'Namespace where the application is running' - name: NAMESPACE - default: "default" - type: string - - description: 'Expected output' - name: EXPECTED_OUTPUT - default: "Hello World!" - type: string - tasks: - - name: task-1 - description: Placeholder task that prints the Snapshot and outputs standard TEST_OUTPUT - params: - - name: SNAPSHOT - value: $(params.SNAPSHOT) - taskSpec: - params: - - name: SNAPSHOT - results: - - name: TEST_OUTPUT - description: Test output - steps: - - image: quay.io/rhqp/support-tools:v0.0.3 - env: - - name: SNAPSHOT - value: $(params.SNAPSHOT) - script: | - echo -e "Example test task for the Snapshot:\n ${SNAPSHOT}" - // Run custom tests for the given Snapshot here - // After the tests finish, record the overall result in the RESULT variable - RESULT="SUCCESS" - - // Output the standardized TEST_OUTPUT result in JSON form - TEST_OUTPUT=$(jq -rc --arg date $(date +%s) --arg RESULT "${RESULT}" --null-input \ - '{result: $RESULT, timestamp: $date, failures: 0, successes: 1, warnings: 0}') - echo -n "${TEST_OUTPUT}" | tee $(results.TEST_OUTPUT.path) \ No newline at end of file diff --git a/ci-hub-support/Containerfile b/ci-hub-support/Containerfile new file mode 100644 index 0000000..ff77f69 --- /dev/null +++ b/ci-hub-support/Containerfile @@ -0,0 +1,21 @@ +# ubi 9.4-1227.1726694542 +FROM registry.access.redhat.com/ubi9-minimal@sha256:f5d2c6a1e0c86e4234ea601552dbabb4ced0e013a1efcbfb439f1f6a7a9275b0 + +LABEL org.opencontainers.image.authors="CodeReady Containers " + +ENV AWS_CLI_VERSION 2.17.63 +ENV AWS_CLI_URL https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip + +# YQ +ENV YQ_VERSION=4.11.2 +ENV YQ_BINARY_URL=https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_amd64 + +RUN microdnf install -y openssh-clients sshpass unzip zip bash jq findutils \ + && curl -Lo /usr/local/bin/yq "${YQ_BINARY_URL}" \ + && chmod +x /usr/local/bin/yq \ + && curl ${AWS_CLI_URL} -o awscliv2.zip \ + && unzip awscliv2.zip \ + && ./aws/install \ + && microdnf clean all \ + && rm -rf /var/cache/yum + diff --git a/ci-hub-support/release-info b/ci-hub-support/release-info new file mode 100644 index 0000000..3544a1b --- /dev/null +++ b/ci-hub-support/release-info @@ -0,0 +1,2 @@ +quay.io/devtools-qe-incubator/ci-hub-support +1.0.0-dev \ No newline at end of file