Go mod tidy #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code Check and Acceptance Tests | |
on: | |
push: | |
branches: [ "main", "go-cli" ] | |
pull_request: | |
paths: | |
- '.github/workflows/code-check-and-tests.yaml' | |
- '**.go' | |
- 'go.mod' | |
- 'go.sum' | |
- '.golangci.yml' | |
schedule: | |
- cron: '44 8 * * 6' | |
permissions: | |
contents: read | |
jobs: | |
# Ensure the project can build first | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- name: Get dependencies | |
run: | | |
go mod tidy | |
git diff --compact-summary --exit-code || \ | |
(echo; echo "Unexpected difference after 'go mod tidy'. Run 'go mod tidy' command and commit."; exit 1) | |
- name: Build | |
run: | | |
make install | |
fmt: | |
name: go fmt | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: | | |
if [ "$(go fmt ./... | wc -l)" -gt 0 ]; then | |
echo "::error::'go fmt' found required formatting changes. Run 'make fmt' on your branch." | |
exit 1; | |
fi | |
vet: | |
name: go vet | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: make vet | |
lint: | |
name: golangcli-lint | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: make golangcilint | |
importfmt: | |
name: importfmt | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: make importfmtlint | |
acceptance: | |
name: Tests | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: | |
make test |