Skip to content

chore: lint code

chore: lint code #247

Workflow file for this run

name: Go CI
on:
- push
- pull_request
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/checkout@v3
- name: Cache Go modules
uses: actions/cache@preview
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=5m
version: latest
# Ref https://github.com/golangci/golangci-lint-action/issues/244
skip-pkg-cache: true
test:
name: Test
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/go
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/deb-sig/double-entry-generator
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: ${{ env.GOPATH }}/src/github.com/deb-sig/double-entry-generator
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17.2
- name: Check Go modules
run: |
go mod tidy && git add go.*
git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit 1);
- name: Verify gofmt
run: |
make check-format && make format && git add pkg
git diff --cached --exit-code || (echo 'Please run "make format" to verify gofmt & goimports' && exit 1);
- name: Run Go test
run: make test