Skip to content

Test images manager #190

Test images manager

Test images manager #190

Workflow file for this run

name: Test images manager
on:
workflow_run:
workflows: [Trigger test images]
types: [completed]
env:
REPOSITORY: quay.io/pelorus
jobs:
setup:
runs-on: ubuntu-latest
outputs:
branch_ref: ${{ steps.variables.outputs.branch_ref }}
pr_type: ${{ steps.variables.outputs.pr_type }}
pr_number: ${{ steps.variables.outputs.pr_number }}
commit_hash: ${{ steps.variables.outputs.commit_hash }}
steps:
- name: Download trigger information
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: trigger-test-images.yml
run_id: ${{ github.event.workflow_run.id }}
name: trigger-information
path: ./
- name: Store variables
id: variables
run: |
echo branch_ref=$(cat trigger-information.json | jq -r '.branch_ref') >> "$GITHUB_OUTPUT"
echo pr_type=$(cat trigger-information.json | jq -r '.pr_type') >> "$GITHUB_OUTPUT"
echo pr_number=$(cat trigger-information.json | jq -r '.pr_number') >> "$GITHUB_OUTPUT"
echo commit_hash=$(cat trigger-information.json | jq -r '.commit_hash') >> "$GITHUB_OUTPUT"
# TODO
# delete-images:
# runs-on: ubuntu-latest
# if: ${{ needs.setup.outputs.pr_type == 'closed' }}
# needs: setup
# steps:
# - name: Delete test images
# run: |
# podman search --list-tags $REPOSITORY/rc-pelorus-exporter
# podman search --list-tags $REPOSITORY/rc-pelorus-operator
# podman search --list-tags $REPOSITORY/rc-pelorus-operator-bundle
# delete all that have pr${{ needs.setup.outputs.pr_number }} in name...
create-images:
runs-on: ubuntu-latest
if: ${{ needs.setup.outputs.pr_type != 'closed' }}
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.setup.outputs.branch_ref }}
- name: Build and push exporter test image to Quay.io
uses: "./.github/workflow_templates/build_push_exporters"
with:
image: rc-pelorus-exporter
tags: vpr${{ needs.setup.outputs.pr_number }}-${{ needs.setup.outputs.commit_hash }}
quay_imagenamespace: ${{ secrets.QUAY_IMAGE_NAMESPACE }}
quay_username: ${{ secrets.QUAY_USERNAME }}
quay_password: ${{ secrets.QUAY_PASSWORD }}
- name: Log in to Quay.io (podman)
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
- name: Use test images in operator
env:
TEST_VERSION: pr${{ needs.setup.outputs.pr_number }}-${{ needs.setup.outputs.commit_hash }}
working-directory: ./pelorus-operator
run: |
export CURRENT_OPERATOR_VERSION="$(grep "VERSION ?= " Makefile | cut -c 12-)"
export CURRENT_CHART_VERSION="$(grep '^version: ' helm-charts/pelorus/Chart.yaml | cut -c 10-)"
export DEFAULT_OPERATOR_IMAGE="${{ env.REPOSITORY }}/pelorus-operator:$CURRENT_OPERATOR_VERSION"
export TEST_OPERATOR_IMAGE="${{ env.REPOSITORY }}/rc-pelorus-operator:${{ env.TEST_VERSION }}"
export DEFAULT_EXPORTER_IMAGE="${{ env.REPOSITORY }}/pelorus-{{ .exporter_type }}-exporter:{{ .image_tag | default \"v$CURRENT_CHART_VERSION\" }}"
export TEST_EXPORTER_IMAGE="${{ env.REPOSITORY }}/rc-pelorus-exporter:{{ .image_tag | default \"v${{ env.TEST_VERSION }}\" }}"
sed -i "s,$DEFAULT_OPERATOR_IMAGE,$TEST_OPERATOR_IMAGE,g" bundle/manifests/pelorus-operator.clusterserviceversion.yaml
sed -i "s,$DEFAULT_EXPORTER_IMAGE,$TEST_EXPORTER_IMAGE,g" helm-charts/pelorus/charts/exporters/templates/_imagestream_from_image.yaml
sed -i "s,$DEFAULT_EXPORTER_IMAGE,$TEST_EXPORTER_IMAGE,g" helm-charts/pelorus/charts/exporters/templates/_deploymentconfig.yaml
sed -i "s,$CURRENT_OPERATOR_VERSION,$TEST_VERSION,g" Makefile
sed -i "s,pelorus-operator,rc-pelorus-operator,g" Makefile
find . -type f | xargs sed -i "s,$CURRENT_OPERATOR_VERSION,$CURRENT_OPERATOR_VERSION-$TEST_VERSION,g"
find . -type f | xargs sed -i "s,$CURRENT_CHART_VERSION,$CURRENT_CHART_VERSION-$TEST_VERSION,g"
grep "$TEST_OPERATOR_IMAGE" bundle/manifests/pelorus-operator.clusterserviceversion.yaml
grep "$TEST_EXPORTER_IMAGE" helm-charts/pelorus/charts/exporters/templates/_imagestream_from_image.yaml
grep "$TEST_VERSION" helm-charts/pelorus/charts/exporters/templates/_deploymentconfig.yaml
grep "$TEST_VERSION" Makefile
grep rc-pelorus-operator Makefile
helm dep update helm-charts/pelorus
rm -r helm-charts/pelorus/charts/*.tgz
- name: Build and push operator test image
working-directory: ./pelorus-operator
run: |
make podman-build
podman image ls -a | grep pr${{ needs.setup.outputs.pr_number }}-${{ needs.setup.outputs.commit_hash }}
podman image ls -a | grep rc-pelorus-operator
make podman-push
- name: Build and push operator bundle test image
working-directory: ./pelorus-operator
run: |
make bundle-build
podman image ls -a | grep pr${{ needs.setup.outputs.pr_number }}-${{ needs.setup.outputs.commit_hash }}
podman image ls -a | grep rc-pelorus-operator-bundle
make bundle-push
# TODO delete old comments, just have the last on PR
- name: Comment test command in PR
uses: "./.github/workflow_templates/comment-pr"
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ needs.setup.outputs.pr_number }}
message: |
Test images available! 🧪🚀 To test operator with them, run
```
operator-sdk run bundle \
quay.io/pelorus/rc-pelorus-operator-bundle:vpr${{ needs.setup.outputs.pr_number }}-${{ needs.setup.outputs.commit_hash }} \
--namespace test-pelorus-operator
```
To clean up environment afterwards, run
```
operator-sdk cleanup pelorus-operator --namespace test-pelorus-operator
```