-
Notifications
You must be signed in to change notification settings - Fork 69
222 lines (194 loc) · 8.69 KB
/
validate.yaml
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
---
name: Validate
on:
push:
branches:
- 'main'
- 'release-*'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'main'
- 'release-*'
schedule:
- cron: "0 6 * * *" # Daily at 06:00.
workflow_dispatch: # Manual workflow trigger
jobs:
generated-files-committed:
name: Generated files are committed
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
steps:
- name: Setup Golang
uses: openshift-knative/hack/actions/setup-go@main
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
# Installs the latest release of oc with the major version 4.
oc: "4"
- name: Install yq
run: |
go install github.com/mikefarah/yq/v3@latest
- name: Install OPM
run: |
go install github.com/operator-framework/operator-registry/cmd/[email protected]
- name: Checkout
uses: actions/checkout@v4
with:
path: ./src/github.com/${{ github.repository }}
fetch-depth: 0
- name: Merge upstream
if: github.event_name == 'pull_request'
working-directory: ./src/github.com/${{ github.repository }}
run: |
if ! git config user.name > /dev/null; then
git config user.name "John Doe"
fi
if ! git config user.email > /dev/null; then
git config user.email "johndoe@localhost"
fi
git remote add upstream https://github.com/${{ github.repository }}.git
git pull --no-rebase upstream ${{ github.base_ref }}
shell: bash
- name: Set CURRENT_VERSION_IMAGES
working-directory: ./src/github.com/${{ github.repository }}
if: (github.event_name == 'pull_request' && github.base_ref != 'main') || ((github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref_name != 'main')
run: |
tag="release-$(yq read ./olm-catalog/serverless-operator/project.yaml 'project.version')"
echo "CURRENT_VERSION_IMAGES=${tag}" >> $GITHUB_ENV
shell: bash
- name: Regenerate all generated files
working-directory: ./src/github.com/${{ github.repository }}
run: make generated-files
# Generate catalog only if not triggered by a pull request. Credentials are not available in pre-submit phase.
- name: Regenerate file-based catalog
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || ( github.event_name == 'push' && !contains(github.ref_name, 'dependabot/') )
working-directory: ./src/github.com/${{ github.repository }}
env:
REGISTRY_REDHAT_IO_USERNAME: ${{ secrets.REGISTRY_REDHAT_IO_USERNAME }}
REGISTRY_REDHAT_IO_PASSWORD: ${{ secrets.REGISTRY_REDHAT_IO_PASSWORD }}
run: make generate-catalog
- name: Regenerate override-snapshot
working-directory: ./src/github.com/${{ github.repository }}
run: make generate-override-snapshot
# Optional:
# Since we're generating files based on a floating branch in midstream,
# we need to reconcile those files periodically.
#
# when it's manually triggered or a scheduled run.
- name: Create Pull Request
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || ( github.event_name == 'push' && !contains(github.ref_name, 'dependabot/') )
uses: peter-evans/create-pull-request@v7
with:
path: ./src/github.com/${{ github.repository }}
branch: auto/update-generated-files-${{ github.ref_name }}
title: "[${{ github.ref_name }}] Run make generated-files"
commit-message: "Run make generated-files"
delete-branch: true
body: |
Generated by running `make generated-files`
- name: Check if everything is consistent
working-directory: ./src/github.com/${{ github.repository }}
run: ./hack/verify-diff.sh
- name: Check existence of skipRange and replaces in ClusterServiceVersion
working-directory: ./src/github.com/${{ github.repository }}
run: |
csv="olm-catalog/serverless-operator/manifests/serverless-operator.clusterserviceversion.yaml"
if [[ "$(GOFLAGS='' go run github.com/mikefarah/yq/v3@latest read "$csv" spec.replaces)" == "" || \
"$(GOFLAGS='' go run github.com/mikefarah/yq/v3@latest read "$csv" 'metadata.annotations."olm.skipRange"')" == "" ]]; then
echo '::error:: Missing spec.replaces or metadata.annotations."olm.skipRange" in CSV.'
exit 34
fi
lint:
name: Lint
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
steps:
- name: Setup Golang
uses: openshift-knative/hack/actions/setup-go@main
- name: Checkout
uses: actions/checkout@v4
with:
path: ./src/github.com/${{ github.repository }}
- name: Install Tools
working-directory: ./src/github.com/${{ github.repository }}
env:
WOKE_VERSION: v0.13.0
OSDK_VERSION: v1.12.0
run: |
TEMP_PATH="$(mktemp -d)"
cd $TEMP_PATH
echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" 2>&1
echo '::endgroup::'
echo '::group:: Installing misspell ... https://github.com/client9/misspell'
go install github.com/client9/misspell/cmd/misspell@latest
echo '::endgroup::'
echo '::group:: Installing woke ... https://github.com/get-woke/woke'
curl -sfL https://raw.githubusercontent.com/get-woke/woke/main/install.sh | sh -s -- -b "${TEMP_PATH}" "${WOKE_VERSION}" 2>&1
echo '::endgroup::'
echo '::group:: Installing operator-sdk ... https://github.com/operator-framework/operator-sdk/'
curl -sfL https://github.com/operator-framework/operator-sdk/releases/download/${OSDK_VERSION}/operator-sdk_linux_amd64 -o "${TEMP_PATH}/operator-sdk"
chmod +x "${TEMP_PATH}/operator-sdk"
echo "${TEMP_PATH}" >> $GITHUB_PATH
- name: Shellcheck
working-directory: ./src/github.com/${{ github.repository }}
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
find . -type f \
-path './**/*.*sh' \
-not -path '*vendor*' | xargs -r shellcheck --format=checkstyle \
| reviewdog -f=checkstyle \
-name="shellcheck" \
-reporter="github-pr-check" \
-filter-mode="added" \
-fail-on-error="true" \
-level="error"
- name: Go Lint - knative-operator
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
args: --timeout=10m0s --verbose
working-directory: ./src/github.com/${{ github.repository }}
# This is mostly copied from https://github.com/get-woke/woke-action-reviewdog/blob/main/entrypoint.sh
# since their action is not yet released under a stable version.
- name: Language
if: ${{ always() && github.event_name == 'pull_request' }}
working-directory: ./src/github.com/${{ github.repository }}
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
woke --output simple \
| reviewdog -efm="%f:%l:%c: %m" \
-name="woke" \
-reporter="github-pr-check" \
-filter-mode="added" \
-fail-on-error="true" \
-level="error"
- name: OLM Bundle
working-directory: ./src/github.com/${{ github.repository }}
run: |
operator-sdk bundle validate ./olm-catalog/serverless-operator --select-optional suite=operatorframework --optional-values=k8s-version=1.22
- name: Spelling
working-directory: ./src/github.com/${{ github.repository }}
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
# Don't fail because of misspell
set +o pipefail
git ls-files | grep -Ev '^(vendor/|.git)' | xargs misspell -i importas -error \
| reviewdog -efm="%f:%l:%c: %m" \
-name="github.com/client9/misspell" \
-reporter="github-pr-check" \
-filter-mode="added" \
-fail-on-error="true" \
-level="error"
- name: Prettify code
uses: creyD/[email protected]
with:
dry: true
prettier_options: --check src/github.com/${{ github.repository }}/templates/*.yaml