Skip to content

Commit

Permalink
feat: added crc-support component. Fix #40.
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo <[email protected]>
  • Loading branch information
adrianriobo committed Oct 24, 2024
1 parent 7cb9077 commit 8b9d808
Show file tree
Hide file tree
Showing 13 changed files with 691 additions and 1 deletion.
89 changes: 89 additions & 0 deletions .github/workflows/crc-support-builder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: crc-support-builder

on:
push:
tags: [ 'crc-support-v*' ]
pull_request:
branches: [ main ]
paths: ['Makefile', 'crc-support/**', '.github\/workflows\/crc-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:
CRC_SUPPORT: ghcr.io/crc-org/ci-crc-support
CRC_SUPPORT_V: pr-${{ github.event.number }}
run: |
make crc-support-oci-build
make crc-support-oci-save
echo "image=${CRC_SUPPORT}:${CRC_SUPPORT_V}" >> "$GITHUB_ENV"
- name: Build image for Release
if: ${{ github.event_name == 'push' }}
run: |
make crc-support-oci-build
make crc-support-oci-save
echo "image=$(sed -n 1p crc-support/release-info):v$(sed -n 2p crc-support/release-info)" >> "$GITHUB_ENV"
- name: Create image metadata
run: |
echo ${{ env.image }} > crc-support-image
echo ${{ github.event_name }} > crc-support-build-event
- name: Upload crc-support
uses: actions/upload-artifact@v4
with:
name: crc-support
path: crc-support*

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_SUPPORT: ghcr.io/crc-org/ci-crc-support
CRC_SUPPORT_V: pr-${{ github.event.number }}
run: |
make crc-support-tkn-create
- name: Check tkn specs
run: |
if [[ ! -f crc-support/tkn/task.yaml ]]; then
exit 1
fi
# 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-support/tkn/task.yaml
- name: Upload crc-support-tkn
uses: actions/upload-artifact@v4
with:
name: crc-support-tkn
path: crc-support/tkn/crc-support*







74 changes: 74 additions & 0 deletions .github/workflows/crc-support-pusher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: crc-support-pusher

on:
workflow_run:
workflows: [ 'crc-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 crc-support assets
uses: actions/download-artifact@v4
with:
name: crc-support
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}

- name: Get crc-support build informaiton
run: |
echo "source_event=$(cat crc-support-build-event)" >> "$GITHUB_ENV"
echo "image=$(cat crc-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 crc-support
run: |
# Load
podman load -i crc-support-linux.tar
podman load -i crc-support-windows.tar
podman load -i crc-support-darwin.tar
# Push
podman push ${{ env.image }}-linux
podman push ${{ env.image }}-windows
podman push ${{ env.image }}-darwin
- name: Download crc-support-tkn assets
uses: actions/download-artifact@v4
with:
name: crc-support-tkn
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}

- name: Push crc-support-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-support-installer.yaml \
-f crc-support.yaml
44 changes: 43 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,46 @@ endif
-f crc-builder/tkn/crc-builder-installer.yaml \
-f crc-builder/tkn/crc-builder.yaml \
-f crc-builder/tkn/crc-builder-arm64.yaml


#### crc-support ####

.PHONY: crc-support-oci-build crc-support-oci-save crc-support-oci-load crc-support-oci-push crc-support-tkn-create crc-support-tkn-push

# Registries and versions
CRC_SUPPORT ?= $(shell sed -n 1p crc-support/release-info)
CRC_SUPPORT_V ?= v$(shell sed -n 2p crc-support/release-info)
CRC_SUPPORT_SAVE ?= crc-support

crc-support-oci-build: CONTEXT=crc-support/oci
crc-support-oci-build: MANIFEST=$(CRC_SUPPORT):$(CRC_SUPPORT_V)
crc-support-oci-build:
${CONTAINER_MANAGER} build -t $(MANIFEST)-linux -f $(CONTEXT)/Containerfile --build-arg=OS=linux $(CONTEXT)
${CONTAINER_MANAGER} build -t $(MANIFEST)-windows -f $(CONTEXT)/Containerfile --build-arg=OS=windows $(CONTEXT)
${CONTAINER_MANAGER} build -t $(MANIFEST)-darwin -f $(CONTEXT)/Containerfile --build-arg=OS=darwin $(CONTEXT)

crc-support-oci-save: MANIFEST=$(CRC_SUPPORT):$(CRC_SUPPORT_V)
crc-support-oci-save:
${CONTAINER_MANAGER} save -o $(CRC_SUPPORT_SAVE)-linux.tar $(MANIFEST)-linux
${CONTAINER_MANAGER} save -o $(CRC_SUPPORT_SAVE)-windows.tar $(MANIFEST)-windows
${CONTAINER_MANAGER} save -o $(CRC_SUPPORT_SAVE)-darwin.tar $(MANIFEST)-darwin

crc-support-oci-load:
${CONTAINER_MANAGER} load -i $(CRC_SUPPORT_SAVE)-linux.tar
${CONTAINER_MANAGER} load -i $(CRC_SUPPORT_SAVE)-windows.tar
${CONTAINER_MANAGER} load -i $(CRC_SUPPORT_SAVE)-darwin.tar

crc-support-oci-push: MANIFEST=$(CRC_SUPPORT):$(CRC_SUPPORT_V)
crc-support-oci-push:
${CONTAINER_MANAGER} push $(MANIFEST)-linux
${CONTAINER_MANAGER} push $(MANIFEST)-windows
${CONTAINER_MANAGER} push $(MANIFEST)-darwin

crc-support-tkn-create:
$(call tkn_template,$(CRC_SUPPORT),$(CRC_SUPPORT_V),crc-support,task)

crc-support-tkn-push: install-out-of-tree-tools
ifndef IMAGE
IMAGE = $(CRC_SUPPORT):$(CRC_SUPPORT_V)
endif
$(TOOLS_BINDIR)/tkn bundle push $(IMAGE)-tkn \
-f crc-support/tkn/task.yaml
7 changes: 7 additions & 0 deletions crc-support/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Overview

crc-support component allows to manage remote operations to setup a environment for testing Openshift Local, it contains the scripts based on each target platform, and it basically manages:

* Cleanup environments to ensure fresh installations
* Download bundles
* Download and install Openshift Local
11 changes: 11 additions & 0 deletions crc-support/oci/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# v0.0.7
FROM quay.io/rhqp/deliverest@sha256:67ed1a47f1580141854c5baa742a50fc21920cf77d9d07eb798d7743508e52eb

LABEL org.opencontainers.image.authors="CRCQE <[email protected]>"

ARG OS

ENV ASSETS_FOLDER=/opt/crc-support \
OS=${OS}

COPY /lib/${OS}/* ${ASSETS_FOLDER}/
28 changes: 28 additions & 0 deletions crc-support/oci/lib/darwin/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# Remove any content from any previous crc installation
force_fresh_environment () {
crc cleanup 2>/dev/null
sudo kill -9 $(pgrep crc-tray | head -1) 2>/dev/null
sudo rm -rf /Applications/Red\ Hat\ OpenShift\ Local.app/
sudo rm /usr/local/bin/crc
rm -rf ~/.crc/
}

# Return 1 if true 0 false
required_download () {
if [[ ! -f $aName ]]; then
return 1
fi
cat $aSHAName | grep $aName | shasum -a 256 -c -
return ${?}
}

# $1 downloadle url
# Return 1 if not valid, 0 if valid
check_download() {
cat $aSHAName | grep $aName | shasum -a 256 -c -
return ${?}
}


1 change: 1 addition & 0 deletions crc-support/oci/lib/darwin/run.sh
25 changes: 25 additions & 0 deletions crc-support/oci/lib/linux/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

# Remove any content from any previous crc installation
force_fresh_environment () {
crc cleanup
sudo rm -rf /usr/local/bin/crc
rm -rf ~/.crc/
}

# Return 1 if true 0 false
required_download () {
if [[ ! -f ${DOWNLOADED_ITEM_NAME} ]]; then
return 1
fi
cat ${SHASUM_FILE} | grep ${DOWNLOADED_ITEM_NAME} | sha256sum -c -
return ${?}
}

# $1 downloadle url
# Return 1 if not valid, 0 if valid
check_download() {
cat ${SHASUM_FILE} | grep ${DOWNLOADED_ITEM_NAME} | sha256sum -c -
return ${?}
}

1 change: 1 addition & 0 deletions crc-support/oci/lib/linux/run.sh
Loading

0 comments on commit 8b9d808

Please sign in to comment.