From a13f317d199bd136d30f5b4ae8b569f761bba24e Mon Sep 17 00:00:00 2001 From: Adrian Riobo Lorenzo Date: Thu, 1 Aug 2024 15:42:51 +0200 Subject: [PATCH 1/4] test Signed-off-by: Adrian Riobo Lorenzo --- .github/workflows/crc-builder-builder.yaml | 34 +++++++++++++++++++ Makefile | 7 ++-- crc-builder/oci/lib/linux/entrypoint.sh | 2 -- .../tkn/tpl/crc-builder-installer.tpl.yaml | 7 ++-- crc-builder/tkn/tpl/crc-builder.tpl.yaml | 25 +++----------- 5 files changed, 47 insertions(+), 28 deletions(-) diff --git a/.github/workflows/crc-builder-builder.yaml b/.github/workflows/crc-builder-builder.yaml index 8e8d3d5..9a30db9 100644 --- a/.github/workflows/crc-builder-builder.yaml +++ b/.github/workflows/crc-builder-builder.yaml @@ -54,6 +54,40 @@ jobs: name: crc-builder path: crc-builder* + tkn-check: + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Template tkn for PR + if: ${{ github.event_name == 'pull_request' }} + env: + # CRC_BUILDER: ghcr.io/crc-org/ci-crc-builder + CRC_BUILDER: ghcr.io/adrianriobo/ci-crc-builder + CRC_BUILDER_V: pr-${{ github.event.number }} + run: | + make crc-builder-tkn-create + + - name: Check tkn for release + if: ${{ github.event_name == 'push' }} + run: | + [ ! -f crc-builder/tkn/crc-builder-installer.yaml ] && exit 1 + [ ! -f crc-builder/tkn/crc-builder.yaml ] && exit 1 + # Check if version is in sync + + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1 + + # https://docs.openshift.com/pipelines/1.15/about/op-release-notes.html + - name: Deploy min supported tekton version + run: kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.44.5/release.yaml + + - name: Deploy tasks + run: | + kubectl apply -f crc-builder/tkn/crc-builder-installer.yaml + kubectl apply -f crc-builder/tkn/crc-builder.yaml + diff --git a/Makefile b/Makefile index c0ac3a0..a17e1bc 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ include tools/tools.mk # 2 version # 3 context define tkn_template - sed -e 's%cimage%$(1)%g' -e 's%cversion%$(2)%g' $(3)/tkn/tpl/task.tpl.yaml > $(3)/tkn/task.yaml + sed -e 's%cimage%$(1)%g' -e 's%cversion%$(2)%g' $(3)/tkn/tpl/$(4).tpl.yaml > $(3)/tkn/$(4).yaml endef # Push task as bundle @@ -84,8 +84,9 @@ endif ${CONTAINER_MANAGER} push $(IMAGE)-windows ${CONTAINER_MANAGER} push $(IMAGE)-darwin -# tkn-create: -# $(call tkn_creator,$(SNC_RUNNER),$(SNC_RUNNER_V),snc-runner) +crc-builder-tkn-create: + $(call tkn_creator,$(CRC_BUILDER),$(CRC_BUILDER_V),crc-builder,crc-builder-installer) + $(call tkn_creator,$(CRC_BUILDER),$(CRC_BUILDER_V),crc-builder,crc-builder) # tkn-push: install-out-of-tree-tools # $(call tkn_pusher,$(SNC_RUNNER),$(SNC_RUNNER_V),snc-runner) diff --git a/crc-builder/oci/lib/linux/entrypoint.sh b/crc-builder/oci/lib/linux/entrypoint.sh index 561afe3..6040319 100755 --- a/crc-builder/oci/lib/linux/entrypoint.sh +++ b/crc-builder/oci/lib/linux/entrypoint.sh @@ -8,8 +8,6 @@ source ./common.sh # Execution is controlled based on ENVS: -# CUSTOM_BUNDLE_VERSION_VARIABLE When build based on a custom bundle need to set type: PODMAN_VERSION or OPENSHIFT_VERSION -# CUSTOM_BUNDLE_VERSION When build based on a custom bundle need to set version # CRC_SCM: Source code repository for crc # CRC_SCM_PR: Optional parameter to build an specific PR for crc # CRC_SCM_REF: Optional parameter to build an specific PR for crc diff --git a/crc-builder/tkn/tpl/crc-builder-installer.tpl.yaml b/crc-builder/tkn/tpl/crc-builder-installer.tpl.yaml index a7e1a84..ef1c719 100644 --- a/crc-builder/tkn/tpl/crc-builder-installer.tpl.yaml +++ b/crc-builder/tkn/tpl/crc-builder-installer.tpl.yaml @@ -4,12 +4,12 @@ kind: Task metadata: name: crc-builder-installer labels: - app.kubernetes.io/version: "0.0.7" + app.kubernetes.io/version: "cversion" redhat.com/product: openshift-local dev.lifecycle.io/phase: build openshift-local.redhat.com/component: installer annotations: - tekton.dev/pipelines.minVersion: "0.24.x" + tekton.dev/pipelines.minVersion: "0.44.x" tekton.dev/categories: installer tekton.dev/tags: openshift-local, installer tekton.dev/displayName: "openshift local installer" @@ -60,7 +60,8 @@ spec: steps: - name: crc-executable-builder - image: quay.io/rhqp/crc-builder:v0.0.7-$(params.os) + # cimage and cversion values should be passed to the template + image: cimage:cversion-$(params.os) imagePullPolicy: Always volumeMounts: - mountPath: /opt/host/ diff --git a/crc-builder/tkn/tpl/crc-builder.tpl.yaml b/crc-builder/tkn/tpl/crc-builder.tpl.yaml index 1ba6415..919afe6 100644 --- a/crc-builder/tkn/tpl/crc-builder.tpl.yaml +++ b/crc-builder/tkn/tpl/crc-builder.tpl.yaml @@ -4,16 +4,16 @@ kind: Task metadata: name: crc-builder labels: - app.kubernetes.io/version: "0.0.6" + app.kubernetes.io/version: "cversion" redhat.com/product: openshift-local dev.lifecycle.io/phase: build openshift-local.redhat.com/component: binary annotations: - tekton.dev/pipelines.minVersion: "0.24.x" + tekton.dev/pipelines.minVersion: "0.44.x" tekton.dev/categories: binary tekton.dev/tags: openshift-local, binary, linux tekton.dev/displayName: "openshift local linux binary" - tekton.dev/platforms: "linux/amd64" + tekton.dev/platforms: "linux/amd64, linux/arm64" spec: description: >- This task will build openshift local binary for linux distributions @@ -25,16 +25,6 @@ spec: default: "''" - name: crc-scm-ref default: main - - name: custom-bundle-version-variable - description: | - When building an installer based on a custom bundle it is required - to manipulate the Makefile to match the custom version. - Current variables holding bundle version based on bundle type are - * OPENSHIFT_VERSION - * PODMAN_VERSION - default: "''" - - name: custom-bundle-version - default: "''" - name: s3-url - name: s3-access-key - name: s3-secret-key @@ -51,7 +41,8 @@ spec: steps: - name: build - image: quay.io/rhqp/crc-builder:v0.0.7-linux + # cimage and cversion values should be passed to the template + image: cimage:cversion-linux imagePullPolicy: Always script: | #!/bin/sh @@ -69,12 +60,6 @@ spec: if [[ $(params.crc-scm-ref) != "" ]]; then CRC_SCM_REF=$(params.crc-scm-ref) fi - if [[ $(params.custom-bundle-version-variable) != "" ]]; then - CUSTOM_BUNDLE_VERSION_VARIABLE=$(params.custom-bundle-version-variable) - fi - if [[ $(params.custom-bundle-version) != "" ]]; then - CUSTOM_BUNDLE_VERSION=$(params.custom-bundle-version) - fi if [[ $(params.s3-folder-path) != "" ]]; then UPLOAD_PATH=$(params.s3-folder-path) fi From c626602fe7ceaa0158f792fcfd74876170f2ad39 Mon Sep 17 00:00:00 2001 From: Adrian Riobo Lorenzo Date: Thu, 1 Aug 2024 15:50:47 +0200 Subject: [PATCH 2/4] test Signed-off-by: Adrian Riobo Lorenzo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a17e1bc..38b682c 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ endif #### crc-builder #### -.PHONY: crc-builder-oci-build crc-builder-oci-save crc-builder-oci-load crc-builder-oci-push +.PHONY: crc-builder-oci-build crc-builder-oci-save crc-builder-oci-load crc-builder-oci-push crc-builder-tkn-create # Registries and versions CRC_BUILDER ?= $(shell sed -n 1p crc-builder/release-info) From f16e23e8e54ace1f63fdf8761e3ce53f880cf5c4 Mon Sep 17 00:00:00 2001 From: Adrian Riobo Lorenzo Date: Thu, 1 Aug 2024 15:58:25 +0200 Subject: [PATCH 3/4] test Signed-off-by: Adrian Riobo Lorenzo --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 38b682c..a0bd09d 100644 --- a/Makefile +++ b/Makefile @@ -85,8 +85,8 @@ endif ${CONTAINER_MANAGER} push $(IMAGE)-darwin crc-builder-tkn-create: - $(call tkn_creator,$(CRC_BUILDER),$(CRC_BUILDER_V),crc-builder,crc-builder-installer) - $(call tkn_creator,$(CRC_BUILDER),$(CRC_BUILDER_V),crc-builder,crc-builder) + $(call tkn_template,$(CRC_BUILDER),$(CRC_BUILDER_V),crc-builder,crc-builder-installer) + $(call tkn_template,$(CRC_BUILDER),$(CRC_BUILDER_V),crc-builder,crc-builder) # tkn-push: install-out-of-tree-tools # $(call tkn_pusher,$(SNC_RUNNER),$(SNC_RUNNER_V),snc-runner) From 176d09642d04b012b9804a49cfcf727760e906bd Mon Sep 17 00:00:00 2001 From: Adrian Riobo Lorenzo Date: Thu, 1 Aug 2024 17:45:16 +0200 Subject: [PATCH 4/4] test Signed-off-by: Adrian Riobo Lorenzo --- .github/workflows/crc-builder-builder.yaml | 6 ++++ .github/workflows/crc-builder-pusher.yml | 30 ++++++++++++++--- .github/workflows/snc-runner-builder.yaml | 38 +++++++++++++++++++++- .github/workflows/snc-runner-pusher.yml | 20 ++++++++++-- Makefile | 32 +++++++++++------- 5 files changed, 107 insertions(+), 19 deletions(-) diff --git a/.github/workflows/crc-builder-builder.yaml b/.github/workflows/crc-builder-builder.yaml index 9a30db9..7fa2ce7 100644 --- a/.github/workflows/crc-builder-builder.yaml +++ b/.github/workflows/crc-builder-builder.yaml @@ -88,6 +88,12 @@ jobs: kubectl apply -f crc-builder/tkn/crc-builder-installer.yaml kubectl apply -f crc-builder/tkn/crc-builder.yaml + - name: Upload crc-builder-tkn + uses: actions/upload-artifact@v4 + with: + name: crc-builder-tkn + path: crc-builder/tkn/crc-builder* + diff --git a/.github/workflows/crc-builder-pusher.yml b/.github/workflows/crc-builder-pusher.yml index 2a1cb33..3aa5b42 100644 --- a/.github/workflows/crc-builder-pusher.yml +++ b/.github/workflows/crc-builder-pusher.yml @@ -15,7 +15,6 @@ jobs: packages: write steps: - name: Download crc-builder assets - id: download-gh-context-artifact uses: actions/download-artifact@v4 with: name: crc-builder @@ -36,7 +35,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Log in to ghcr.io - if: ${{ env.source_event == 'push' }} + if: ${{ env.source_event == 'pull_request' }} uses: redhat-actions/podman-login@v1 with: registry: ghcr.io @@ -53,5 +52,28 @@ jobs: - name: Push crc-builder run: | - make snc-runner-oci-load - IMAGE=${{ env.image }} make snc-runner-oci-push \ No newline at end of file + podman load -i crc-builder-linux.tar + podman manifest push ${{ env.image }}-linux + podman load -i crc-builder-windows.tar + podman push ${{ env.image }}-windows + podman load -i crc-builder-darwin.tar + podman push ${{ env.image }}-darwin + + - name: Download crc-builder-tkn assets + uses: actions/download-artifact@v4 + with: + name: crc-builder-tkn + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + - name: Push crc-builder-tkn + env: + TKN_VERSION: '0.37.0' + run: | + curl -LO "https://github.com/tektoncd/cli/releases/download/v${TKN_VERSION}/tkn_${TKN_VERSION}_Linux_x86_64.tar.gz" + tar xvzf "tkn_${TKN_VERSION}_Linux_x86_64.tar.gz" tkn + ./tkn bundle push ${{ env.image }}-tkn \ + -f crc-builder-installer.yaml \ + -f crc-builder.yaml + + \ No newline at end of file diff --git a/.github/workflows/snc-runner-builder.yaml b/.github/workflows/snc-runner-builder.yaml index c0e123e..67cdd9f 100644 --- a/.github/workflows/snc-runner-builder.yaml +++ b/.github/workflows/snc-runner-builder.yaml @@ -48,7 +48,43 @@ jobs: name: snc-runner path: snc-runner* - + tkn-check: + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Template tkn for PR + if: ${{ github.event_name == 'pull_request' }} + env: + # CRC_BUILDER: ghcr.io/crc-org/ci-crc-builder + CRC_BUILDER: ghcr.io/adrianriobo/ci-snc-runner + CRC_BUILDER_V: pr-${{ github.event.number }} + run: | + make snc-runner-tkn-create + + - name: Check tkn for release + if: ${{ github.event_name == 'push' }} + run: | + [ ! -f snc-runner/tkn/task.yaml ] && exit 1 + # Check if version is in sync + + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1 + + # https://docs.openshift.com/pipelines/1.15/about/op-release-notes.html + - name: Deploy min supported tekton version + run: kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.44.5/release.yaml + + - name: Deploy tasks + run: | + kubectl apply -f snc-runner/tkn/task.yaml + + - name: Upload crc-builder-tkn + uses: actions/upload-artifact@v4 + with: + name: snc-runner-tkn + path: snc-runner/tkn/task.yaml \ No newline at end of file diff --git a/.github/workflows/snc-runner-pusher.yml b/.github/workflows/snc-runner-pusher.yml index 39ad36a..43bf1d6 100644 --- a/.github/workflows/snc-runner-pusher.yml +++ b/.github/workflows/snc-runner-pusher.yml @@ -53,5 +53,21 @@ jobs: - name: Push snc-runner run: | - make snc-runner-oci-load - IMAGE=${{ env.image }} make snc-runner-oci-push \ No newline at end of file + podman load -i snc-runner.tar + podman push ${{ env.image }} + + - name: Download snc-runner-tkn assets + uses: actions/download-artifact@v4 + with: + name: snc-runner-tkn + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + - name: Push snc-runner-tkn + env: + TKN_VERSION: '0.37.0' + run: | + curl -LO "https://github.com/tektoncd/cli/releases/download/v${TKN_VERSION}/tkn_${TKN_VERSION}_Linux_x86_64.tar.gz" + tar xvzf "tkn_${TKN_VERSION}_Linux_x86_64.tar.gz" tkn + ./tkn bundle push ${{ env.image }}-tkn \ + -f task.yaml \ No newline at end of file diff --git a/Makefile b/Makefile index a0bd09d..f4fa865 100644 --- a/Makefile +++ b/Makefile @@ -13,17 +13,9 @@ define tkn_template sed -e 's%cimage%$(1)%g' -e 's%cversion%$(2)%g' $(3)/tkn/tpl/$(4).tpl.yaml > $(3)/tkn/$(4).yaml endef -# Push task as bundle -# 1 image -# 2 version -# 3 context -define tkn_push - $(TOOLS_BINDIR)/tkn bundle push $(1):$(2)-tkn -f $(3)/tkn/task.yaml -endef - #### snc-runner #### -.PHONY: snc-runner-oci-build snc-runner-oci-save snc-runner-oci-load snc-runner-oci-push +.PHONY: snc-runner-oci-build snc-runner-oci-save snc-runner-oci-load snc-runner-oci-push snc-runner-tkn-create snc-runner-tkn-push # Variables SNC_RUNNER ?= $(shell sed -n 1p snc-runner/release-info) @@ -47,9 +39,19 @@ ifndef IMAGE endif ${CONTAINER_MANAGER} push $(IMAGE) +snc-runner-tkn-create: + $(call tkn_template,$(SNC_RUNNER),$(SNC_RUNNER_V),snc-runner,task) + +snc-runner-tkn-push: install-out-of-tree-tools +ifndef IMAGE + IMAGE = $(SNC_RUNNER):$(SNC_RUNNER_V) +endif + $(TOOLS_BINDIR)/tkn bundle push $(IMAGE)-tkn \ + -f snc-runner/tkn/task.yaml + #### crc-builder #### -.PHONY: crc-builder-oci-build crc-builder-oci-save crc-builder-oci-load crc-builder-oci-push crc-builder-tkn-create +.PHONY: crc-builder-oci-build crc-builder-oci-save crc-builder-oci-load crc-builder-oci-push crc-builder-tkn-create crc-builder-tkn-push # Registries and versions CRC_BUILDER ?= $(shell sed -n 1p crc-builder/release-info) @@ -88,5 +90,11 @@ crc-builder-tkn-create: $(call tkn_template,$(CRC_BUILDER),$(CRC_BUILDER_V),crc-builder,crc-builder-installer) $(call tkn_template,$(CRC_BUILDER),$(CRC_BUILDER_V),crc-builder,crc-builder) -# tkn-push: install-out-of-tree-tools -# $(call tkn_pusher,$(SNC_RUNNER),$(SNC_RUNNER_V),snc-runner) +crc-builder-tkn-push: install-out-of-tree-tools +ifndef IMAGE + IMAGE = $(CRC_BUILDER):$(CRC_BUILDER_V) +endif + $(TOOLS_BINDIR)/tkn bundle push $(IMAGE)-tkn \ + -f crc-builder/tkn/crc-builder-installer.yaml + -f crc-builder/tkn/crc-builder.yaml + \ No newline at end of file