Skip to content

Commit

Permalink
build: a number of fixes on Makefile and nix-shell
Browse files Browse the repository at this point in the history
Pin a few packages version which are not compatible on latest.
Perhaps all of them should be pinned!
Remove a few uses of sudo which should not be required?
Add a few packages missing from nix-shell
Allow make clean to work properly
Don't bootstrap by default, though this may be discussed further.
Setup goenv env variables on github actions workflows

Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed Jan 6, 2025
1 parent 5c68557 commit 5a38965
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 13 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ jobs:
go-version: 1.19.9
cache: false

- name: Set go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
- name: Unit test
run: make test

Expand Down Expand Up @@ -77,6 +82,11 @@ jobs:
go-version: 1.19.9
cache: false

- name: Set go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
- name: Setup Minikube-Kubernetes
uses: medyagh/setup-minikube@latest
with:
Expand All @@ -99,7 +109,7 @@ jobs:
run: ./ci/ci-test.sh

- name: Upload Coverage Report
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./tests/bdd_coverage.txt
Expand Down
23 changes: 20 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
go-version: 1.19.9
cache: false

- name: Set go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
- name: Lint Check
uses: golangci/golangci-lint-action@v4
with:
Expand Down Expand Up @@ -71,6 +76,11 @@ jobs:
go-version: 1.19.9
cache: false

- name: Set go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
- name: Unit test
run: make test

Expand Down Expand Up @@ -99,8 +109,13 @@ jobs:
go-version: 1.19.9
cache: false

- name: Set go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
- name: Build images locally
run: make lvm-driver-image || exit 1;
run: make lvm-driver-image

- name: Setup Minikube-Kubernetes
uses: medyagh/setup-minikube@latest
Expand All @@ -122,10 +137,12 @@ jobs:
- name: Running tests
env:
OPENEBS_NAMESPACE: "openebs"
run: ./ci/ci-test.sh
run: |
./ci/ci-test.sh
journalctl -u kubelet
- name: Upload Coverage Report
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./tests/bdd_coverage.txt
Expand Down
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods \
EXTERNAL_TOOLS=\
golang.org/x/tools/cmd/cover \
golang.org/x/lint/golint \
github.com/axw/gocov/gocov \
github.com/axw/gocov/gocov@v1.1 \
github.com/matm/gocov-html/cmd/gocov-html \
github.com/onsi/ginkgo/ginkgo \
github.com/onsi/gomega/...
github.com/onsi/gomega/...@v1.35

# The images can be pushed to any docker/image registeries
# like docker hub, quay. The registries are specified in
Expand Down Expand Up @@ -86,6 +86,7 @@ clean:
@echo "--> Cleaning Directory" ;
go clean -testcache
rm -rf bin
chmod -R u+w ${GOPATH}
rm -rf ${GOPATH}/bin/${CSI_DRIVER}
rm -rf ${GOPATH}/pkg/*

Expand Down Expand Up @@ -119,7 +120,10 @@ verify-deps: deps
bootstrap: controller-gen install-golangci-lint
@for tool in $(EXTERNAL_TOOLS) ; do \
echo "+ Installing $$tool" ; \
cd && GO111MODULE=on go install $$tool@latest; \
if ! echo $$tool | grep "@"; then \
tool=$$tool@latest ; \
fi ; \
GO111MODULE=on go install $$tool; \
done

## golangci-lint tool used to check linting tools in codebase
Expand All @@ -130,7 +134,7 @@ bootstrap: controller-gen install-golangci-lint
## Install golangci-lint only if tool doesn't exist in system
.PHONY: install-golangci-lint
install-golangci-lint:
$(if $(shell which golangci-lint), echo "golangci-lint already exist in system", (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b "${GOPATH}/bin" v1.56.2))
$(if $(shell which golangci-lint), echo "golangci-lint already exist in system", (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GOPATH}/bin" v1.56.2))

.PHONY: controller-gen
controller-gen:
Expand Down Expand Up @@ -222,15 +226,15 @@ lvm-driver-image: lvm-driver
@echo "+ Generating ${CSI_DRIVER} image"
@echo "--------------------------------"
@cp bin/${CSI_DRIVER}/${CSI_DRIVER} buildscripts/${CSI_DRIVER}/
cd buildscripts/${CSI_DRIVER} && sudo docker build -t ${IMAGE_ORG}/${CSI_DRIVER}:${IMAGE_TAG} ${DBUILD_ARGS} . && sudo docker tag ${IMAGE_ORG}/${CSI_DRIVER}:${IMAGE_TAG} quay.io/${IMAGE_ORG}/${CSI_DRIVER}:${IMAGE_TAG}
cd buildscripts/${CSI_DRIVER} && docker build -t ${IMAGE_ORG}/${CSI_DRIVER}:${IMAGE_TAG} ${DBUILD_ARGS} . && docker tag ${IMAGE_ORG}/${CSI_DRIVER}:${IMAGE_TAG} quay.io/${IMAGE_ORG}/${CSI_DRIVER}:${IMAGE_TAG}
@rm buildscripts/${CSI_DRIVER}/${CSI_DRIVER}

.PHONY: ansible-runner-image
ansible-runner-image:
@echo "------------------"
@echo "--> Build ansible-runner image for lvm-localpv e2e-tests"
@echo "------------------"
sudo docker build . -f e2e-tests/Dockerfile -t ${IMAGE_ORG}/lvm-localpv-e2e:ci
docker build . -f e2e-tests/Dockerfile -t ${IMAGE_ORG}/lvm-localpv-e2e:ci

.PHONY: ci
ci:
Expand Down
8 changes: 5 additions & 3 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ pkgs.mkShell {
minikube
semver-tool
yq-go
];
which
curl
cacert
util-linux
] ++ pkgs.lib.optional (builtins.getEnv "IN_NIX_SHELL" == "pure") docker;
shellHook = ''
export HOME=${builtins.getEnv "HOME"}
export GOPATH=$(pwd)/nix/.go
export GOCACHE=$(pwd)/nix/.go/cache
export TMPDIR=$(pwd)/nix/.tmp
export PATH=$GOPATH/bin:$PATH
mkdir -p "$TMPDIR"
make bootstrap
'';
}
2 changes: 2 additions & 0 deletions tests/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ func leakProtectionTest() {
By("Creating default storage class", createStorageClass)
ds := deleteNodeDaemonSet() // ensure that provisioning remains in pending state.

time.Sleep(30 * time.Second)

By("Creating PVC", createPVC)
time.Sleep(30 * time.Second) // wait for external provisioner to pick up new pvc
By("Verify pending lvm volume resource")
Expand Down

0 comments on commit 5a38965

Please sign in to comment.