Skip to content

Commit

Permalink
Add Go 1.20 Compatibility (#1035)
Browse files Browse the repository at this point in the history
* Fix deprecated go test -i flag

* Bump golangci-lint from v1.50.1 to v1.51.1

* Fix loopclosure: loop variable test captured by func literal

* Exclude deprecated rand.Seed staticcheck in golangci-lint

* Generate protoc and mockgen files in ci-ready

* Remove random seed from trillian/integration
  • Loading branch information
roger2hk authored Feb 21, 2023
1 parent 90460bd commit f944df0
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ linters:

issues:
# Don't turn off any checks by default. We can do this explicitly if needed.
exclude-use-default: false
exclude-use-default: false
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### Misc

* Updated golangci-lint to v1.50.1 (developers should update to this version).
* Updated golangci-lint to v1.51.1 (developers should update to this version).
* Bump Go version from 1.17 to 1.19.

## v1.1.4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pull requests for review.

```bash
# Install golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1

# Run code generation, build, test and linters
./scripts/presubmit.sh
Expand Down
6 changes: 5 additions & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ steps:
go.etcd.io/etcd/v3 go.etcd.io/etcd/etcdctl/v3 \
github.com/fullstorydev/grpcurl/cmd/grpcurl
# Generate all protoc and mockgen files
go generate -run="protoc" ./...
go generate -run="mockgen" ./...
# Cache all the modules we'll need too
go mod download
go test -i ./...
go test ./...
# Wait for trillian logserver to be up
until nc -z deployment_trillian-log-server_1 8090; do echo .; sleep 5; done
Expand All @@ -90,6 +93,7 @@ steps:
id: 'default_test'
env:
- 'GOFLAGS='
- 'PRESUBMIT_OPTS=--no-generate'
- 'TRILLIAN_LOG_SERVERS=deployment_trillian-log-server_1:8090'
- 'TRILLIAN_LOG_SERVER_1=deployment_trillian-log-server_1:8090'
waitFor: ['ci-ready']
Expand Down
6 changes: 5 additions & 1 deletion cloudbuild_master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ steps:
go.etcd.io/etcd/v3 go.etcd.io/etcd/etcdctl/v3 \
github.com/fullstorydev/grpcurl/cmd/grpcurl
# Generate all protoc and mockgen files
go generate -run="protoc" ./...
go generate -run="mockgen" ./...
# Cache all the modules we'll need too
go mod download
go test -i ./...
go test ./...
# Wait for trillian logserver to be up
until nc -z deployment_trillian-log-server_1 8090; do echo .; sleep 5; done
Expand All @@ -90,6 +93,7 @@ steps:
id: 'default_test'
env:
- 'GOFLAGS='
- 'PRESUBMIT_OPTS=--no-generate'
- 'TRILLIAN_LOG_SERVERS=deployment_trillian-log-server_1:8090'
- 'TRILLIAN_LOG_SERVER_1=deployment_trillian-log-server_1:8090'
waitFor: ['ci-ready']
Expand Down
6 changes: 5 additions & 1 deletion cloudbuild_tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ steps:
go.etcd.io/etcd/v3 go.etcd.io/etcd/etcdctl/v3 \
github.com/fullstorydev/grpcurl/cmd/grpcurl
# Generate all protoc and mockgen files
go generate -run="protoc" ./...
go generate -run="mockgen" ./...
# Cache all the modules we'll need too
go mod download
go test -i ./...
go test ./...
# Wait for trillian logserver to be up
until nc -z deployment_trillian-log-server_1 8090; do echo .; sleep 5; done
Expand All @@ -90,6 +93,7 @@ steps:
id: 'default_test'
env:
- 'GOFLAGS='
- 'PRESUBMIT_OPTS=--no-generate'
- 'TRILLIAN_LOG_SERVERS=deployment_trillian-log-server_1:8090'
- 'TRILLIAN_LOG_SERVER_1=deployment_trillian-log-server_1:8090'
waitFor: ['ci-ready']
Expand Down
2 changes: 1 addition & 1 deletion integration/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ENV GO111MODULE=on
RUN apt-get update && apt-get -y install build-essential curl docker-compose lsof netcat unzip wget xxd

RUN cd /usr/bin && curl -L -O https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && mv jq-linux64 /usr/bin/jq && chmod +x /usr/bin/jq
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.1
RUN mkdir protoc && \
(cd protoc && \
PROTOC_VERSION=3.20.1 && \
Expand Down
1 change: 1 addition & 0 deletions schedule/schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func TestEvery(t *testing.T) {
},
} {
t.Run(test.name, func(t *testing.T) {
test := test
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), test.timeout)
defer cancel()
Expand Down
7 changes: 0 additions & 7 deletions trillian/integration/ct_hammer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"flag"
"fmt"
"io"
"math/rand"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -64,7 +63,6 @@ var (
parallelFetch = flag.Int("parallel_fetch", 2, "Number of concurrent GetEntries fetches")

metricsEndpoint = flag.String("metrics_endpoint", "", "Endpoint for serving metrics; if left empty, metrics will not be exposed")
seed = flag.Int64("seed", -1, "Seed for random number generation")
logConfig = flag.String("log_config", "", "File holding log config in JSON")
mmd = flag.Duration("mmd", 2*time.Minute, "Default MMD for logs")
operations = flag.Uint64("operations", ^uint64(0), "Number of operations to perform")
Expand Down Expand Up @@ -177,11 +175,6 @@ func main() {
if *logConfig == "" {
klog.Exit("Test aborted as no log config provided (via --log_config)")
}
if *seed == -1 {
*seed = time.Now().UTC().UnixNano() & 0xFFFFFFFF
}
fmt.Printf("Today's test has been brought to you by the letters C and T and the number %#x\n", *seed)
rand.Seed(*seed)

cfg, err := ctfe.LogConfigFromFile(*logConfig)
if err != nil {
Expand Down
7 changes: 0 additions & 7 deletions trillian/integration/ct_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"encoding/pem"
"flag"
"fmt"
"math/rand"
"os"
"strings"
"testing"
Expand All @@ -38,7 +37,6 @@ var (
httpServers = flag.String("ct_http_servers", "localhost:8092", "Comma-separated list of (assumed interchangeable) servers, each as address:port")
metricsServers = flag.String("ct_metrics_servers", "localhost:8093", "Comma-separated list of (assumed interchangeable) metrics servers, each as address:port")
testDir = flag.String("testdata_dir", "testdata", "Name of directory with test data")
seed = flag.Int64("seed", -1, "Seed for random number generation")
logConfig = flag.String("log_config", "", "File holding log config in JSON")
mmd = flag.Duration("mmd", 30*time.Second, "MMD for tested logs")
skipStats = flag.Bool("skip_stats", false, "Skip checks of expected log statistics")
Expand All @@ -49,11 +47,6 @@ func commonSetup(t *testing.T) []*configpb.LogConfig {
if *logConfig == "" {
t.Skip("Integration test skipped as no log config provided")
}
if *seed == -1 {
*seed = time.Now().UTC().UnixNano() & 0xFFFFFFFF
}
fmt.Printf("Today's test has been brought to you by the letters C and T and the number %#x\n", *seed)
rand.Seed(*seed)

cfgs, err := ctfe.LogConfigFromFile(*logConfig)
if err != nil {
Expand Down

0 comments on commit f944df0

Please sign in to comment.