Skip to content

Commit

Permalink
test: remove v1 binary commands from GitHub actions and Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-ding committed Oct 14, 2022
1 parent 2810c45 commit dcbbf77
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 150 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,8 @@ jobs:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Build
run: |
go build -v -a -o ./bin/csi-proxy.exe ./cmd/csi-proxy
- name: Run Windows Integration Tests
run: |
# start the CSI Proxy before running tests on windows
Start-Job -Name CSIProxy -ScriptBlock {
.\bin\csi-proxy.exe
};
Start-Sleep -Seconds 30;
Write-Output "getting named pipes"
[System.IO.Directory]::GetFiles("\\.\\pipe\\")
$env:CSI_PROXY_GH_ACTIONS="TRUE"
go test -v -race ./integrationtests/...
unit_tests:
Expand Down
48 changes: 4 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CMDS=csi-proxy
all: build test
all: test

# include release tools for building binary and testing targets
include release-tools/build.make
Expand All @@ -10,42 +9,6 @@ REPO_ROOT = $(CURDIR)
BUILD_DIR = bin
BUILD_TOOLS_DIR = $(BUILD_DIR)/tools
GO_ENV_VARS = GO111MODULE=on GOOS=windows
CSI_PROXY_API_GEN = $(BUILD_DIR)/csi-proxy-api-gen

.PHONY: compile-csi-proxy-api-gen
compile-csi-proxy-api-gen:
GO111MODULE=on go build -o $(CSI_PROXY_API_GEN) ./cmd/csi-proxy-api-gen

.PHONY: generate
generate: generate-protobuf generate-csi-proxy-api-gen

# using xargs instead of -exec since the latter doesn't propagate exit statuses
.PHONY: generate-protobuf
generate-protobuf:
@ if ! which protoc > /dev/null 2>&1; then echo 'Unable to find protoc binary' ; exit 1; fi
@ generate_protobuf_for() { \
local FILE="$$1"; \
local FILE_DIR="$$(dirname "$(GOPATH)/$$FILE")"; \
echo "Generating protobuf file from $$FILE in $$FILE_DIR"; \
protoc -I "$(GOPATH)/src/" -I '$(REPO_ROOT)/client/api' "$$FILE" --go_out=plugins="grpc:$(GOPATH)/src"; \
} ; \
export -f generate_protobuf_for; \
find '$(REPO_ROOT)' -not -path './vendor/*' -name '*.proto' | sed -e "s|$(GOPATH)/src/||g" | xargs -n1 '$(SHELL)' -c 'generate_protobuf_for "$$0"'

.PHONY: generate-csi-proxy-api-gen
generate-csi-proxy-api-gen: compile-csi-proxy-api-gen
$(CSI_PROXY_API_GEN) -i github.com/kubernetes-csi/csi-proxy/client/api,github.com/kubernetes-csi/csi-proxy/integrationtests/apigroups/api/dummy --v=8

.PHONY: clean
clean: clean-protobuf clean-generated

.PHONY: clean-protobuf
clean-protobuf:
find '$(REPO_ROOT)' -name '*.proto' -exec '$(SHELL)' -c 'rm -vf "$$(dirname {})/$$(basename {} .proto).pb.go"' \;

.PHONY: clean-generated
clean-generated:
find '$(REPO_ROOT)' -name '*_generated.go' -exec '$(SHELL)' -c '[[ "$$(head -n 1 "{}")" == "// Code generated by csi-proxy-api-gen"* ]] && rm -v {}' \;

# see https://github.com/golangci/golangci-lint/releases
GOLANGCI_LINT_VERSION = v1.21.0
Expand All @@ -60,17 +23,14 @@ lint: $(GOLANGCI_LINT)
test: test-go
test-go:
@ echo; echo "### $@:"
# TODO: After issue https://github.com/microsoft/go-winio/pull/169 is resolved, remove the filter on the test path.
GO111MODULE=on go test `find ./internal/server/ -type d -not -name server`;\
cd client && GO111MODULE=on go test `go list ./... | grep -v group` && cd ../
GO111MODULE=on go test ./pkg/...

.PHONY: test-vet
test: test-vet
test-vet:
@ echo; echo "### $@:"
# TODO: After issue https://github.com/microsoft/go-winio/pull/169 is resolved, remove the filter on the test path.
# GO111MODULE=on go vet `find ./internal/server/ -type d -not -name server`;\
cd client && GO111MODULE=on go vet `go list ./... | grep -v group` && cd ../
GO111MODULE=on go vet ./pkg/...

# see https://github.com/golangci/golangci-lint#binary-release
$(GOLANGCI_LINT):
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$$(dirname '$(GOLANGCI_LINT)')" '$(GOLANGCI_LINT_VERSION)'
7 changes: 1 addition & 6 deletions scripts/run-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
# - a kubernetes cluster with a Windows nodepool
#
# Steps:
# - cross compile the csi-proxy binary and the integration tests
# - cross compile the csi-proxy integration tests
# - copy to the VM using scp
# - restart the CSI Proxy binary process with a helper powershell script
# - run the integration tests

set -euxo pipefail
Expand All @@ -18,12 +17,8 @@ pkgdir=${GOPATH}/src/github.com/kubernetes-csi/csi-proxy
source $pkgdir/scripts/utils.sh

main() {
compile_csi_proxy
compile_csi_proxy_integration_tests
sync_csi_proxy
sync_csi_proxy_integration_tests
sync_powershell_utils
restart_csi_proxy
run_csi_proxy_integration_tests
}

Expand Down
26 changes: 0 additions & 26 deletions scripts/sync-csi-proxy.sh

This file was deleted.

41 changes: 0 additions & 41 deletions scripts/utils.psm1

This file was deleted.

24 changes: 1 addition & 23 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,23 @@ sync_file_to_vm() {
gcloud compute scp $@ $windows_node:"C:\\Users\\${current_account}"
}

compile_csi_proxy() {
echo "Compiling CSI Proxy"
make -C $pkgdir build
}

compile_csi_proxy_integration_tests() {
echo "Compiling CSI Proxy integration tests"
GOOS=windows GOARCH=amd64 go test -c $pkgdir/integrationtests -o $pkgdir/bin/integrationtests.test.exe
}

sync_csi_proxy() {
echo "Sync the csi-proxy.exe binary"
local csi_proxy_bin_path="$pkgdir/bin/csi-proxy.exe"
sync_file_to_vm $csi_proxy_bin_path
}

sync_csi_proxy_integration_tests() {
echo "Sync the integrationtests.exe binary"
local integration_bin_path="$pkgdir/bin/integrationtests.test.exe"
sync_file_to_vm $integration_bin_path
}

sync_powershell_utils() {
local utils_psm1="$pkgdir/scripts/utils.psm1"
sync_file_to_vm $utils_psm1
}

restart_csi_proxy() {
echo "Restart csi-proxy service"
gcloud compute ssh $windows_node --command='powershell -c "& { $ErrorActionPreference = \"Stop\"; Import-Module (Resolve-Path(\"utils.psm1\")); Restart-CSIProxy; }"'
}

run_csi_proxy_integration_tests() {
echo "Run integration tests"
local ps1=$(cat << 'EOF'
"& {
$ErrorActionPreference = \"Stop\";
Import-Module (Resolve-Path(\"utils.psm1\"));
Run-CSIProxyIntegrationTests -test_args \"--test.v\";
.\integrationtests.test.exe --test.v
}"
EOF
);
Expand Down

0 comments on commit dcbbf77

Please sign in to comment.