Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Scorecard testing in Makefile #141

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions .github/workflows/pre-submit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs: # jobs to run
runs-on: ubuntu-22.04 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go # https://github.com/actions/setup-go/blob/main/action.yml
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
Expand All @@ -35,3 +35,40 @@ jobs: # jobs to run

- name: Build Images
run: make container-build-community

scorecard-k8s:
name: Test Scorecard Tests # https://sdk.operatorframework.io/docs/testing-operators/scorecard/
runs-on: ubuntu-22.04
env:
# see https://github.com/kubernetes-sigs/kind/tags
KIND_VERSION: v0.22.0
# see https://hub.docker.com/r/kindest/node/tags for available versions!
K8S_VERSION: v1.27.11
FAR_VERSION: 0.3.0
FAR_PREVIOUS_VERSION: 0.2.1

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Start kind cluster
uses: container-tools/kind-action@v2
with:
version: ${{env.KIND_VERSION}}
config: ./hack/kind-scorecard-config.yaml
node_image: kindest/node:${{env.K8S_VERSION}}
kubectl_version: ${{env.K8S_VERSION}}
registry: true

- name: Cluster info
run: |
kubectl version -o=yaml
kubectl cluster-info
kubectl get nodes -o=wide
- name: Build bundle-community
run: PREVIOUS_VERSION=${{env.FAR_PREVIOUS_VERSION}} VERSION=${{env.FAR_VERSION}} make bundle-community

- name: Run scorecard tests
run: OPERATOR_NAMESPACE=default make test-scorecard
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ catalog-push: ## Push a catalog image.
verify-unchanged: ## Verify there are no un-committed changes
./hack/verify-unchanged.sh

.PHONY: test-scorecard
test-scorecard: operator-sdk ## Run Scorecard testing for the bundle directory on OPERATOR_NAMESPACE
$(OPERATOR_SDK) scorecard ./bundle -n $(OPERATOR_NAMESPACE)

.PHONY: container-build
container-build: docker-build bundle-build ## Build containers

Expand Down Expand Up @@ -462,8 +466,6 @@ test-e2e: ginkgo ## Run end to end (E2E) tests
.PHONY: bundle-reset
bundle-reset:
VERSION=0.0.1 $(MAKE) manifests bundle
# empty creation date
sed -r -i "s|createdAt: .*|createdAt: \"\"|;" ${BUNDLE_CSV}

.PHONY: full-gen
full-gen: go-verify manifests generate manifests fmt bundle fix-imports bundle-reset ## generates all automatically generated content
full-gen: go-verify manifests generate manifests fmt bundle fix-imports bundle-reset ## generates all automatically generated content
5 changes: 5 additions & 0 deletions hack/kind-scorecard-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# One control plane node cluster config for k8s e2e test in github workflow!
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
Loading