Skip to content

refactor: ♻️ address several minor potential lint errors (#48) #131

refactor: ♻️ address several minor potential lint errors (#48)

refactor: ♻️ address several minor potential lint errors (#48) #131

Workflow file for this run

name: Go
on:
push:
branches: [main]
pull_request:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/checkout@v2
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-lint-${{ hashFiles('.github/workflows/go.yml') }}
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-lint-${{ hashFiles('.github/workflows/go.yml') }}
- name: formatting
if: ${{ always() }}
run: |
go run golang.org/x/tools/cmd/[email protected] -w .
go run mvdan.cc/[email protected] -w .
[[ -z $(git status -s) ]] || (echo "::error::Formatting"; exit 1)
- name: revive (run)
id: revive_lint
if: ${{ always() }}
shell: bash {0} # don't fail fast
run: |
FINDINGS=$(go run github.com/mgechev/[email protected] -config ci/revive.toml --formatter json ./...)
code=$?
echo "::set-output name=findings::${FINDINGS}"
exit $code
- name: revive (report)
if: ${{ always() && fromJSON(steps.revive_lint.outputs.findings)[0] != null }}
run: |
echo "::group::Failures"
while read -r line; do
eval "$(echo ${line} | jq -r '@sh "severity=\(.Severity) failure=\(.Failure) file=\(.Position.Start.Filename) l=\(.Position.Start.Line) col=\(.Position.Start.Column)"')"
echo "::${severity} file=$file,line=$l,col=$col::${failure}"
done < <(
jq -c '.[]' <<-EOF
${{ steps.revive_lint.outputs.findings }}
EOF
)
echo "::endgroup::"
- name: markdownlint
if: ${{ always() }}
uses: nosborn/github-action-markdown-cli@v2
with:
files: .
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/checkout@v2
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- run: |
go build -v .
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/checkout@v2
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- run: |
go test -v \
-coverprofile=coverage.txt \
-covermode=atomic \
-coverpkg=./... \
./...
- name: collect code coverage
uses: codecov/codecov-action@v2
with:
file: ./coverage.txt