Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added crc-support component #41

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
# main
FROM quay.io/rhqp/deliverest@sha256:6b42078f7a869d3b5c64dbac9bf84fe8080d15f6fde0d794713ad4a509eeacc5

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

ARG OS

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

COPY /lib/${OS}/* ${ASSETS_FOLDER}/
36 changes: 36 additions & 0 deletions crc-support/oci/lib/darwin/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/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/
}

# $1 file name for the asset to be checked
# $2 file name holding the shasum value
# Return 1 if true 0 false
required_download () {
if [[ ! -f ${1} ]]; then
return 1
fi
cat ${2} | grep ${1} | shasum -a 256 -c -
return ${?}
}

# $1 file name for the asset to be checked
# $2 file name holding the shasum value
# Return 1 if true 0 false
check_download() {
cat ${2} | grep ${1} | shasum -a 256 -c -
return ${?}
}

# $1 file name for crc installer
installCRC() {
sudo installer -pkg ${1} -target /
}


1 change: 1 addition & 0 deletions crc-support/oci/lib/darwin/run.sh
33 changes: 33 additions & 0 deletions crc-support/oci/lib/linux/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/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/
}

# $1 file name for the asset to be checked
# $2 file name holding the shasum value
# Return 1 if true 0 false
required_download () {
if [[ ! -f ${1} ]]; then
return 1
fi
cat ${2} | grep ${1} | sha256sum -c -
return ${?}

}

# $1 file name for the asset to be checked
# $2 file name holding the shasum value
# Return 1 if not valid, 0 if valid
check_download() {
cat ${2} | grep ${1} | sha256sum -c -
return ${?}
}

# $1 file name for crc installer
installCRC() {
sudo tar xvf "${1}" --strip-components 1 -C /usr/local/bin/
}
1 change: 1 addition & 0 deletions crc-support/oci/lib/linux/run.sh
Loading
Loading