diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index d52e3131..6d8280a8 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -22,13 +22,9 @@ jobs: version: v0.8.1 - name: Docker build run: | - docker build -t gcr.io/linkerd-io/proxy-init:latest . - docker build -t buoyantio/iptables-tester:v1 -f integration_test/iptables/Dockerfile-tester ./integration_test + make image + make tester-image - name: Load image into the local KinD cluster - run: | - kind load docker-image gcr.io/linkerd-io/proxy-init:latest - kind load docker-image buoyantio/iptables-tester:v1 + run: make kind-load - name: Run integration tests - run: | - cd integration_test - SKIP_BUILD_TESTER_IMAGE=1 ./run_tests.sh + run: SKIP_BUILD_TESTER_IMAGE=1 make integration-test diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index d3966c01..327b4ec1 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -32,6 +32,4 @@ jobs: # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Format - run: | - gofmt -d . - test -z "$(gofmt -d .)" + run: make fmt diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index f39928fd..9c399bcc 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -18,4 +18,4 @@ jobs: # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Run unit tests - run: go test -v ./... + run: make test diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..e662b75e --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +DOCKER_REGISTRY ?= gcr.io/linkerd-io +REPO = $(DOCKER_REGISTRY)/proxy-init +TESTER_REPO = buoyantio/iptables-tester + +.DEFAULT_GOAL := help + +.PHONY: help +help: ## Show this help + @echo 'Info: For integration test using KinD, run make kind-load integration-test' + @echo 'Info: For other environments, run make integration-test after having uploaded the images' + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +############### +# Go +############### +.PHONY: build +build: ## Build the project + go build -o out/linkerd2-proxy-init main.go + +.PHONY: run +run: ## Run the project + go run main.go + +.PHONY: test +test: ## Perform unit test + go test -v ./... + +.PHONY: fmt +fmt: ## Check the code formatting + gofmt -d . + test -z "$(shell gofmt -d .)" + +.PHONY: integration-test +integration-test: image ## Perform integration test + cd integration_test && ./run_tests.sh + +############### +# Docker +############### +.PHONY: image +image: ## Build docker image for the project + docker build -t $(REPO):latest . + +.PHONY: tester-image +tester-image: ## Build docker image for the tester component + docker build -t $(TESTER_REPO):v1 -f ./integration_test/iptables/Dockerfile-tester ./integration_test + +.PHONY: kind-load +kind-load: image tester-image ## Load the required image to KinD cluster + kind load docker-image $(REPO):latest + kind load docker-image $(TESTER_REPO):v1 diff --git a/README.md b/README.md index 44a20fa6..f2ad46ed 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,11 @@ Start by building and tagging the `proxy-init` image required for the test: ```bash eval $(minikube docker-env) -docker build -t gcr.io/linkerd-io/proxy-init:latest . +make image ``` Then run the tests with: ```bash -cd integration_test -./run_tests.sh +make integration-test ```