ci: overall enhancements and cosmetics improvements (#134)

* ci: cosmetic renaming CI jobs

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>

* chore: overrall Makefile enhancements

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
This commit is contained in:
Khosrow Moossavi 2021-03-31 12:41:24 -04:00 committed by GitHub
parent b02996e027
commit 8d9e00b699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 122 additions and 56 deletions

View file

@ -1,35 +1,57 @@
name: tests
name: ci
on:
pull_request:
types: ['opened', 'synchronize']
types: ["opened", "synchronize"]
paths-ignore:
- 'README.md'
- "README.md"
push:
branches:
- master
paths-ignore:
- 'README.md'
- "README.md"
env:
GO_VERSION: "1.16"
jobs:
unit:
tests:
runs-on: ubuntu-20.04
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: ${{ env.GO_VERSION }}
- name: Run tests
run: |
make test
run: make test
- name: Install goveralls
run: go get github.com/mattn/goveralls
env:
GO111MODULE: off
run: go get github.com/mattn/goveralls
- name: Send coverage
run: goveralls -coverprofile=cover.out -service=github
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=cover.out -service=github
lint:
runs-on: ubuntu-20.04
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.38

View file

@ -1,18 +0,0 @@
name: lint
on:
pull_request:
types: ['opened', 'synchronize']
push:
branches:
- master
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.38

View file

@ -1,22 +1,28 @@
name: goreleaser
name: release
on:
push:
tags:
- '*'
- "*"
env:
GO_VERSION: "1.16"
jobs:
goreleaser:
runs-on: ubuntu-20.04
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: ${{ env.GO_VERSION }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:

View file

@ -27,13 +27,13 @@ archives:
format: zip
checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"
changelog:
sort: desc
filters:
exclude:
- '^Merge'
- "^Merge"
snapshot:
name_template: "{{ .Tag }}-next"
@ -47,4 +47,4 @@ brews:
test: |
system "#{bin}/git-chglog --help"
install: |
bin.install "git-chglog"
bin.install "git-chglog"

100
Makefile
View file

@ -1,37 +1,93 @@
VERSION?=$$(git describe --tags --always)
# Build variables
VERSION ?= $(shell git describe --tags --always)
LDFLAGS="-X main.version=$(VERSION)"
# Go variables
GO ?= go
GOOS ?= $(shell $(GO) env GOOS)
GOARCH ?= $(shell $(GO) env GOARCH)
GOHOST ?= GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO)
LDFLAGS ?= "-X main.version=$(VERSION)"
.PHONY: all
all: help
###############
##@ Development
.PHONY: clean
clean:
clean: ## Clean workspace
@ $(MAKE) --no-print-directory log-$@
rm -rf ./dist/
rm -rf ./git-chglog
rm -rf $(GOPATH)/bin/git-chglog
rm -rf cover.out
.PHONY: build
build:
go build -ldflags=$(LDFLAGS) -o git-chglog ./cmd/git-chglog
.PHONY: test
test:
go test -covermode atomic -coverprofile cover.out -v ./...
.PHONY: install
install:
go install ./cmd/git-chglog
.PHONY: changelog
changelog: build
./git-chglog --next-tag $(VERSION) -o CHANGELOG.md
test: ## Run tests
@ $(MAKE) --no-print-directory log-$@
$(GOHOST) test -covermode atomic -coverprofile cover.out -v ./...
.PHONY: lint
lint:
@golangci-lint run
lint: ## Run linters
@ $(MAKE) --no-print-directory log-$@
golangci-lint run
#########
##@ Build
.PHONY: build
build: ## Build git-chglog
@ $(MAKE) --no-print-directory log-$@
CGO_ENABLED=0 $(GOHOST) build -ldflags=$(LDFLAGS) -o git-chglog ./cmd/git-chglog
.PHONY: install
install: ## Install git-chglog
@ $(MAKE) --no-print-directory log-$@
$(GOHOST) install ./cmd/git-chglog
###########
##@ Release
.PHONY: changelog
changelog: build ## Generate changelog
@ $(MAKE) --no-print-directory log-$@
./git-chglog --next-tag $(VERSION) -o CHANGELOG.md
.PHONY: release
release: changelog
@git add CHANGELOG.md
@git commit -m "chore: update changelog for $(VERSION)"
release: changelog ## Release a new tag
@ $(MAKE) --no-print-directory log-$@
git add CHANGELOG.md
git commit -m "chore: update changelog for $(VERSION)"
git tag $(VERSION)
git push origin master $(VERSION)
########
##@ Help
.PHONY: help
help: ## Display this help
@awk \
-v "col=\033[36m" -v "nocol=\033[0m" \
' \
BEGIN { \
FS = ":.*##" ; \
printf "Usage:\n make %s<target>%s\n", col, nocol \
} \
/^[a-zA-Z_-]+:.*?##/ { \
printf " %s%-12s%s %s\n", col, $$1, nocol, $$2 \
} \
/^##@/ { \
printf "\n%s%s%s\n", nocol, substr($$0, 5), nocol \
} \
' $(MAKEFILE_LIST)
log-%:
@grep -h -E '^$*:.*?## .*$$' $(MAKEFILE_LIST) | \
awk \
'BEGIN { \
FS = ":.*?## " \
}; \
{ \
printf "\033[36m==> %s\033[0m\n", $$2 \
}'