-
Notifications
You must be signed in to change notification settings - Fork 84
137 lines (122 loc) · 6.15 KB
/
test-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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/_deployment.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/_deployment.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
```