Skip to content

Commit

Permalink
ci: add manifests and codegen validation in pull request
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinandan Purkait <purkaitabhinandan@gmail.com>
  • Loading branch information
Abhinandan-Purkait committed Jul 29, 2024
1 parent 5b13ad9 commit 592d6e5
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 11 deletions.
40 changes: 39 additions & 1 deletion .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,50 @@ jobs:
run: |
ct lint --config ct.yaml
validate_codegen:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/go
GOBIN: ${{ github.workspace }}/go/bin
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/openebs/zfs-localpv
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.GOPATH }}/src/github.com/openebs/zfs-localpv

- name: Set up Go 1.19
uses: actions/setup-go@v4
with:
go-version: 1.19.9
cache: false

- name: Helm tool installer
uses: Azure/setup-helm@v4.2.0

- name: Verify kubegen
run: |
make verify-kubegen
- name: Verify manifests
run: |
make verify-manifests
unit-tests:
runs-on: ubuntu-latest
needs: ["lint", "validate_codegen"]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go 1.19
uses: actions/setup-go@v4
with:
go-version: 1.19.9
cache: false

- name: Unit test
run: make test

Expand Down Expand Up @@ -111,7 +149,7 @@ jobs:

csi-driver:
runs-on: ubuntu-latest
needs: ["lint", "bdd-tests"]
needs: ["bdd-tests"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
41 changes: 40 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- uses: rrbutani/use-nix-shell-action@v1.1.0
with:
file: shell.nix

- name: Check if the chart follows a valid semver version
run: |
branch_name="${{ github.event.pull_request.base.ref }}"
Expand All @@ -42,12 +43,50 @@ jobs:
run: |
ct lint --config ct.yaml
validate_codegen:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/go
GOBIN: ${{ github.workspace }}/go/bin
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/openebs/zfs-localpv
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.GOPATH }}/src/github.com/openebs/zfs-localpv

- name: Set up Go 1.19
uses: actions/setup-go@v4
with:
go-version: 1.19.9
cache: false

- name: Helm tool installer
uses: Azure/setup-helm@v4.2.0

- name: Verify kubegen
run: |
make verify-kubegen
- name: Verify manifests
run: |
make verify-manifests
unit-tests:
runs-on: ubuntu-latest
needs: ["lint", "validate_codegen"]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go 1.19
uses: actions/setup-go@v4
with:
go-version: 1.19.9
cache: false

- name: Unit test
run: make test

Expand Down Expand Up @@ -118,7 +157,7 @@ jobs:

csi-driver:
runs-on: ubuntu-latest
needs: ["lint", "bdd-tests"]
needs: ["bdd-tests"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
40 changes: 39 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,50 @@ jobs:
run: |
ct lint --config ct.yaml
validate_codegen:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/go
GOBIN: ${{ github.workspace }}/go/bin
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/openebs/zfs-localpv
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.GOPATH }}/src/github.com/openebs/zfs-localpv

- name: Set up Go 1.19
uses: actions/setup-go@v4
with:
go-version: 1.19.9
cache: false

- name: Helm tool installer
uses: Azure/setup-helm@v4.2.0

- name: Verify kubegen
run: |
make verify-kubegen
- name: Verify manifests
run: |
make verify-manifests
unit-tests:
runs-on: ubuntu-latest
needs: ["lint", "validate_codegen"]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go 1.19
uses: actions/setup-go@v4
with:
go-version: 1.19.9
cache: false

- name: Unit test
run: make test

Expand Down Expand Up @@ -104,7 +142,7 @@ jobs:

csi-driver:
runs-on: ubuntu-latest
needs: ["lint", "bdd-tests"]
needs: ["bdd-tests"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bootstrap: controller-gen

.PHONY: controller-gen
controller-gen:
TMP_DIR=$(shell mktemp -d) && cd $$TMP_DIR && go mod init tmp && go install -mod=mod sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.0 && rm -rf $$TMP_DIR;
@go install -mod=mod sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.0

# SRC_PKG is the path of code files
SRC_PKG := github.com/openebs/zfs-localpv/pkg
Expand All @@ -144,7 +144,7 @@ kubegendelete:

.PHONY: deepcopy-install
deepcopy-install:
@go install -mod=mod k8s.io/code-generator/cmd/deepcopy-gen
@go install -mod=mod k8s.io/code-generator/cmd/deepcopy-gen@v0.27.2

.PHONY: deepcopy
deepcopy:
Expand All @@ -156,7 +156,7 @@ deepcopy:

.PHONY: clientset-install
clientset-install:
@go install -mod=mod k8s.io/code-generator/cmd/client-gen
@go install -mod=mod k8s.io/code-generator/cmd/client-gen@v0.27.2

.PHONY: clientset
clientset:
Expand All @@ -170,7 +170,7 @@ clientset:

.PHONY: lister-install
lister-install:
@go install -mod=mod k8s.io/code-generator/cmd/lister-gen
@go install -mod=mod k8s.io/code-generator/cmd/lister-gen@v0.27.2

.PHONY: lister
lister:
Expand All @@ -182,7 +182,7 @@ lister:

.PHONY: informer-install
informer-install:
@go install -mod=mod k8s.io/code-generator/cmd/informer-gen
@go install -mod=mod k8s.io/code-generator/cmd/informer-gen@v0.27.2

.PHONY: informer
informer:
Expand Down Expand Up @@ -236,4 +236,14 @@ golint:
@echo "--------------------------------"
@echo ""

.PHONY: verify-manifests
verify-manifests: bootstrap manifests
@./buildscripts/check-diff.sh
@echo "Completed verify-codegen no changes detected !!"

.PHONY: verify-kubegen
verify-kubegen: bootstrap kubegen
@./buildscripts/check-diff.sh
@echo "Completed verify-codegen no changes detected !!"

include Makefile.buildx.mk
5 changes: 5 additions & 0 deletions buildscripts/check-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -e

git --no-pager diff --exit-code pkg/generated pkg/apis/ deploy/yamls
4 changes: 2 additions & 2 deletions buildscripts/generate-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [ "$CONTROLLER_GEN" = "" ]; then
exit 1;
fi

$CONTROLLER_GEN crd:trivialVersions=false,preserveUnknownFields=false paths=./pkg/apis/... output:crd:artifacts:config=$DEPLOY_YAML_DIR
$CONTROLLER_GEN crd:trivialVersions=false,preserveUnknownFields=false paths=./pkg/apis/... output:crd:artifacts:config="$DEPLOY_YAML_DIR"

for FILE in "$DEPLOY_YAML_DIR"/zfs.openebs.io_*; do
BASE_NAME=$(basename "$FILE" | sed -e 's/^zfs.openebs.io_//' -e 's/s\.yaml$/.yaml/')
Expand All @@ -32,4 +32,4 @@ for FILE in "$DEPLOY_YAML_DIR"/zfs.openebs.io_*; do
awk 'BEGIN { print "{{- if .Values.zfsLocalPv.enabled -}}" } { print } END { if (NR > 0) print "{{- end -}}" }' "$TARGET_FILE" > "$TARGET_FILE.tmp" && mv "$TARGET_FILE.tmp" "$TARGET_FILE"
done

helm template $RELEASE_NAME $HELM_CHART_DIR -n $RELEASE_NAMESPACE --set analytics.installerType="zfs-operator" > $DEPLOY_YAML_DIR/../zfs-operator.yaml
helm template "$RELEASE_NAME" "$HELM_CHART_DIR" -n "$RELEASE_NAMESPACE" --set analytics.installerType="zfs-operator" > "$DEPLOY_YAML_DIR"/../zfs-operator.yaml
1 change: 0 additions & 1 deletion buildscripts/push
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,3 @@ then
# Push COMMIT tagged image - :COMMIT
TagAndPushImage "${DIMAGE}" "${COMMIT}"
fi;

0 comments on commit 592d6e5

Please sign in to comment.