From 588ba31254d83e758278c34c9078724522cdaa40 Mon Sep 17 00:00:00 2001 From: Mihai Bojin Date: Wed, 22 Jul 2020 11:05:50 +0100 Subject: [PATCH] Refactor; auto-check a tag after it was pushed --- .github/workflows/release-check.yml | 18 ++++++++++++++++++ GNUmakefile | 12 +++++++++++- githooks/pre-push | 17 ++--------------- scripts/check-version.sh | 29 +++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/release-check.yml create mode 100755 scripts/check-version.sh diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml new file mode 100644 index 000000000..be721b5d7 --- /dev/null +++ b/.github/workflows/release-check.yml @@ -0,0 +1,18 @@ +on: + push: + tags: + - v0.*.* + - v1.*.* + +jobs: + tests: + name: Continuous Integration Tests + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + + - name: Checking the code + run: make tools lint test + + - name: Checking the version + run: make check-version diff --git a/GNUmakefile b/GNUmakefile index 627458abc..dc383cc35 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -13,26 +13,36 @@ link-git-hooks: find .git/hooks -type l -exec rm {} \; find githooks -type f -exec ln -sf ../../{} .git/hooks/ \; +.PHONY: build build: go install ./$(PKG_NAME) +.PHONY: test test: go test $(SOURCE_FILES) -coverprofile $(COVERAGE) -timeout=30s -parallel=4 -cover -race +.PHONY: fmt fmt: @echo "==> Fixing source code with gofmt..." gofmt -s -w ./$(PKG_NAME) goimports -w ./$(PKG_NAME) +.PHONY: lint-fix lint-fix: golangci-lint run --fix +.PHONY: lint lint: golangci-lint run $(SOURCE_FILES) +.PHONY: check check: test lint-fix +.PHONY: tools tools: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_VERSION) -.PHONY: build test fmt lint lint-fix check tools +TAG=$(shell git describe --tags --dirty --always) +.PHONY: check-version +check-version: + scripts/check-version.sh "$(TAG)" diff --git a/githooks/pre-push b/githooks/pre-push index 90281de0f..65d839d6c 100755 --- a/githooks/pre-push +++ b/githooks/pre-push @@ -1,10 +1,8 @@ #!/usr/bin/env bash # # A simple pre-push hook which ensures that the tag being pushed to GitHub -# matches the version defined in the VERSION_FILE. +# matches the version defined in code. # -declare -r VERSION_FILE="mongodbatlas/mongodbatlas.go" - # Determine if a tag is being pushed tag= input=$(