Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Go GitHub Action workflow #97

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 47 additions & 72 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,106 +3,81 @@ on:
push:
branches:
- main
pull_request: {}
pull_request: { }

jobs:
build-test:

strategy:
matrix:
os: [ macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}

build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: 1.21.x
go-version: stable

- run: go build -gcflags="-m" ./...
- name: Build
run: go build -gcflags="-m" ./...

- run: go test -v -race ./...
- name: Test
run: go test -v -race ./...

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: 1.21.x
go-version: stable

- uses: dominikh/staticcheck-action@29e9b80fb8de0521ba4ed3fdf68fed5bbe82a2d2 # v1.1.0
- uses: golangci/golangci-lint-action@v6
with:
install-go: false
version: latest
only-new-issues: true
args: -E gosec --timeout=2m --verbose

vet:
modtidy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: 1.21.x
go-version: stable

- run: go vet ./...
- name: Run go mod tidy
run: |
go mod tidy
gitdiff="$(git diff -U0)"
echo "$gitdiff"
test -z "$gitdiff"

fmt:
vendor-diff:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: 1.21.x
go-version: stable

- name: Run gofmt -d .
run: |
fmtvar="$(gofmt -d .)"
echo "$fmtvar"
test -z "$fmtvar"
- name: Checkout base commit
uses: actions/checkout@v4
with:
path: a
ref: ${{ github.base_ref }}

modtidy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download dependencies of base commit
run: go mod vendor
working-directory: a

- uses: actions/setup-go@v2
- name: Checkout PR
uses: actions/checkout@v4
with:
go-version: 1.21.x
path: b

- name: Run go mod tidy
run: |
go mod tidy
gitdiff="$(git diff -U0)"
echo "$gitdiff"
test -z "$gitdiff"
- name: Download dependencies of PR
run: go mod vendor
working-directory: b

vendor-diff:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: ^1.20

- name: Checkout base commit
uses: actions/checkout@v3
with:
path: a
ref: ${{ github.base_ref }}
- name: Download dependencies of base commit
run: go mod vendor
working-directory: a

- name: Checkout PR
uses: actions/checkout@v3
with:
path: b
- name: Download dependencies of PR
run: go mod vendor
working-directory: b

- name: Diff of dependencies
run: diff -ur --color=always a/vendor b/vendor || true
- name: Diff of dependencies
run: diff -ur --color=always a/vendor b/vendor || true
Loading