From f629a81148d0d94dcc75481d91e4d1d7af24eda1 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Mon, 23 Dec 2019 14:57:33 -0600 Subject: [PATCH 1/8] ci: add config for git-chglog --- .chglog/CHANGELOG.tpl.md | 30 ++++++++++++++++++++++++++++++ .chglog/config.yml | 28 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 .chglog/CHANGELOG.tpl.md create mode 100755 .chglog/config.yml diff --git a/.chglog/CHANGELOG.tpl.md b/.chglog/CHANGELOG.tpl.md new file mode 100755 index 0000000..60a67d5 --- /dev/null +++ b/.chglog/CHANGELOG.tpl.md @@ -0,0 +1,30 @@ +{{ range .Versions }} + +## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }}) + +{{ range .CommitGroups -}} +### {{ .Title }} + +{{ range .Commits -}} +* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} +{{ end }} +{{ end -}} + +{{- if .RevertCommits -}} +### Reverts + +{{ range .RevertCommits -}} +* {{ .Revert.Header }} +{{ end }} +{{ end -}} + +{{- if .NoteGroups -}} +{{ range .NoteGroups -}} +### {{ .Title }} + +{{ range .Notes }} +{{ .Body }} +{{ end }} +{{ end -}} +{{ end -}} +{{ end -}} \ No newline at end of file diff --git a/.chglog/config.yml b/.chglog/config.yml new file mode 100755 index 0000000..a8da6af --- /dev/null +++ b/.chglog/config.yml @@ -0,0 +1,28 @@ +style: github +template: CHANGELOG.tpl.md +info: + title: CHANGELOG + repository_url: https://github.com/go-vela/vela-git +options: + commits: + # filters: + # Type: + # - feat + # - fix + # - perf + # - refactor + commit_groups: + # title_maps: + # feat: Features + # fix: Bug Fixes + # perf: Performance Improvements + # refactor: Code Refactoring + header: + pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" + pattern_maps: + - Type + - Scope + - Subject + notes: + keywords: + - BREAKING CHANGE \ No newline at end of file From dcce853d9bd1543ba90c7fb91c6132d74b08db07 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Mon, 23 Dec 2019 14:58:07 -0600 Subject: [PATCH 2/8] ci: move release action to prerelease --- .github/workflows/prerelease.yml | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/prerelease.yml diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml new file mode 100644 index 0000000..4fc0947 --- /dev/null +++ b/.github/workflows/prerelease.yml @@ -0,0 +1,37 @@ +# name of the action +name: prerelease + +# trigger on push events with `v*` in tag +on: + push: + tags: + - 'v*' + +# pipeline to execute +jobs: + prerelease: + runs-on: ubuntu-latest + container: + image: golang:latest + steps: + - name: clone + uses: actions/checkout@v1 + + - name: build + env: + GOOS: linux + CGO_ENABLED: '0' + run: | + go build -a \ + -ldflags '-s -w -extldflags "-static"' \ + -o release/vela-git \ + github.com/go-vela/vela-git + + - name: publish + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: target/vela-git + cache: true + tag_names: true + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} From 73da2f5956c78caf1ca2eed2fb16d49d38a78f34 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Mon, 23 Dec 2019 14:58:28 -0600 Subject: [PATCH 3/8] ci: add release action for changelog --- .github/workflows/release.yml | 57 ++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e39d599..eded7f8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,30 +1,53 @@ -name: Release Action +# name of the action +name: release + +# trigger on push events with `v*` in tag +# ignore push events with `v*-rc*` in tag on: push: tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + - 'v*' + - '!v*-rc*' +# pipeline to execute jobs: release: runs-on: ubuntu-latest container: image: golang:latest steps: - - name: clone - uses: actions/checkout@master + uses: actions/checkout@v1 - - name: build - env: - GOOS: linux - CGO_ENABLED: '0' - run: go build -a -ldflags '-s -w -extldflags "-static"' -o release/vela-git github.com/go-vela/vela-git + - name: tags + run: | + git fetch --tags + + - name: version + id: version + run: | + echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} - - name: publish - uses: elgohr/Publish-Docker-Github-Action@master - with: - name: target/vela-git - cache: true - tag_names: true - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + - name: install + run: | + go get github.com/git-chglog/git-chglog/cmd/git-chglog + go get github.com/itchio/gothub + + - name: changelog + run: | + # https://github.com/git-chglog/git-chglog#git-chglog + $(go env GOPATH)/bin/git-chglog \ + -o $GITHUB_WORKSPACE/CHANGELOG.md \ + ${{ steps.version.outputs.VERSION }} + + - name: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # https://github.com/itchio/gothub#gothub + $(go env GOPATH)/bin/gothub edit \ + --user go-vela \ + --repo vela-git \ + --tag ${{ steps.version.outputs.VERSION }} \ + --name ${{ steps.version.outputs.VERSION }} \ + --description "$(cat $GITHUB_WORKSPACE/CHANGELOG.md)" From 039c3df2ac7cd8399295c7c677dc81df0de384e7 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Mon, 23 Dec 2019 14:58:48 -0600 Subject: [PATCH 4/8] ci: add pipeline annotations --- .github/workflows/build.yml | 10 +++++++--- .github/workflows/publish.yml | 15 +++++++++++---- .github/workflows/test.yml | 16 +++++++++++++--- .github/workflows/validate.yml | 7 +++++-- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7325220..e262df0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,17 +1,21 @@ -name: Build Action +# name of the action +name: build + +# trigger on pull_request or push events on: pull_request: push: +# pipeline to execute jobs: build: runs-on: ubuntu-latest container: image: golang:latest steps: - - name: clone uses: actions/checkout@v1 - name: build - run: make build + run: | + make build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9845990..eac0545 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,23 +1,30 @@ -name: Publish Action +# name of the action +name: publish + +# trigger on push events with branch master on: push: branches: [ master ] +# pipeline to execute jobs: publish: runs-on: ubuntu-latest container: image: golang:latest steps: - - name: clone - uses: actions/checkout@master + uses: actions/checkout@v1 - name: build env: GOOS: linux CGO_ENABLED: '0' - run: go build -a -ldflags '-s -w -extldflags "-static"' -o release/vela-git github.com/go-vela/vela-git + run: | + go build -a \ + -ldflags '-s -w -extldflags "-static"' \ + -o release/vela-git \ + github.com/go-vela/vela-git - name: publish uses: elgohr/Publish-Docker-Github-Action@master diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83a0acf..fa1c476 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,17 +1,27 @@ -name: Test Action +# name of the action +name: test + +# trigger on pull_request or push events on: pull_request: push: +# pipeline to execute jobs: test: runs-on: ubuntu-latest container: image: golang:latest steps: - - name: clone uses: actions/checkout@v1 - name: test - run: go test -cover -coverprofile coverage.out ./... + run: | + go test -race -covermode=atomic -coverprofile=coverage.out ./... + + - name: coverage + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: coverage.out diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index f3a2c66..867909f 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -1,15 +1,18 @@ -name: Validate Action +# name of the action +name: validate + +# trigger on pull_request or push events on: pull_request: push: +# pipeline to execute jobs: validate: runs-on: ubuntu-latest container: image: golang:latest steps: - - name: clone uses: actions/checkout@v1 From be7b31f9613c30d34de5d73bd08cd06b6fbad137 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Mon, 23 Dec 2019 14:59:06 -0600 Subject: [PATCH 5/8] ci: update makefile for binary name --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 9be2933..260c6bf 100644 --- a/Makefile +++ b/Makefile @@ -23,14 +23,14 @@ clean: ################################# binary-build: - GOOS=linux CGO_ENABLED=0 go build -o release/git-plugin github.com/go-vela/vela-git + GOOS=linux CGO_ENABLED=0 go build -o release/vela-git github.com/go-vela/vela-git ################################# ###### Docker Build ###### ################################# docker-build: - docker build --no-cache -t git-plugin:local . + docker build --no-cache -t vela-git:local . ################################# ###### Docker Run ###### @@ -48,7 +48,7 @@ docker-run: -e VELA_NETRC_MACHINE \ -e VELA_NETRC_USERNAME \ -e VELA_NETRC_PASSWORD \ - git-plugin:local + vela-git:local docker-example: @@ -62,4 +62,4 @@ docker-example: -e VELA_NETRC_MACHINE \ -e VELA_NETRC_USERNAME \ -e VELA_NETRC_PASSWORD \ - git-plugin:local + vela-git:local From b94eb6bdec92e269e1a3ccf6320b0a6fec0e2b2b Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Mon, 23 Dec 2019 14:59:34 -0600 Subject: [PATCH 6/8] chore: add badges to readme --- .github/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/README.md b/.github/README.md index 4864311..1a32d0c 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,4 +1,8 @@ -# Git +# vela-git + +[![GoDoc](https://godoc.org/github.com/go-vela/vela-git?status.svg)](https://godoc.org/github.com/go-vela/vela-git) +[![Go Report Card](https://goreportcard.com/badge/go-vela/vela-git)](https://goreportcard.com/report/go-vela/vela-git) +[![codecov](https://codecov.io/gh/go-vela/vela-git/branch/master/graph/badge.svg)](https://codecov.io/gh/go-vela/vela-git) Git plugin built around the [git](https://git-scm.com/) CLI to clone repositories for Vela. From cf594b0af792cda5feb0838fbb44a0b99f12fe6b Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Mon, 23 Dec 2019 15:02:12 -0600 Subject: [PATCH 7/8] ci: add default codecov configuration --- codecov.yml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..f23cd41 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,50 @@ +# The is the default codecov.io yaml configuration all projects use +# that do not have their own codecov.yml already in the project. +# +# https://docs.codecov.io/docs/codecov-yaml#section-default-yaml + +# This section provides the generic configuration for codecov. +# +# https://docs.codecov.io/docs/codecovyml-reference#section-codecov +codecov: + + require_ci_to_pass: yes + +# This section provides the configuration for the +# coverage report codecov analyzes for results. +# +# https://docs.codecov.io/docs/codecovyml-reference#section-coverage +coverage: + + precision: 2 + round: down + range: "70...100" + + status: + project: yes + patch: yes + changes: no + +# This section provides the configuration for the +# parsers codecov uses for the coverage report. +# +# https://docs.codecov.io/docs/codecovyml-reference#section-parsers +parsers: + + gcov: + + branch_detection: + conditional: yes + loop: yes + method: no + macro: no + +# This section provides the configuration for the +# comments codecov makes to open pull requests. +# +# https://docs.codecov.io/docs/codecovyml-reference#section-comment +comment: + + layout: "reach, diff, flags, files" + behavior: default + require_changes: no From db17fd2e2a6abf0120b43508b0ffefe1587c750c Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Mon, 23 Dec 2019 15:02:36 -0600 Subject: [PATCH 8/8] ci: add golangci configuration --- .golangci.yml | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..60daee7 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,73 @@ +# This is a manually created golangci.com yaml configuration with +# some defaults explicitly provided. There is a large number of +# linters we've enabled that are usually disabled by default. +# +# https://github.com/golangci/golangci-lint#config-file + +# This section provides the configuration for how golangci +# outputs it results from the linters it executes. +output: + format: colored-line-number + print-issued-lines: true + print-linter-name: true + +# This section provides the configuration for which linters +# golangci will execute. Several of them were disabled by +# default but we've opted to enable them. +linters: + # disable all linters as new linters might be added to golangci + disable-all: true + enable: + # linters enabled by default + - deadcode + - errcheck + - govet + - gosimple # a.k.a. megacheck + - ineffassign + - staticcheck + - structcheck + - typecheck + - unused + - varcheck + + # linters disabled by default + - bodyclose + - gocognit + - goconst + - gocyclo + - goimports + - gosec + - funlen + - maligned + - misspell + - stylecheck + - unparam + - whitespace + - wsl + + # static list of linters we know golangci can run but we've + # chosen to leave disabled for now + # + # disable: + # - depguard + # - dogsled + # - dupl + # - gocritic + # - gochecknoinits + # - gochecknoglobals + # - godox + # - gofmt + # - golint + # - gomnd + # - interfacer + # - lll + # - nakedret + # - scopelint + # - unconvert + +# This section provides the configuration for each linter +# we've instructed golangci to execute. +linters-settings: + funlen: + lines: 100 + statements: 60