Skip to content

Commit cc0f23b

Browse files
Merge pull request #88 from davgordo/osdk-upgrade
upgrade osdk to 1.22.2
2 parents fd22003 + 7f2c2d8 commit cc0f23b

File tree

11 files changed

+1150
-537
lines changed

11 files changed

+1150
-537
lines changed

.github/workflows/go-module-pr.yml

Lines changed: 312 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,312 @@
1+
name: go-module-pr
2+
on:
3+
workflow_call:
4+
inputs:
5+
OPERATOR_SDK_VERSION:
6+
description: "Version of Operator SDK Binary for installation"
7+
default: "v1.9.0"
8+
required: false
9+
type: string
10+
BUILD_PLATFORMS:
11+
description: 'Comma separated list of targets for builds e.g. "linux/amd64,linux/arm64,linux/ppc64le,linux/s390x"'
12+
default: "linux/amd64,linux/arm64,linux/ppc64le,linux/s390x"
13+
required: false
14+
type: string
15+
GO_VERSION:
16+
description: "Go version to use"
17+
default: "~1.16"
18+
required: false
19+
type: string
20+
RUN_UNIT_TESTS:
21+
description: "Run unit tests will run the test target in the Makefile"
22+
default: false
23+
required: false
24+
type: boolean
25+
env:
26+
DEFAULT_BUNDLE_VERSION: "0.0.1"
27+
DEFAULT_BUNDLE_CHANNEL: "alpha"
28+
DEFAULT_OPERATOR_VERSION: "latest"
29+
DEFAULT_HELMCHART_VERSION: "v0.0.1"
30+
HELM_REPO_DIR: "./tmp/gh-pages"
31+
32+
jobs:
33+
setup:
34+
runs-on: ubuntu-latest
35+
name: setup
36+
steps:
37+
- name: Setting Workflow Variables
38+
id: set-variables
39+
env:
40+
BUILD_PLATFORMS: ${{ inputs.BUILD_PLATFORMS }}
41+
run: |
42+
echo "::set-output name=repository_name::$(basename $GITHUB_REPOSITORY)"
43+
echo "::set-output name=bin_dir::$(pwd)/bin"
44+
45+
# Create Distribution Matrix
46+
echo "::set-output name=dist_matrix::$(echo -n "${{ env.BUILD_PLATFORMS }}" | jq -csR '. | split(",")')"
47+
# Create Image Tags
48+
echo "::set-output name=image_platform_tags::$(echo $BUILD_PLATFORMS | sed -e 's/,/ /g' -e 's/\//-/g')"
49+
50+
- name: Setting Image Variables
51+
id: set-variables-image
52+
run: |
53+
if [ "${{ secrets.OPERATOR_IMAGE_REPOSITORY }}" == "" ]; then
54+
echo "::set-output name=operator_image_repository_name::${{ steps.set-variables.outputs.repository_name }}"
55+
echo "::set-output name=operator_image_registry::quay.io/$(dirname $GITHUB_REPOSITORY)"
56+
else
57+
OPERATOR_IMAGE_REPOSITORY="${{ secrets.OPERATOR_IMAGE_REPOSITORY }}"
58+
echo "::set-output name=operator_image_repository_name::${OPERATOR_IMAGE_REPOSITORY##*/}"
59+
echo "::set-output name=operator_image_registry::${OPERATOR_IMAGE_REPOSITORY%/*}"
60+
fi
61+
62+
if [ "${{ secrets.BUNDLE_IMAGE_REPOSITORY }}" == "" ]; then
63+
echo "::set-output name=bundle_image_repository_name::${{ steps.set-variables.outputs.repository_name }}-bundle"
64+
echo "::set-output name=bundle_image_registry::quay.io/$(dirname $GITHUB_REPOSITORY)"
65+
66+
else
67+
BUNDLE_IMAGE_REPOSITORY="${{ secrets.BUNDLE_IMAGE_REPOSITORY }}"
68+
echo "::set-output name=bundle_image_repository_name::${BUNDLE_IMAGE_REPOSITORY##*/}"
69+
echo "::set-output name=bundle_image_registry::${BUNDLE_IMAGE_REPOSITORY%/*}"
70+
fi
71+
72+
# Set versions based on presence of tag
73+
if [[ "${{ github.ref }}" =~ ^refs/tags/ ]]; then
74+
TAG="${GITHUB_REF/refs\/tags\//}"
75+
echo "::set-output name=tag_event::true"
76+
echo "::set-output name=operator_version::$TAG"
77+
echo "::set-output name=bundle_version::${TAG:1}"
78+
echo "::set-output name=helmchart_version::$TAG"
79+
else
80+
echo "::set-output name=tag_event::false"
81+
echo "::set-output name=operator_version::$DEFAULT_OPERATOR_VERSION"
82+
echo "::set-output name=bundle_version::$DEFAULT_BUNDLE_VERSION"
83+
echo "::set-output name=helmchart_version::$DEFAULT_HELMCHART_VERSION"
84+
fi
85+
86+
- name: Verify Semver Bundle Version
87+
uses: rubenesp87/[email protected]
88+
with:
89+
version: "${{ steps.set-variables-image.outputs.bundle_version }}"
90+
91+
- name: Verify Semver Helm Chart Version
92+
uses: rubenesp87/[email protected]
93+
with:
94+
version: "${{ steps.set-variables-image.outputs.helmchart_version }}"
95+
96+
- name: Build Go Cache Paths
97+
id: go-cache-paths
98+
run: |
99+
echo "::set-output name=go-build::$(go env GOCACHE)"
100+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
101+
102+
- name: Set up Go 1.x
103+
uses: actions/setup-go@v1
104+
with:
105+
go-version: ${{ inputs.GO_VERSION }}
106+
107+
- name: Check out code
108+
uses: actions/checkout@v2
109+
110+
- name: Go Build Cache
111+
uses: actions/cache@v2
112+
with:
113+
path: ${{ steps.go-cache-paths.outputs.go-build }}
114+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
115+
116+
- name: Go Mod Cache
117+
uses: actions/cache@v2
118+
with:
119+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
120+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
121+
122+
- name: Go Dependencies
123+
run: go mod download
124+
125+
- name: Download Binaries
126+
env:
127+
OPERATOR_SDK_VERSION: ${{ inputs.OPERATOR_SDK_VERSION }}
128+
run: |
129+
# Create Binary Directory
130+
mkdir -p ${{ steps.set-variables.outputs.bin_dir }}
131+
132+
# Operator SDK
133+
curl -L -o ${{ steps.set-variables.outputs.bin_dir }}/operator-sdk https://github.com/operator-framework/operator-sdk/releases/download/${{ env.OPERATOR_SDK_VERSION }}/operator-sdk_linux_amd64
134+
135+
# Controller-gen
136+
make controller-gen
137+
138+
# Kustomize
139+
make kustomize
140+
141+
- name: Upload Support Binaries
142+
uses: actions/upload-artifact@v2
143+
with:
144+
name: support-binaries
145+
path: ${{ steps.set-variables.outputs.bin_dir }}
146+
147+
outputs:
148+
repository_name: ${{ steps.set-variables.outputs.repository_name }}
149+
bin_dir: ${{ steps.set-variables.outputs.bin_dir }}
150+
operator_image_repository_name: ${{ steps.set-variables-image.outputs.operator_image_repository_name}}
151+
operator_image_registry: ${{ steps.set-variables-image.outputs.operator_image_registry }}
152+
bundle_image_repository_name: ${{ steps.set-variables-image.outputs.bundle_image_repository_name }}
153+
bundle_image_registry: ${{ steps.set-variables-image.outputs.bundle_image_registry }}
154+
go_build: ${{ steps.go-cache-paths.outputs.go-build }}
155+
go_mod: ${{ steps.go-cache-paths.outputs.go-mod }}
156+
operator_version: ${{ steps.set-variables-image.outputs.operator_version }}
157+
bundle_version: ${{ steps.set-variables-image.outputs.bundle_version }}
158+
helmchart_version: ${{ steps.set-variables-image.outputs.helmchart_version }}
159+
tag_event: ${{ steps.set-variables-image.outputs.tag_event }}
160+
dist_matrix: ${{ steps.set-variables.outputs.dist_matrix }}
161+
image_platform_tags: ${{ steps.set-variables.outputs.image_platform_tags }}
162+
163+
build-operator:
164+
runs-on: ubuntu-latest
165+
name: build-operator
166+
needs: ["setup"]
167+
strategy:
168+
matrix:
169+
platform: ${{ fromJson(needs.setup.outputs.dist_matrix) }}
170+
env:
171+
REPOSITORY_NAME: ${{ needs.setup.outputs.repository_name }}
172+
OPERATOR_VERSION: ${{ needs.setup.outputs.operator_version }}
173+
BUNDLE_VERSION: ${{ needs.setup.outputs.bundle_version }}
174+
OPERATOR_IMAGE_REPOSITORY: "${{ needs.setup.outputs.operator_image_registry }}/${{ needs.setup.outputs.operator_image_repository_name }}"
175+
OPERATOR_IMAGE_REGISTRY: ${{ needs.setup.outputs.operator_image_registry }}
176+
BUNDLE_IMAGE_REPOSITORY: "${{ needs.setup.outputs.bundle_image_registry }}/${{ needs.setup.outputs.bundle_image_repository_name }}"
177+
BUNDLE_IMAGE_REGISTRY: ${{ needs.setup.outputs.bundle_image_registry }}
178+
179+
steps:
180+
- name: Set up Go 1.x
181+
uses: actions/setup-go@v1
182+
with:
183+
go-version: ${{ inputs.GO_VERSION }}
184+
185+
- name: Check out code
186+
uses: actions/checkout@v2
187+
188+
- name: Go Build Cache
189+
uses: actions/cache@v2
190+
with:
191+
path: ${{ needs.setup.outputs.go_build }}
192+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
193+
194+
- name: Go Mod Cache
195+
uses: actions/cache@v2
196+
with:
197+
path: ${{ needs.setup.outputs.go_mod }}
198+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
199+
200+
- name: Download Support Binaries
201+
uses: actions/download-artifact@v2
202+
with:
203+
name: support-binaries
204+
path: ${{ needs.setup.outputs.bin_dir }}
205+
206+
- name: Prepare Build Step
207+
id: setup-build-step
208+
run: |
209+
# Setup Path
210+
echo "${{ needs.setup.outputs.bin_dir }}" >> $GITHUB_PATH
211+
212+
# Make Binaries Executable
213+
chmod +x ${{ needs.setup.outputs.bin_dir }}/*
214+
215+
# Configure Platform Variables
216+
echo "::set-output name=platform_os::$(echo ${{ matrix.platform }} | cut -d/ -f1)"
217+
echo "::set-output name=platform_arch::$(echo ${{ matrix.platform }} | cut -d/ -f2)"
218+
219+
- name: Download Dependencies
220+
shell: bash
221+
run: |
222+
make generate
223+
make fmt
224+
make vet
225+
226+
- name: build code
227+
shell: bash
228+
env:
229+
VERSION: latest
230+
GOOS: ${{ steps.setup-build-step.outputs.platform_os }}
231+
GOARCH: ${{ steps.setup-build-step.outputs.platform_arch }}
232+
run: make
233+
234+
- name: Set up QEMU
235+
uses: docker/setup-qemu-action@v1
236+
237+
- name: Set up Docker Buildx
238+
uses: docker/setup-buildx-action@v1
239+
with:
240+
buildkitd-flags: --debug
241+
242+
- name: "Build Operator Image"
243+
uses: docker/build-push-action@v2
244+
with:
245+
context: .
246+
file: "./ci.Dockerfile"
247+
platforms: ${{ matrix.platform }}
248+
push: false
249+
tags: "${{ env.OPERATOR_IMAGE_REPOSITORY }}:latest-${{ steps.setup-build-step.outputs.platform_os }}-${{ steps.setup-build-step.outputs.platform_arch }},${{ env.OPERATOR_IMAGE_REPOSITORY }}:${{ env.OPERATOR_VERSION }}-${{ steps.setup-build-step.outputs.platform_os }}-${{ steps.setup-build-step.outputs.platform_arch }}"
250+
251+
- name: Prepare Distribution Artifacts
252+
shell: bash
253+
run: |
254+
# Create Distribution Directory
255+
mkdir dist
256+
257+
# Move and Rename Manager Binary
258+
mv bin/manager dist/${{ env.REPOSITORY_NAME }}-manager-${{ env.OPERATOR_VERSION }}-${{ steps.setup-build-step.outputs.platform_os }}-${{ steps.setup-build-step.outputs.platform_arch }}
259+
260+
- name: Upload Dist
261+
uses: actions/upload-artifact@v2
262+
with:
263+
name: dist
264+
path: dist
265+
266+
test-operator:
267+
runs-on: ubuntu-latest
268+
name: test-operator
269+
if: ${{ inputs.RUN_UNIT_TESTS }}
270+
needs: ["setup"]
271+
env:
272+
REPOSITORY_NAME: ${{ needs.setup.outputs.repository_name }}
273+
steps:
274+
- name: Set up Go 1.x
275+
uses: actions/setup-go@v1
276+
with:
277+
go-version: ${{ inputs.GO_VERSION }}
278+
279+
- name: Check out code
280+
uses: actions/checkout@v2
281+
282+
- name: Go Build Cache
283+
uses: actions/cache@v2
284+
with:
285+
path: ${{ needs.setup.outputs.go_build }}
286+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
287+
288+
- name: Go Mod Cache
289+
uses: actions/cache@v2
290+
with:
291+
path: ${{ needs.setup.outputs.go_mod }}
292+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
293+
294+
- name: Download Binaries
295+
uses: actions/download-artifact@v2
296+
with:
297+
name: support-binaries
298+
path: ${{ needs.setup.outputs.bin_dir }}
299+
300+
- name: Prepare Build Step
301+
id: setup-build-step
302+
run: |
303+
# Setup Path
304+
echo "${{ needs.setup.outputs.bin_dir }}" >> $GITHUB_PATH
305+
306+
# Make Binaries Executable
307+
chmod +x ${{ needs.setup.outputs.bin_dir }}/*
308+
309+
- name: Run unit tests
310+
shell: bash
311+
if: ${{ inputs.RUN_UNIT_TESTS }}
312+
run: make test

0 commit comments

Comments
 (0)