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

chore: Bump to GoLang v1.20 #1689

Merged
merged 9 commits into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/build-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.20"
check-latest: true

- name: Build all dependencies
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/check-vulnerabilities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2023 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

name: Check Vulnerabilities Workflow

on:
pull_request:
branches:
- master
- develop

push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- master
- develop

jobs:
check-vulnerabilities:
name: Check vulnerabilities job

runs-on: ubuntu-latest

steps:
- name: Run govulncheck
uses: golang/govulncheck-action@v1
with:
go-version-input: "1.20"
go-package: ./...
check-latest: true
cache: true
2 changes: 1 addition & 1 deletion .github/workflows/code-test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.20"
check-latest: true

- name: Generate full test coverage report using go-acc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/detect-change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.20"
check-latest: true

- name: Build dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-then-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.20"
check-latest: true

- name: Run the golangci-lint
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.20"
check-latest: true

- name: Check linting through golangci-lint
Expand All @@ -46,7 +46,7 @@ jobs:
# Required: the version of golangci-lint is required.
# Note: The version should not pick the patch version as the latest patch
# version is what will always be used.
version: v1.51
version: v1.53

# Optional: working directory, useful for monorepos or if we wanted to run this
# on a non-root directory.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.20"
check-latest: true

- name: Build dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/start-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.20"
check-latest: true

- name: Build modules
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ client\:add-schema:

.PHONY: deps\:lint
deps\:lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53

.PHONY: deps\:test
deps\:test:
Expand Down Expand Up @@ -158,7 +158,7 @@ verify:

.PHONY: tidy
tidy:
go mod tidy -go=1.19
go mod tidy -go=1.20

.PHONY: clean
clean:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/sourcenetwork/defradb

go 1.19
go 1.20

require (
github.com/bits-and-blooms/bitset v1.8.0
Expand Down
16 changes: 0 additions & 16 deletions tests/bench/bench_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ package bench
import (
"context"
"fmt"
"hash/fnv"
"math"
"math/rand"
"os"
"sync"
"testing"
Expand Down Expand Up @@ -43,26 +41,12 @@ var (
func init() {
logging.SetConfig(logging.Config{Level: logging.NewLogLevelOption(logging.Error)})

// create a consistent seed value for the random package
// so we don't have random fluctuations between runs
// (specifically thinking about the fixture generation stuff)
seed := hashToInt64("https://xkcd.com/221/")
rand.Seed(seed)
Comment on lines -46 to -50
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsimnz Do you see value in having a consistent seed and passing it the place where the random generation happens (as now it's not a global thing but a local object we would have to pass around with an initiated seed).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made issue for tracking: #1690


// assign if not empty
if s := os.Getenv(storageEnvName); s != "" {
storage = s
}
}

// hashToInt64 uses the FNV-1 hash to int
// algorithm
func hashToInt64(s string) int64 {
h := fnv.New64a()
h.Write([]byte(s))
return int64(h.Sum64())
}

func SetupCollections(
b *testing.B,
ctx context.Context,
Expand Down
5 changes: 3 additions & 2 deletions tests/bench/storage/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ package storage

import (
"context"
"math/rand"
"crypto/rand"
mathRand "math/rand"
"sort"
"testing"

Expand Down Expand Up @@ -327,5 +328,5 @@ func getSampledIndex(populationSize int, sampleSize int, i int) int {
}

pointsPerInterval := populationSize / sampleSize
return (i * pointsPerInterval) + rand.Intn(pointsPerInterval)
return (i * pointsPerInterval) + mathRand.Intn(pointsPerInterval)
}
4 changes: 2 additions & 2 deletions tests/integration/change_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func detectDbChangesInit(repository string, targetBranch string) {

latestTargetCommitHash := getLatestCommit(repository, targetBranch)
detectDbChangesCodeDir = path.Join(changeDetectorTempDir, "code", latestTargetCommitHash)
rand.Seed(time.Now().Unix())
randNumber := rand.Int()
r := rand.New(rand.NewSource(time.Now().Unix()))
randNumber := r.Int()
dbsDir := path.Join(changeDetectorTempDir, "dbs", fmt.Sprint(randNumber))

testPackagePath, isIntegrationTest := getTestPackagePath()
Expand Down
4 changes: 2 additions & 2 deletions tools/cloud/aws/packer/build_aws_ami.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ build {
inline = [
"/usr/bin/cloud-init status --wait",
"sudo apt-get update && sudo apt-get install make build-essential -y",
"curl -OL https://golang.org/dl/go1.19.8.linux-amd64.tar.gz",
"rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.19.8.linux-amd64.tar.gz",
"curl -OL https://golang.org/dl/go1.20.6.linux-amd64.tar.gz",
"rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.20.6.linux-amd64.tar.gz",
"export PATH=$PATH:/usr/local/go/bin",
"git clone \"https://git@$DEFRADB_GIT_REPO\"",
"cd ./defradb || { printf \"\\\ncd into defradb failed.\\\n\" && exit 2; }",
Expand Down
8 changes: 4 additions & 4 deletions tools/configs/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ run:

# Define the Go version limit.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`.
go: "1.19"
go: "1.20"

#=====================================================================================[ Output Configuration Options ]
output:
Expand Down Expand Up @@ -263,7 +263,7 @@ linters-settings:

gosimple:
# Select the Go version to target.
go: "1.19"
go: "1.20"
# https://staticcheck.io/docs/options#checks
checks: ["all", "-S1038"]
# Turn on all except (these are disabled):
Expand Down Expand Up @@ -355,13 +355,13 @@ linters-settings:

staticcheck:
# Select the Go version to target.
go: "1.19"
go: "1.20"
# https://staticcheck.io/docs/options#checks
checks: ["all"]

unused:
# Select the Go version to target.
go: "1.19"
go: "1.20"

whitespace:
# Enforces newlines (or comments) after every multi-line if statement.
Expand Down
2 changes: 1 addition & 1 deletion tools/defradb-builder.containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# An image with defradb's code and go tooling available, to assemble in a larger container.

FROM docker.io/golang:1.19 AS BUILD
FROM docker.io/golang:1.20 AS BUILD

WORKDIR /lib/defradb/

Expand Down
2 changes: 1 addition & 1 deletion tools/defradb.containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Stage: BUILD
# Several steps are involved to enable caching and because of the behavior of COPY regarding directories.
FROM docker.io/golang:1.19 AS BUILD
FROM docker.io/golang:1.20 AS BUILD
WORKDIR /repo/
COPY go.mod go.sum Makefile ./
RUN make deps:modules
Expand Down