use github actions instead of circle ci
parent
846cadd5fd
commit
212b9d0b03
@ -0,0 +1,31 @@
|
|||||||
|
name: Continuous Delivery
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
goreleaser:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Unshallow repo
|
||||||
|
run: git fetch --prune --unshallow
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: 1.18.x
|
||||||
|
- name: Run goreleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{secrets.API_TOKEN}}
|
||||||
|
homebrew:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Bump Homebrew formula
|
||||||
|
uses: dawidd6/action-homebrew-bump-formula@v3
|
||||||
|
with:
|
||||||
|
token: ${{secrets.API_TOKEN}}
|
||||||
|
formula: lazydocker
|
@ -0,0 +1,99 @@
|
|||||||
|
name: Continuous Integration
|
||||||
|
|
||||||
|
env:
|
||||||
|
GO_VERSION: 1.18
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
name: ci - ${{matrix.os}}
|
||||||
|
runs-on: ${{matrix.os}}
|
||||||
|
env:
|
||||||
|
GOFLAGS: -mod=vendor
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: 1.18.x
|
||||||
|
- name: Cache build
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.cache/go-build
|
||||||
|
key: ${{runner.os}}-go-${{hashFiles('**/go.sum')}}-test
|
||||||
|
restore-keys: |
|
||||||
|
${{runner.os}}-go-
|
||||||
|
- name: Test code
|
||||||
|
run: |
|
||||||
|
bash ./test.sh
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GOFLAGS: -mod=vendor
|
||||||
|
GOARCH: amd64
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: 1.18.x
|
||||||
|
- name: Cache build
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.cache/go-build
|
||||||
|
key: ${{runner.os}}-go-${{hashFiles('**/go.sum')}}-build
|
||||||
|
restore-keys: |
|
||||||
|
${{runner.os}}-go-
|
||||||
|
- name: Build linux binary
|
||||||
|
run: |
|
||||||
|
GOOS=linux go build
|
||||||
|
- name: Build windows binary
|
||||||
|
run: |
|
||||||
|
GOOS=windows go build
|
||||||
|
- name: Build darwin binary
|
||||||
|
run: |
|
||||||
|
GOOS=darwin go build
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GOFLAGS: -mod=vendor
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: 1.18.x
|
||||||
|
- name: Cache build
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.cache/go-build
|
||||||
|
key: ${{runner.os}}-go-${{hashFiles('**/go.sum')}}-test
|
||||||
|
restore-keys: |
|
||||||
|
${{runner.os}}-go-
|
||||||
|
- name: Lint
|
||||||
|
uses: golangci/golangci-lint-action@v3.1.0
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
- name: Format code
|
||||||
|
run: |
|
||||||
|
if [ $(find . ! -path "./vendor/*" -name "*.go" -exec gofmt -s -d {} \;|wc -l) -gt 0 ]; then
|
||||||
|
find . ! -path "./vendor/*" -name "*.go" -exec gofmt -s -d {} \;
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
- name: errors
|
||||||
|
run: golangci-lint run
|
||||||
|
if: ${{ failure() }}
|
@ -0,0 +1,29 @@
|
|||||||
|
linters:
|
||||||
|
disable:
|
||||||
|
- structcheck # gives false positives
|
||||||
|
enable:
|
||||||
|
- gofumpt
|
||||||
|
- thelper
|
||||||
|
- goimports
|
||||||
|
- tparallel
|
||||||
|
- wastedassign
|
||||||
|
- exportloopref
|
||||||
|
- unparam
|
||||||
|
- prealloc
|
||||||
|
- unconvert
|
||||||
|
- exhaustive
|
||||||
|
- makezero
|
||||||
|
- nakedret
|
||||||
|
# - goconst # TODO: enable and fix issues
|
||||||
|
fast: false
|
||||||
|
|
||||||
|
linters-settings:
|
||||||
|
exhaustive:
|
||||||
|
default-signifies-exhaustive: true
|
||||||
|
|
||||||
|
nakedret:
|
||||||
|
# the gods will judge me but I just don't like naked returns at all
|
||||||
|
max-func-lines: 0
|
||||||
|
|
||||||
|
run:
|
||||||
|
go: 1.18
|
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
echo "" > coverage.txt
|
||||||
|
|
||||||
|
export GOFLAGS=-mod=vendor
|
||||||
|
|
||||||
|
use_go_test=false
|
||||||
|
if command -v gotest; then
|
||||||
|
use_go_test=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
for d in $( find ./* -maxdepth 10 ! -path "./vendor*" ! -path "./.git*" ! -path "./scripts*" -type d); do
|
||||||
|
if ls $d/*.go &> /dev/null; then
|
||||||
|
args="-race -coverprofile=profile.out -covermode=atomic $d"
|
||||||
|
if [ "$use_go_test" == true ]; then
|
||||||
|
gotest $args
|
||||||
|
else
|
||||||
|
go test $args
|
||||||
|
fi
|
||||||
|
if [ -f profile.out ]; then
|
||||||
|
cat profile.out >> coverage.txt
|
||||||
|
rm profile.out
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
@ -1,11 +0,0 @@
|
|||||||
dependencies:
|
|
||||||
post:
|
|
||||||
# install golint
|
|
||||||
- go get golang.org/x/lint/golint
|
|
||||||
|
|
||||||
test:
|
|
||||||
pre:
|
|
||||||
# run analysis before tests
|
|
||||||
- go vet ./...
|
|
||||||
- test -z "$(golint ./... | tee /dev/stderr)"
|
|
||||||
- test -z "$(gofmt -s -l . | tee /dev/stderr)"
|
|
Loading…
Reference in New Issue