-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from spotahome/refactor
- Loading branch information
Showing
124 changed files
with
3,102 additions
and
6,125 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
check: | ||
name: Check | ||
runs-on: ubuntu-latest | ||
# Execute the checks inside the container instead the VM. | ||
container: golangci/golangci-lint:v1.24.0-alpine | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- run: ./hack/scripts/check.sh | ||
|
||
unit-test: | ||
name: Unit test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-go@v2-beta | ||
with: | ||
go-version: 1.14 | ||
- run: make ci-unit-test | ||
|
||
integration-test: | ||
name: Integration test | ||
runs-on: ubuntu-latest | ||
needs: [check, unit-test] | ||
strategy: | ||
matrix: | ||
kubernetes: [1.15.7, 1.16.4, 1.17.0, 1.18.0] | ||
env: | ||
KIND_VERSION: v0.7.0 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- run: curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/ | ||
- run: curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v${{ matrix.kubernetes }}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ | ||
- run: KUBERNETES_VERSION=${{ matrix.kubernetes }} make ci-integration-test | ||
|
||
|
||
|
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,20 +1,23 @@ | ||
# Binaries for programs and plugins | ||
# Binaries for programs and plugins. | ||
*.exe | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
# Test binary, build with `go test -c`. | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
# Output of the go coverage tool, specifically when used with LiteIDE. | ||
*.out | ||
|
||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 | ||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736. | ||
.glide/ | ||
|
||
# binary | ||
# Binary. | ||
bin/ | ||
|
||
# vendor | ||
vendor/ | ||
# Vendor. | ||
vendor/ | ||
|
||
# Test coverage. | ||
.test_coverage.txt |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,103 +1,60 @@ | ||
|
||
# Name of this service/application | ||
SERVICE_NAME := kooper | ||
|
||
# Path of the go service inside docker | ||
DOCKER_GO_SERVICE_PATH := /src | ||
|
||
# Shell to use for running scripts | ||
SHELL := $(shell which bash) | ||
|
||
# Get docker path or an empty string | ||
DOCKER := $(shell command -v docker) | ||
|
||
# Get the main unix group for the user running make (to be used by docker-compose later) | ||
OSTYPE := $(shell uname) | ||
GID := $(shell id -g) | ||
|
||
# Get the unix user id for the user running make (to be used by docker-compose later) | ||
UID := $(shell id -u) | ||
|
||
# cmds | ||
UNIT_TEST_CMD := ./hack/scripts/unit-test.sh | ||
INTEGRATION_TEST_CMD := ./hack/scripts/integration-test.sh | ||
CI_INTEGRATION_TEST_CMD := ./hack/scripts/integration-test-kind.sh | ||
MOCKS_CMD := ./hack/scripts/mockgen.sh | ||
DOCKER_RUN_CMD := docker run -v ${PWD}:$(DOCKER_GO_SERVICE_PATH) --rm -it $(SERVICE_NAME) | ||
RUN_EXAMPLE_POD_ECHO := go run ./examples/echo-pod-controller/cmd/* --development | ||
RUN_EXAMPLE_POD_ECHO_ONEFILE := go run ./examples/onefile-echo-pod-controller/main.go --development | ||
RUN_EXAMPLE_POD_TERM := go run ./examples/pod-terminator-operator/cmd/* --development | ||
DEPS_CMD := GO111MODULE=on go mod tidy && GO111MODULE=on go mod vendor | ||
K8S_VERSION := "1.15.6" | ||
SET_K8S_DEPS_CMD := GO111MODULE=on go mod edit \ | ||
-require=k8s.io/apiextensions-apiserver@kubernetes-${K8S_VERSION} \ | ||
-require=k8s.io/client-go@kubernetes-${K8S_VERSION} \ | ||
-require=k8s.io/apimachinery@kubernetes-${K8S_VERSION} \ | ||
-require=k8s.io/api@kubernetes-${K8S_VERSION} \ | ||
-require=k8s.io/kubernetes@v${K8S_VERSION} && \ | ||
$(DEPS_CMD) | ||
DOCKER_RUN_CMD := docker run --env ostype=$(OSTYPE) -v ${PWD}:/src --rm -it ${SERVICE_NAME} | ||
DEPS_CMD := go mod tidy | ||
CHECK_CMD := ./hack/scripts/check.sh | ||
|
||
|
||
# environment dirs | ||
DEV_DIR := docker/dev | ||
help: ## Show this help | ||
@echo "Help" | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[93m %s\n", $$1, $$2}' | ||
|
||
# The default action of this Makefile is to build the development docker image | ||
.PHONY: default | ||
default: build | ||
default: help | ||
|
||
# Test if the dependencies we need to run this Makefile are installed | ||
.PHONY: deps-development | ||
deps-development: | ||
ifndef DOCKER | ||
@echo "Docker is not available. Please install docker" | ||
@exit 1 | ||
endif | ||
|
||
# Build the development docker image | ||
.PHONY: build | ||
build: | ||
build: ## Build the development docker image. | ||
docker build -t $(SERVICE_NAME) --build-arg uid=$(UID) --build-arg gid=$(GID) -f ./docker/dev/Dockerfile . | ||
|
||
# Dependency stuff. | ||
.PHONY: set-k8s-deps | ||
set-k8s-deps: | ||
$(SET_K8S_DEPS_CMD) | ||
|
||
.PHONY: deps | ||
deps: | ||
deps: ## Updates the required dependencies. | ||
$(DEPS_CMD) | ||
|
||
# Test stuff in dev | ||
.PHONY: unit-test | ||
unit-test: build | ||
$(DOCKER_RUN_CMD) /bin/sh -c '$(UNIT_TEST_CMD)' | ||
.PHONY: integration-test | ||
integration-test: build | ||
integration-test: build ## Runs integration tests out of CI. | ||
echo "[WARNING] Requires a kubernetes cluster configured (and running) on your kubeconfig!!" | ||
$(INTEGRATION_TEST_CMD) | ||
|
||
.PHONY: test | ||
test: unit-test | ||
test: build ## Runs unit tests out of CI. | ||
$(DOCKER_RUN_CMD) /bin/sh -c '$(UNIT_TEST_CMD)' | ||
|
||
.PHONY: check | ||
check: build ## Runs checks. | ||
@$(DOCKER_RUN_CMD) /bin/sh -c '$(CHECK_CMD)' | ||
|
||
# Test stuff in ci | ||
.PHONY: ci-unit-test | ||
ci-unit-test: | ||
ci-unit-test: ## Runs unit tests in CI. | ||
$(UNIT_TEST_CMD) | ||
|
||
.PHONY: ci-integration-test | ||
ci-integration-test: | ||
ci-integration-test: ## Runs integration tests in CI. | ||
$(CI_INTEGRATION_TEST_CMD) | ||
.PHONY: ci | ||
|
||
.PHONY: ci ## Runs all tests in CI. | ||
ci: ci-unit-test ci-integration-test | ||
|
||
# Mocks stuff in dev | ||
.PHONY: mocks | ||
mocks: build | ||
mocks: build ## Generates mocks. | ||
$(DOCKER_RUN_CMD) /bin/sh -c '$(MOCKS_CMD)' | ||
|
||
# Run examples. | ||
.PHONY: controller-example | ||
controller-example: | ||
$(RUN_EXAMPLE_POD_ECHO) | ||
.PHONY: controller-example-onefile | ||
controller-example-onefile: | ||
$(RUN_EXAMPLE_POD_ECHO_ONEFILE) | ||
.PHONY: operator-example | ||
operator-example: | ||
$(RUN_EXAMPLE_POD_TERM) |
Oops, something went wrong.