Skip to content

Commit

Permalink
chore: migrate crc-e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Fanjul committed Oct 23, 2024
1 parent 4eb78ab commit ddae45a
Show file tree
Hide file tree
Showing 7 changed files with 489 additions and 1 deletion.
92 changes: 92 additions & 0 deletions .github/workflows/crc-e2e-builder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: crc-e2e-builder

on:
push:
tags: [ 'crc-e2e-v*' ]
pull_request:
branches: [ main ]
paths: ['crc-e2e/**', '.github\/workflows\/crc-e2e*' ]

jobs:
build:
name: build
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4

# Allow emulation for building multi arch images
- name: Prepare runner
shell: bash
run: |
sudo apt-get install -y qemu-user-static
- name: Build image for PR
if: ${{ github.event_name == 'pull_request' }}
env:
CRC_E2E: ghcr.io/crc-org/ci-crc-e2e
CRC_E2E_V: pr-${{ github.event.number }}
run: |
make crc-e2e-oci-build
make crc-e2e-oci-save
echo "image=${CRC_E2E}:${CRC_E2E_V}" >> "$GITHUB_ENV"
- name: Build image for Release
if: ${{ github.event_name == 'push' }}
run: |
make crc-e2e-oci-build
make crc-e2e-oci-save
echo "image=$(sed -n 1p crc-e2e/release-info):v$(sed -n 2p crc-e2e/release-info)" >> "$GITHUB_ENV"
- name: Create image metadata
run: |
echo ${{ env.image }} > crc-e2e-image
echo ${{ github.event_name }} > crc-e2e-build-event
- name: Upload crc-e2e
uses: actions/upload-artifact@v4
with:
name: crc-e2e
path: crc-e2e*

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_E2E: ghcr.io/crc-org/ci-crc-e2e
CRC_E2E_V: pr-${{ github.event.number }}
run: |
make crc-e2e-tkn-create
- name: Check tkn specs
run: |
if [[ ! -f crc-e2e/tkn/crc-e2e-installer.yaml ]]; then
exit 1
fi
if [[ ! -f crc-e2e/tkn/crc-e2e.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-e2e/tkn/crc-e2e-installer.yaml
kubectl apply -f crc-e2e/tkn/crc-e2e.yaml
- name: Upload crc-e2e-tkn
uses: actions/upload-artifact@v4
with:
name: crc-e2e-tkn
path: crc-e2e/tkn/crc-e2e*
72 changes: 72 additions & 0 deletions .github/workflows/crc-e2e-pusher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: crc-e2e-pusher

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

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

- name: Push crc-e2e-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-e2e-installer.yaml \
-f crc-e2e.yaml
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,22 @@ 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-e2e ####

.PHONY: crc-e2e-tkn-create crc-e2e-tkn-push

# Registries and versions
CRC_E2E ?= $(shell sed -n 1p crc-e2e/release-info)
CRC_E2E_V ?= v$(shell sed -n 2p crc-e2e/release-info)
CRC_E2E_SAVE ?= crc-e2e

crc-e2e-tkn-create:
$(call tkn_template,$(CRC_E2E),$(CRC_E2E_V),crc-e2e,crc-e2e)

crc-e2e-tkn-push: install-out-of-tree-tools
ifndef IMAGE
IMAGE = $(CRC_E2E):$(CRC_E2E_V)
endif
$(TOOLS_BINDIR)/tkn bundle push $(IMAGE)-tkn \
-f crc-e2e/tkn/crc-e2e.yaml
9 changes: 9 additions & 0 deletions crc-e2e/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

## 1.0.0

* Initial version for managinig 2 types of builders
* linux multi arch container based
* windows and mac build on remote target


35 changes: 35 additions & 0 deletions crc-e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# CRC e2e

## Modifications to the image

Changes to `crc-e2e/os/macos/builder/build.sh` require re-building and pushing the image to internal registry (ImageStream). Make sure the changes are pushed to some `mybranch` on your fork of the QE platform repo (`github.com/<your-username>/qe-platform`). Since the `crc-e2e/manifests/buildconfig.yaml` will be guiding the build of the image, it needs to specify your branch on your fork as the source.

```diff
source:
contextDir: support/images/crc-e2e
git:
# dev
+ ref: 'mybranch'
+ uri: 'https://gitlab.cee.redhat.com/<your-username>/qe-platform.git'
- ref: v2.14.0
- uri: 'https://gitlab.cee.redhat.com/crc/qe-platform.git'
type: Git
```

Log in to `codeready-container` project, apply the changes in `crc-e2e/manifests/buildconfig.yaml` and start the build from the corresponding `BuildConfig` (depending on the platform).

```bash
oc apply -f support/images/crc-e2e/manifests/buildconfig.yaml
oc start-build image-crc-e2e-<platform>
```

Lastly, make sure that `imagePullPolicy` is set to `Always` in all places that use this imageStreamTag (e.g. `crc-e2e:v0.0.3-macos`). In our case, we needed to change and re-apply the following YAML.

```bash
oc apply -f orchestrator/catalog/task/crc-e2e-installer/0.3/crc-e2e-installer.yaml
```

Then undo changes to `crc-e2e/manifests/buildconfig.yaml` so it points to the upstream repository.

_If everything works as expected, send an MR to `gitlab.cee.redhat.com/crc/qe-platform`._

2 changes: 2 additions & 0 deletions crc-e2e/release-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quay.io/crc-org/ci-crc-e2e
1.0.0-dev
Loading

0 comments on commit ddae45a

Please sign in to comment.