Skip to content

Commit d530252

Browse files
Merge pull request #34 from RedHatGov/bugfix/replace_travis
- Replace Travis with GitHub Actions. - Update Operator SDK base to 1.4.2 - Some improvements to testing methodology - Update to new osdk-manager - Some Lint fixes - Explicitly namespace modules in role
2 parents db97b70 + 84d2549 commit d530252

File tree

24 files changed

+245
-111
lines changed

24 files changed

+245
-111
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Run Operator SDK tests, release new operator images if tests succeed
2+
3+
on:
4+
schedule:
5+
- cron: '0 1 * * *' # everyday at 1am
6+
push:
7+
branches:
8+
- develop
9+
- main
10+
pull_request:
11+
branches:
12+
- develop
13+
14+
jobs:
15+
test-cluster:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
with:
21+
submodules: recursive
22+
- name: Kind
23+
uses: engineerd/[email protected]
24+
with:
25+
config: molecule/kind-cluster/files/kind-config.yml
26+
name: osdk-test
27+
version: v0.9.0
28+
- name: Prereq setup
29+
run: hack/ci-setup.sh
30+
- name: Test
31+
run: hack/ci-test.sh kind-cluster
32+
33+
test-namespace:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v2
38+
with:
39+
submodules: recursive
40+
- name: Kind
41+
uses: engineerd/[email protected]
42+
with:
43+
config: molecule/kind-cluster/files/kind-config.yml
44+
name: osdk-test
45+
version: v0.9.0
46+
- name: Prereq setup
47+
run: hack/ci-setup.sh
48+
- name: Test
49+
run: hack/ci-test.sh kind-namespace
50+
51+
release:
52+
needs: [test-cluster, test-namespace]
53+
if: >
54+
github.event_name != 'pull_request' &&
55+
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v2
60+
with:
61+
submodules: recursive
62+
- name: Login to Quay
63+
if: github.event_name != 'pull_request'
64+
uses: docker/login-action@v1
65+
with:
66+
registry: quay.io
67+
username: ${{ secrets.QUAY_USERNAME }}
68+
password: ${{ secrets.QUAY_PASSWORD }}
69+
- name: Build, bundle, and push (develop)
70+
run: |
71+
hack/operate.sh --push-images --bundle --develop --verbose --formatter
72+
if: github.ref == 'refs/heads/develop'
73+
- name: Build, bundle, and push
74+
run: |
75+
hack/operate.sh --push-images --bundle --extra-tag=latest --verbose --formatter
76+
if: github.ref == 'refs/heads/main'

.travis.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM quay.io/operator-framework/ansible-operator:v1.0.0
1+
FROM quay.io/operator-framework/ansible-operator:v1.4.2
22

33
COPY requirements.yml ${HOME}/requirements.yml
44
RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \

Makefile

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
1-
# Current Operator version
1+
# VERSION defines the project version for the bundle.
2+
# Update this value when you upgrade the version of your project.
3+
# To re-generate a bundle for another specific version without changing the standard setup, you can:
4+
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
5+
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
26
VERSION ?= 0.0.1
3-
# Default bundle image tag
4-
BUNDLE_IMG ?= controller-bundle:$(VERSION)
5-
# Options for 'bundle-build'
7+
8+
# CHANNELS define the bundle channels used in the bundle.
9+
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "preview,fast,stable")
10+
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
11+
# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=preview,fast,stable)
12+
# - use environment variables to overwrite this value (e.g export CHANNELS="preview,fast,stable")
613
ifneq ($(origin CHANNELS), undefined)
714
BUNDLE_CHANNELS := --channels=$(CHANNELS)
815
endif
16+
17+
# DEFAULT_CHANNEL defines the default channel used in the bundle.
18+
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
19+
# To re-generate a bundle for any other default channel without changing the default setup, you can:
20+
# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable)
21+
# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable")
922
ifneq ($(origin DEFAULT_CHANNEL), undefined)
1023
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
1124
endif
1225
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
1326

27+
# BUNDLE_IMG defines the image:tag used for the bundle.
28+
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
29+
BUNDLE_IMG ?= controller-bundle:$(VERSION)
30+
1431
# Image URL to use all building/pushing image targets
1532
IMG ?= controller:latest
1633

@@ -41,43 +58,49 @@ undeploy: kustomize
4158

4259
# Build the docker image
4360
docker-build:
44-
docker build . -t ${IMG}
61+
docker build -t ${IMG} .
4562

4663
# Push the docker image
4764
docker-push:
4865
docker push ${IMG}
4966

5067
PATH := $(PATH):$(PWD)/bin
5168
SHELL := env PATH=$(PATH) /bin/sh
52-
OS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
53-
ARCH = $(shell uname -m | sed 's/x86_64/amd64/')
54-
OSOPER = $(shell uname -s | tr '[:upper:]' '[:lower:]' | sed 's/darwin/apple-darwin/' | sed 's/linux/linux-gnu/')
55-
ARCHOPER = $(shell uname -m )
69+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
70+
ARCH := $(shell uname -m | sed 's/x86_64/amd64/')
5671

72+
# Download kustomize locally if necessary, preferring the $(pwd)/bin path over global if both exist.
73+
.PHONY: kustomize
74+
KUSTOMIZE = $(shell pwd)/bin/kustomize
5775
kustomize:
58-
ifeq (, $(shell which kustomize 2>/dev/null))
76+
ifeq (,$(wildcard $(KUSTOMIZE)))
77+
ifeq (,$(shell which kustomize 2>/dev/null))
5978
@{ \
6079
set -e ;\
61-
mkdir -p bin ;\
62-
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.5.4/kustomize_v3.5.4_$(OS)_$(ARCH).tar.gz | tar xzf - -C bin/ ;\
80+
mkdir -p $(dir $(KUSTOMIZE)) ;\
81+
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.5.4/kustomize_v3.5.4_$(OS)_$(ARCH).tar.gz | \
82+
tar xzf - -C bin/ ;\
6383
}
64-
KUSTOMIZE=$(realpath ./bin/kustomize)
6584
else
66-
KUSTOMIZE=$(shell which kustomize)
85+
KUSTOMIZE = $(shell which kustomize)
86+
endif
6787
endif
6888

89+
# Download ansible-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
90+
.PHONY: ansible-operator
91+
ANSIBLE_OPERATOR = $(shell pwd)/bin/ansible-operator
6992
ansible-operator:
70-
ifeq (, $(shell which ansible-operator 2>/dev/null))
93+
ifeq (,$(wildcard $(ANSIBLE_OPERATOR)))
94+
ifeq (,$(shell which ansible-operator 2>/dev/null))
7195
@{ \
7296
set -e ;\
73-
mkdir -p bin ;\
74-
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/v1.0.0/ansible-operator-v1.0.0-$(ARCHOPER)-$(OSOPER) ;\
75-
mv ansible-operator-v1.0.0-$(ARCHOPER)-$(OSOPER) ./bin/ansible-operator ;\
76-
chmod +x ./bin/ansible-operator ;\
97+
mkdir -p $(dir $(ANSIBLE_OPERATOR)) ;\
98+
curl -sSLo $(ANSIBLE_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.4.2/ansible-operator_$(OS)_$(ARCH) ;\
99+
chmod +x $(ANSIBLE_OPERATOR) ;\
77100
}
78-
ANSIBLE_OPERATOR=$(realpath ./bin/ansible-operator)
79101
else
80-
ANSIBLE_OPERATOR=$(shell which ansible-operator)
102+
ANSIBLE_OPERATOR = $(shell which ansible-operator)
103+
endif
81104
endif
82105

83106
# Generate bundle manifests and metadata, then validate generated files.

PROJECT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ resources:
66
kind: Gitea
77
version: v1alpha1
88
version: 3-alpha
9+
plugins:
10+
manifests.sdk.operatorframework.io/v2: {}
11+
scorecard.sdk.operatorframework.io/v2: {}

config/manager/manager.yaml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,29 @@ spec:
2323
control-plane: controller-manager
2424
spec:
2525
containers:
26-
- name: manager
27-
args:
28-
- "--enable-leader-election"
29-
- "--leader-election-id=gitea-operator"
30-
image: controller:latest
31-
env:
32-
- name: WATCH_NAMESPACE
33-
valueFrom:
34-
fieldRef:
35-
fieldPath: metadata.annotations['olm.targetNamespaces']
26+
- name: manager
27+
args:
28+
- "--enable-leader-election"
29+
- "--leader-election-id=gitea-operator"
30+
image: controller:latest
31+
env:
32+
- name: ANSIBLE_GATHERING
33+
value: explicit
34+
- name: WATCH_NAMESPACE
35+
valueFrom:
36+
fieldRef:
37+
fieldPath: metadata.annotations['olm.targetNamespaces']
38+
livenessProbe:
39+
httpGet:
40+
path: /readyz
41+
port: 6789
42+
initialDelaySeconds: 15
43+
periodSeconds: 20
44+
readinessProbe:
45+
httpGet:
46+
path: /healthz
47+
port: 6789
48+
initialDelaySeconds: 5
49+
periodSeconds: 10
3650
terminationGracePeriodSeconds: 10
3751
serviceAccountName: gitea-operator-sa

config/scorecard/patches/basic.config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
entrypoint:
55
- scorecard-test
66
- basic-check-spec
7-
image: quay.io/operator-framework/scorecard-test:master
7+
image: quay.io/operator-framework/scorecard-test:v1.4.2
88
labels:
99
suite: basic
1010
test: basic-check-spec-test

config/scorecard/patches/olm.config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
entrypoint:
55
- scorecard-test
66
- olm-bundle-validation
7-
image: quay.io/operator-framework/scorecard-test:master
7+
image: quay.io/operator-framework/scorecard-test:v1.4.2
88
labels:
99
suite: olm
1010
test: olm-bundle-validation-test
@@ -14,7 +14,7 @@
1414
entrypoint:
1515
- scorecard-test
1616
- olm-crds-have-validation
17-
image: quay.io/operator-framework/scorecard-test:master
17+
image: quay.io/operator-framework/scorecard-test:v1.4.2
1818
labels:
1919
suite: olm
2020
test: olm-crds-have-validation-test
@@ -24,7 +24,7 @@
2424
entrypoint:
2525
- scorecard-test
2626
- olm-crds-have-resources
27-
image: quay.io/operator-framework/scorecard-test:master
27+
image: quay.io/operator-framework/scorecard-test:v1.4.2
2828
labels:
2929
suite: olm
3030
test: olm-crds-have-resources-test
@@ -34,7 +34,7 @@
3434
entrypoint:
3535
- scorecard-test
3636
- olm-spec-descriptors
37-
image: quay.io/operator-framework/scorecard-test:master
37+
image: quay.io/operator-framework/scorecard-test:v1.4.2
3838
labels:
3939
suite: olm
4040
test: olm-spec-descriptors-test
@@ -44,7 +44,7 @@
4444
entrypoint:
4545
- scorecard-test
4646
- olm-status-descriptors
47-
image: quay.io/operator-framework/scorecard-test:master
47+
image: quay.io/operator-framework/scorecard-test:v1.4.2
4848
labels:
4949
suite: olm
5050
test: olm-status-descriptors-test

hack/ci-setup.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash -ex
2+
# Installs dependencies needed to run the tests in CI environment
3+
4+
5+
mkdir -p $HOME/.local/bin
6+
export PATH="$HOME/.local/bin:$PATH"
7+
export KUBECONFIG=$HOME/.kube/config
8+
9+
# Basic pip prereqs
10+
pip3 install --user --upgrade setuptools wheel pip
11+
12+
# Dependencies for test environment
13+
pip3 install --user docker==4.2.2 ansible molecule ansible-lint yamllint flake8 openshift jmespath
14+
15+
# Ansible dependencies
16+
ansible-galaxy collection install -r requirements.yml
17+
18+
# Kind CLI (for loading images into cluster)
19+
curl -Lo $HOME/.local/bin/kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-linux-amd64
20+
chmod +x $HOME/.local/bin/kind
21+
22+
# Helm CLI (for loading Ingress)
23+
curl -Lo $HOME/helm.tgz https://get.helm.sh/helm-v3.5.2-linux-amd64.tar.gz
24+
tar xvzf $HOME/helm.tgz -C $HOME/.local/bin --strip-components 1 linux-amd64/helm
25+
helm repo add stable https://charts.helm.sh/stable

hack/ci-test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash -ex
2+
# Exports correct environment for the CI system (relies on ci-setup.sh) and runs requested tests
3+
4+
export KUBECONFIG=$HOME/.kube/config
5+
export PATH="$HOME/.local/bin:$PATH"
6+
export OPERATORDIR="$(pwd)"
7+
make kustomize
8+
[ -f ./bin/kustomize ] && export KUSTOMIZE_PATH="$(realpath ./bin/kustomize)" || export KUSTOMIZE_PATH="$(which kustomize)"
9+
10+
TEST_OPERATOR_NAMESPACE=default molecule test -s $1

0 commit comments

Comments
 (0)