Skip to content

Commit

Permalink
Improve Go CI and Makefile targets (valkey-io#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-congo authored Mar 4, 2024
1 parent 0e7a866 commit cfc0780
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 360 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
fail-fast: false
matrix:
go:
- '1.18'
- '1.21'
- '1.18.10'
- '1.22.0'
redis:
- 6.2.14
- 7.2.3
Expand Down Expand Up @@ -60,21 +60,21 @@ jobs:
with:
redis-version: ${{ matrix.redis }}

- name: Install client dependencies
- name: Install tools for Go ${{ matrix.go }}
working-directory: ./go
run: make install-tools
run: make install-tools-go${{ matrix.go }}

- name: Build client
working-directory: ./go
run: make build

- name: Run linters
working-directory: ./go
run: make lint
run: make lint-ci

- name: Run unit tests
- name: Run tests
working-directory: ./go
run: make unit-test-report
run: make test-and-report

- name: Upload test reports
if: always()
Expand All @@ -83,7 +83,7 @@ jobs:
with:
name: test-reports-go-${{ matrix.go }}-redis-${{ matrix.redis }}-${{ matrix.os }}
path: |
go/reports/unit-test-report.html
go/reports/test-report.html
build-amazonlinux-latest:
if: github.repository_owner == 'aws'
Expand All @@ -93,7 +93,7 @@ jobs:
matrix:
go:
- 1.18.10
- 1.21.6
- 1.22.0
runs-on: ubuntu-latest
container: amazonlinux:latest
timeout-minutes: 15
Expand Down Expand Up @@ -135,29 +135,29 @@ jobs:
echo "/usr/local/go/bin" >> $GITHUB_PATH
echo "$HOME/go/bin" >> $GITHUB_PATH
- name: Install client dependencies
- name: Install tools for Go ${{ matrix.go }}
working-directory: ./go
run: make install-tools
run: make install-tools-go${{ matrix.go }}

- name: Build client
working-directory: ./go
run: make build

- name: Run linters
working-directory: ./go
run: make lint
run: make lint-ci

- name: Run unit tests
- name: Run tests
working-directory: ./go
run: make unit-test-report
run: make test-and-report

- name: Upload test reports
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: test-reports-go-${{ matrix.go }}-amazon-linux-latest
path: go/reports/unit-test-report.html
path: go/reports/test-report.html

lint-rust:
timeout-minutes: 15
Expand Down
43 changes: 39 additions & 4 deletions go/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
install-tools:
@cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %
install-build-tools:
go install google.golang.org/protobuf/cmd/[email protected]

install-dev-tools-go1.18.10:
go install github.com/vakenbolt/[email protected]
go install mvdan.cc/[email protected]
go install github.com/segmentio/[email protected]
go install honnef.co/go/tools/cmd/[email protected]

install-dev-tools-go1.22.0:
go install github.com/vakenbolt/[email protected]
go install mvdan.cc/[email protected]
go install github.com/segmentio/[email protected]
go install honnef.co/go/tools/cmd/[email protected]

install-dev-tools: install-dev-tools-go1.22.0

install-tools-go1.18.10: install-build-tools install-dev-tools-go1.18.10

install-tools-go1.22.0: install-build-tools install-dev-tools-go1.22.0

install-tools: install-tools-go1.22.0

build: build-glide-core build-glide-client generate-protobuf
go build ./...
Expand All @@ -23,7 +43,22 @@ generate-protobuf:
lint:
go vet ./...
staticcheck ./...
gofumpt -d .
golines --dry-run --shorten-comments -m 127 .

lint-ci:
go vet ./...
staticcheck ./...
if [ "$$(gofumpt -l . | wc -l)" -gt 0 ]; then exit 1; fi
if [ "$$(golines -l --shorten-comments -m 127 . | wc -l)" -gt 0 ]; then exit 1; fi

format:
gofumpt -w .
golines -w --shorten-comments -m 127 .

test:
go test -v -race `go list ./... | grep -v protobuf`

unit-test-report:
test-and-report:
mkdir -p reports
go test -race ./... -json | go-test-report -o reports/unit-test-report.html
go test -v -race `go list ./... | grep -v protobuf` -json | go-test-report -o reports/test-report.html
18 changes: 1 addition & 17 deletions go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,4 @@ module github.com/aws/glide-for-redis/go/glide

go 1.18

require (
github.com/vakenbolt/go-test-report v0.9.3
google.golang.org/protobuf v1.32.0
honnef.co/go/tools v0.3.3
)

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/tools v0.12.1-0.20230825192346-2191a27a6dc5 // indirect
)
require google.golang.org/protobuf v1.32.0
Loading

0 comments on commit cfc0780

Please sign in to comment.