Skip to content

Commit

Permalink
feat: add github actions workflows (#3)
Browse files Browse the repository at this point in the history
feat: add github actions workflows
  • Loading branch information
wass3r authored Jul 21, 2020
2 parents e4669ba + e160555 commit 59f86fc
Show file tree
Hide file tree
Showing 12 changed files with 425 additions and 0 deletions.
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
4 changes: 4 additions & 0 deletions cmd/secret-vault/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func TestVault_Plugin_Validate(t *testing.T) {
},
err: nil,
},
Read: &Read{
Path: "/path/to/secret",
Keys: []string{"foobar"},
},
}

// run test
Expand Down
Loading

0 comments on commit 59f86fc

Please sign in to comment.