kind #4712
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright 2023 IBM Corporation | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http:#www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: kind | |
on: | |
workflow_dispatch: {} | |
pull_request: {} | |
schedule: | |
- cron: "0 0 * * *" | |
push: | |
branches: | |
- master | |
env: | |
GO_VERSION: "1.21" | |
jobs: | |
scorecard: | |
name: Scorecrd tests | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Set up Go ${{ env.GO_VERSION }} | |
uses: actions/[email protected] | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Build | |
run: | | |
make build | |
curl -Lo ./operator-sdk "https://github.com/operator-framework/operator-sdk/releases/download/v1.25.2/operator-sdk_linux_amd64" | |
curl -Lo ./kind "https://kind.sigs.k8s.io/dl/v0.17.0/kind-$(uname)-amd64" | |
chmod +x ./operator-sdk | |
chmod +x ./kind | |
./kind create cluster --image kindest/node:v1.24.15 | |
./kind get clusters | |
kubectl config get-contexts | |
kubectl config set-context kind-kind | |
export PATH=`pwd`:$PATH | |
- name: Install OLM | |
run: | | |
kubectl apply -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.19.1/crds.yaml | |
kubectl apply -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.19.1/olm.yaml | |
- name: Deploy Operators YAML | |
env: | |
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} | |
ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }} | |
LICENSING_NAMESPACE: ibm-licensing | |
run: | | |
kubectl create namespace ${LICENSING_NAMESPACE} | |
n=0; until ((n >= 60)); do kubectl -n ${LICENSING_NAMESPACE} get serviceaccount default -o name && break; n=$((n + 1)); sleep 60; done; ((n < 60)) | |
kubectl create secret docker-registry my-registry-token -n ${LICENSING_NAMESPACE} --docker-server=docker-na-public.artifactory.swg-devops.com --docker-username=${ARTIFACTORY_USERNAME} --docker-password=${ARTIFACTORY_TOKEN} | |
kubectl apply -f ./bundle/manifests/operator.ibm.com_ibmlicensings.yaml | |
kubectl apply -f ./config/rbac/service_account.yaml -n ${LICENSING_NAMESPACE} | |
kubectl -n ${LICENSING_NAMESPACE} patch serviceaccount ibm-licensing-operator -p '{"imagePullSecrets": [{"name": "my-registry-token"}]}' | |
kubectl apply -f ./config/rbac/role.yaml | |
kubectl apply -f ./config/rbac/role_binding.yaml | |
kubectl apply -f ./config/rbac/role_operands.yaml | |
kubectl get sa -n ${LICENSING_NAMESPACE} | |
- name: Run Scorecard tests | |
run: | | |
export PATH=`pwd`:$PATH | |
set -o pipefail | |
make scorecard 2>&1 | tee ./scorecard_logs.txt | |
- name: Archive scorecard logs | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: scorecard results | |
path: ./*.txt | |
setup-build-publish-deploy: | |
name: Operator tests on KinD | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
k8s: [v1.24.7, v1.25.3, v1.26.0] | |
steps: | |
- name: Set up Go ${{ env.GO_VERSION }} | |
uses: actions/[email protected] | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Login to Artifactory | |
uses: docker/login-action@v1 | |
with: | |
registry: docker-na-public.artifactory.swg-devops.com | |
username: ${{ secrets.ARTIFACTORY_USERNAME }} | |
password: ${{ secrets.ARTIFACTORY_TOKEN }} | |
- name: Download binaries | |
run: | | |
wget https://github.com/kubernetes-sigs/kind/releases/download/v0.17.0/kind-linux-amd64 | |
mv ./kind-linux-amd64 ./kind | |
chmod +x ./kind | |
cp ./common/scripts/tests/kind_config.yaml ./ | |
./kind create cluster --image kindest/node:${{ matrix.k8s }} --config ./kind_config.yaml --name tests | |
kubectl config set-context kind-tests | |
kubectl get nodes | |
- name: Test Unit Operator - License Service | |
env: | |
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} | |
ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }} | |
run: | | |
export PATH=`pwd`:$PATH | |
export SUFIX=$RANDOM | |
export USE_EXISTING_CLUSTER=true | |
set -o pipefail | |
make unit-test 2>&1 | tee ./unittest_logs_${{ matrix.k8s }}.txt | |
- name: Check all pods | |
if: always() | |
run: | | |
export PATH=`pwd`:$PATH | |
kubectl config set-context kind-tests | |
kubectl describe pods --all-namespaces > ./pods_${{ matrix.k8s }}.txt 2>&1 | |
- name: Archive logs | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: operator results ${{matrix.k8s}} | |
path: ./*.txt | |