Skip to content

Commit

Permalink
Add unit test, static code analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-congo committed Feb 8, 2024
1 parent a032fa5 commit debde9d
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 24 deletions.
62 changes: 53 additions & 9 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,58 @@ jobs:
working-directory: ./go/glide
run: cargo build --release

- name: Install client dependencies
working-directory: ./go/glide
run: |
go get .
- name: Generate the Go protobuf files
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
mkdir go/glide/protobuf
protoc --proto_path=glide-core/src/protobuf \
--go_opt=Mconnection_request.proto=github.com/aws/glide-for-redis/go/glide/protobuf \
--go_opt=Mredis_request.proto=github.com/aws/glide-for-redis/go/glide/protobuf \
--go_opt=Mresponse.proto=github.com/aws/glide-for-redis/go/glide/protobuf \
--go_out=go/glide/protobuf \
--go_opt=paths=source_relative \
glide-core/src/protobuf/*.proto
mkdir go/glide/protobuf
protoc --proto_path=glide-core/src/protobuf \
--go_opt=Mconnection_request.proto=github.com/aws/glide-for-redis/go/glide/protobuf \
--go_opt=Mredis_request.proto=github.com/aws/glide-for-redis/go/glide/protobuf \
--go_opt=Mresponse.proto=github.com/aws/glide-for-redis/go/glide/protobuf \
--go_out=go/glide/protobuf \
--go_opt=paths=source_relative \
glide-core/src/protobuf/*.proto
- name: Build client
working-directory: ./go/glide
run: |
go mod edit -go=${{ matrix.go }}
go build .
- name: Run go vet
working-directory: ./go/glide
run: go vet .

- name: Run staticcheck
working-directory: ./go/glide
run: go vet .

- name: Run unit tests
working-directory: ./go/glide
run: go test -json | go-test-report -o reports/unit-test-report.html

- name: Upload test reports
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: test-reports-go-${{ matrix.go }}-redis-${{ matrix.redis }}-${{ matrix.os }}
path: |
go/glide/reports/unit-test-report.html
lint-rust:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: ./.github/workflows/lint-rust
with:
cargo-toml-folder: ./go/glide
name: lint go rust
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,3 @@ utils/tls_crts/

# java compiled files.
*.class

# Go compilation files
go/**/lib.h
*.pb.go
5 changes: 5 additions & 0 deletions go/glide/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Go compilation files
lib.h
*.pb.go

reports
3 changes: 0 additions & 3 deletions go/glide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ crate-type = ["cdylib"]
redis = { path = "../../submodules/redis-rs/redis", features = ["aio", "tokio-comp", "tls", "tokio-native-tls-comp", "tls-rustls-insecure"] }
glide-core = { path = "../../glide-core" }
tokio = { version = "^1", features = ["rt", "macros", "rt-multi-thread", "time"] }
num-derive = "0.4.0"
num-traits = "0.2.15"
tracing-subscriber = "0.3.16"
protobuf = { version = "3.3.0", features = [] }

[profile.release]
Expand Down
8 changes: 0 additions & 8 deletions go/glide/glide.go
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
package glide

import (
"fmt"
)

func main() {
fmt.Println("Hello world!")
}
12 changes: 12 additions & 0 deletions go/glide/glide_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package glide

import (
"testing"
)

func TestNothing(t *testing.T) {
someVar := true
if !someVar {
t.Fatalf("Expected someVar to be true, but was false.")
}
}
17 changes: 17 additions & 0 deletions go/glide/go.mod
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
module github.com/aws/glide-for-redis/go/glide

go 1.21.6

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
github.com/vakenbolt/go-test-report v0.9.3 // indirect
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/tools v0.12.1-0.20230825192346-2191a27a6dc5 // indirect
google.golang.org/protobuf v1.32.0 // indirect
honnef.co/go/tools v0.4.6 // indirect
)
318 changes: 318 additions & 0 deletions go/glide/go.sum

Large diffs are not rendered by default.

0 comments on commit debde9d

Please sign in to comment.