Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add github actions workflows #3

Merged
merged 7 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ 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 -}}
28 changes: 28 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/go-vela/secret-vault
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
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
37 changes: 37 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -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/secret-vault \
github.com/go-vela/secret-vault/cmd/secret-vault

- name: publish
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: target/secret-vault
cache: true
tag_names: true
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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@v1

- name: build
env:
GOOS: linux
CGO_ENABLED: '0'
run: |
go build -a \
-ldflags '-s -w -extldflags "-static"' \
-o release/secret-vault \
github.com/go-vela/secret-vault/cmd/secret-vault

- name: publish
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: target/secret-vault
cache: true
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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*'
- '!v*-rc*'

# pipeline to execute
jobs:
release:
runs-on: ubuntu-latest
container:
image: golang:latest
steps:
- name: clone
uses: actions/checkout@v1

- name: tags
run: |
git fetch --tags

- name: version
id: version
run: |
echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}

- name: install
run: |
go get github.com/git-chglog/git-chglog/cmd/git-chglog
go get github.com/github-release/github-release

- 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/github-release/github-release#how-to-use
$(go env GOPATH)/bin/github-release edit \
--user go-vela \
--repo secret-vault \
--tag ${{ steps.version.outputs.VERSION }} \
--name ${{ steps.version.outputs.VERSION }} \
--description "$(cat $GITHUB_WORKSPACE/CHANGELOG.md)"
41 changes: 41 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# name of the action
name: reviewdog

# trigger on pull_request events
on:
pull_request:

# pipeline to execute
jobs:
diff-review:
runs-on: ubuntu-latest
container:
image: golang:latest
steps:
- name: clone
uses: actions/checkout@v1

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--config=.golangci.yml"
fail_on_error: true
filter_mode: diff_context
reporter: github-pr-review

full-review:
runs-on: ubuntu-latest
container:
image: golang:latest
steps:
- name: clone
uses: actions/checkout@v1

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--config=.golangci.yml"
fail_on_error: false
filter_mode: nofilter
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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 -race -covermode=atomic -coverprofile=coverage.out ./...

- name: coverage
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.out
26 changes: 26 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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

- name: validate
run: |
# Check that go mod tidy produces a zero diff; clean up any changes afterwards.
go mod tidy && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
# Check that go vet ./... produces a zero diff; clean up any changes afterwards.
go vet ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
# Check that go fmt ./... produces a zero diff; clean up any changes afterwards.
go fmt ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
73 changes: 73 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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
Loading