-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lint and unit tests in github action
Signed-off-by: chandankumar4 <[email protected]>
- Loading branch information
1 parent
c6f214c
commit c88100c
Showing
3 changed files
with
76 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,101 @@ | ||
|
||
name: test | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
codegen: | ||
name: Codegen | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Restore go build cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/go-build | ||
key: ${{ runner.os }}-go-build-v1-${{ hashFiles('**/go.mod') }} | ||
|
||
- name: Setup Golang | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: Add bins to PATH | ||
run: | | ||
echo /home/runner/go/bin >> $GITHUB_PATH | ||
echo /usr/local/bin >> $GITHUB_PATH | ||
- name: Get dependencies | ||
run: go mod download | ||
|
||
- name: Make codegen | ||
run: | | ||
echo 'GOPATH=/home/runner/go' >> $GITHUB_ENV | ||
make -B codegen | ||
- name: Ensure nothing changed | ||
run: git diff --exit-code | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
env: | ||
GOPATH: /home/runner/go | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Golang | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.58 | ||
args: --timeout=10m | ||
|
||
unit-tests: | ||
name: Unit Tests | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Golang | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.21' | ||
id: go | ||
|
||
- name: Install MockGen | ||
run: go install github.com/golang/mock/[email protected] | ||
|
||
- name: Restore Go build cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/go-build | ||
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }} | ||
|
||
- name: Get dependencies | ||
run: go mod download | ||
|
||
- name: Test | ||
run: make test | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Verify docker image | ||
run: make image |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,9 @@ IMG ?= numaplane-controller | |
VERSION ?= latest | ||
# BASE_VERSION will be used during release process to bump up versions | ||
BASE_VERSION := latest | ||
# Default cluster name where numaplane get deployed, update it as needed. | ||
CLUSTER_NAME ?= staging-usw2-k8s | ||
IMAGE_NAMESPACE ?= quay.io/numaproj | ||
IMAGE_FULL_PATH ?= $(IMAGE_NAMESPACE)/$(IMG):$(VERSION) | ||
|
||
|
||
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
GIT_COMMIT=$(shell git rev-parse HEAD) | ||
GIT_BRANCH=$(shell git rev-parse --symbolic-full-name --verify --quiet --abbrev-ref HEAD) | ||
|
@@ -116,7 +113,7 @@ test: manifests generate fmt vet envtest ## Run tests. | |
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -race -v ./... -coverprofile cover.out | ||
|
||
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint | ||
GOLANGCI_LINT_VERSION ?= v1.54.2 | ||
GOLANGCI_LINT_VERSION ?= v1.58.0 | ||
golangci-lint: | ||
@[ -f $(GOLANGCI_LINT) ] || { \ | ||
set -e ;\ | ||
|
@@ -141,13 +138,8 @@ build: manifests generate fmt vet ## Build manager binary. | |
run: manifests generate fmt vet ## Run a controller from your host. | ||
go run -gcflags=${GCFLAGS} ./cmd/main.go | ||
|
||
.PHONY: run-agent | ||
run-agent: generate fmt vet ## Run agent from your host. | ||
go run -gcflags=${GCFLAGS} cmd/agent/main.go | ||
|
||
|
||
clean: | ||
-rm bin/manager -f | ||
-rm -f bin/manager | ||
|
||
# If you wish to build the manager image targeting other platforms you can use the --platform flag. | ||
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it. | ||
|
@@ -182,14 +174,10 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform | |
|
||
##@ Deployment | ||
|
||
ifndef ignore-not-found | ||
ignore-not-found = false | ||
endif | ||
|
||
.PHONY: start | ||
start: image | ||
$(KUBECTL) apply -f tests/manifests/numaplane-ns.yaml | ||
$(KUBECTL) kustomize tests/manifests | sed 's/CLUSTER_NAME_VALUE/$(CLUSTER_NAME)/g' | sed 's@quay.io/numaproj/@$(IMAGE_NAMESPACE)/@' | sed 's/$(IMG):$(BASE_VERSION)/$(IMG):$(VERSION)/' | $(KUBECTL) apply -f - | ||
$(KUBECTL) kustomize tests/manifests | sed '[email protected]/numaproj/@$(IMAGE_NAMESPACE)/@' | sed 's/$(IMG):$(BASE_VERSION)/$(IMG):$(VERSION)/' | $(KUBECTL) apply -f - | ||
|
||
##@ Build Dependencies | ||
|
||
|