forked from cryostatio/cryostat-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (161 loc) · 6.22 KB
/
test-ci-reusable.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
on:
workflow_call:
inputs:
tag:
required: true
type: string
repository:
required: false
type: string
ref:
required: false
type: string
sha:
required: true
type: string
env:
OPENSUSE_UNOFFICIAL_LIBCONTAINERS_KEY_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/Release.key"
OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04"
permissions:
statuses: write
packages: write
jobs:
clean-up-test-images:
runs-on: ubuntu-latest
needs: [scorecard-test]
strategy:
matrix:
image: [cryostat-operator, cryostat-operator-bundle, cryostat-operator-scorecard]
steps:
- uses: r26d/[email protected]
with:
owner: ${{ github.repository_owner }}
name: ${{ matrix.image }}
token: ${{ secrets.GITHUB_TOKEN }}
ignore-missing-package: true
tag-regex: ${{ inputs.tag }}
tagged-keep-latest: 0
controller-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
- uses: actions/setup-go@v4
with:
go-version: '1.22.*'
- name: Run controller tests
run: make test-envtest
- name: Set latest commit status as ${{ job.status }}
uses: myrotvorets/set-commit-status-action@master
if: always()
with:
sha: ${{ inputs.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
context: ${{ github.job }}
scorecard-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
- name: Install podman v4
run: |
echo "deb $OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list
curl -fsSL $OPENSUSE_UNOFFICIAL_LIBCONTAINERS_KEY_URL | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg
sudo apt -y update
sudo apt -y install podman
- name: Build scorecard image for test
run: |
CUSTOM_SCORECARD_IMG=ghcr.io/${{ github.repository_owner }}/cryostat-operator-scorecard:${{ inputs.tag }} \
PLATFORMS=linux/amd64 \
MANIFEST_PUSH=false \
make scorecard-build
- name: Push scorecard image to ghcr.io for test
id: push-scorecard-to-ghcr
uses: redhat-actions/push-to-registry@v2
with:
image: cryostat-operator-scorecard
tags: ${{ inputs.tag }}
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build operator image for test
run: |
OPERATOR_IMG=ghcr.io/${{ github.repository_owner }}/cryostat-operator:${{ inputs.tag }} \
SKIP_TESTS=true \
make oci-build
- name: Push operator image to ghcr.io for test
id: push-operator-to-ghcr
uses: redhat-actions/push-to-registry@v2
with:
image: cryostat-operator
tags: ${{ inputs.tag }}
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build bundle image for test
run: |
yq -i '.spec.template.spec.imagePullSecrets = [{"name": "registry-key"}]' config/manager/manager.yaml
OPERATOR_IMG=${{ steps.push-operator-to-ghcr.outputs.registry-path }} \
BUNDLE_IMG=ghcr.io/${{ github.repository_owner }}/cryostat-operator-bundle:${{ inputs.tag }} \
make bundle bundle-build
- name: Push bundle image to ghcr.io for test
id: push-bundle-to-ghcr
uses: redhat-actions/push-to-registry@v2
with:
image: cryostat-operator-bundle
tags: ${{ inputs.tag }}
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Kind cluster
uses: helm/[email protected]
with:
config: .github/kind-config.yaml
cluster_name: ci-${{ github.run_id }}
wait: 1m
ignore_failed_clean: true
- name: Set up Ingress Controller
run: |
# Install nginx ingress controller
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
kubectl rollout status -w \
deployment/ingress-nginx-controller \
-n ingress-nginx --timeout 5m
# Lower the number of worker processes
kubectl patch cm/ingress-nginx-controller \
--type merge \
-p '{"data":{"worker-processes":"1"}}' \
-n ingress-nginx
# Modify /etc/hosts to resolve hostnames
ip_address=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ci-${{ github.run_id }}-control-plane)
echo "$ip_address testing.cryostat" | sudo tee -a /etc/hosts
- name: Install Operator Lifecycle Manager
run: curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/install.sh | bash -s v0.28.0
- name: Install Cert Manager
run: make cert_manager
- uses: redhat-actions/podman-login@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
auth_file_path: $HOME/.docker/config.json
- name: Run scorecard tests
run: |
SCORECARD_REGISTRY_SERVER="ghcr.io" \
SCORECARD_REGISTRY_USERNAME="${{ github.repository_owner }}" \
SCORECARD_REGISTRY_PASSWORD="${{ secrets.GITHUB_TOKEN }}" \
BUNDLE_IMG="${{ steps.push-bundle-to-ghcr.outputs.registry-path }}" \
make test-scorecard
- name: Set latest commit status as ${{ job.status }}
uses: myrotvorets/set-commit-status-action@master
if: always()
with:
sha: ${{ inputs.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
context: ${{ github.job }}