diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml new file mode 100644 index 0000000..6b9dd60 --- /dev/null +++ b/.github/workflows/workflow.yaml @@ -0,0 +1,61 @@ +name: test +on: + push: + paths-ignore: + - "**.md" + pull_request: + paths-ignore: + - "**.md" + +jobs: + lint: + name: "Lint" + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Install golangci-lint + run: | + mkdir -p $GITHUB_WORKSPACE/bin + echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GITHUB_WORKSPACE/bin v${GOLANGCILINT_VERSION} + env: + GOLANGCILINT_VERSION: 1.35.2 + + - name: Make lint + run: | + make lint + + test: + name: "Unit test" + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Set up Go 1.15 + uses: actions/setup-go@v2 + with: + go-version: 1.15 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Install kubebuilder + run: | + curl -L -O "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${KUBEBUILDER_VERSION}/kubebuilder_${KUBEBUILDER_VERSION}_linux_amd64.tar.gz" &&\ + tar -zxvf kubebuilder_${KUBEBUILDER_VERSION}_linux_amd64.tar.gz &&\ + sudo mv kubebuilder_${KUBEBUILDER_VERSION}_linux_amd64 /usr/local/kubebuilder + env: + KUBEBUILDER_VERSION: 2.3.1 + + - name: Unit test + run: make test + + - name: Codecov Upload + uses: codecov/codecov-action@v1 + with: + flags: unittests + file: ./cover.out + fail_ci_if_error: false diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6029665 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +all: lint test + +lint: + golangci-lint -v run ./... --timeout 5m + +test: + go test ./... -coverprofile cover.out