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

v2: upgrade build to include go1.21 #890

Merged
merged 31 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8cf5bbc
v2: upgrade to go1.21
iand Sep 11, 2023
b1b4661
Add uci config
iand Sep 11, 2023
3997993
Use newer uci actions
iand Sep 11, 2023
77ca4ec
Fix merge conflict
iand Sep 12, 2023
d7feea9
Use v2 working directory in actions
iand Sep 12, 2023
1299359
Set go-version input in actions
iand Sep 13, 2023
ce1fa35
Set go-version input in actions
iand Sep 13, 2023
52555e3
Use go 1.20.8 in actions
iand Sep 13, 2023
9838121
Use go 1.21.1 and relative working directory
iand Sep 13, 2023
f08a1ea
Try default working directory on job
iand Sep 13, 2023
bf14d3e
Remove uci.yaml which is not supported yet
iand Sep 13, 2023
0e6e4d2
Try default working directory on job
iand Sep 13, 2023
318fdaa
Try default working directory as input
iand Sep 13, 2023
c5768c2
Restore uci.yaml
iand Sep 13, 2023
576d604
Restore uci.yaml
iand Sep 13, 2023
54cc8e8
Use modified go-check
iand Sep 13, 2023
3826f9d
Use modified go-test
iand Sep 13, 2023
f131d09
Fix go-test
iand Sep 13, 2023
b8662b9
Fix go-test
iand Sep 13, 2023
e94e01e
Fix go-test
iand Sep 13, 2023
22ad479
Merge branch 'v2-develop' into v2-go121
iand Sep 13, 2023
960eca4
Restore libp2p 0.30.0
iand Sep 13, 2023
60e8ff2
go mod tidy
iand Sep 13, 2023
ebff55e
Remove nil error return from DefaultConfig
iand Sep 13, 2023
45dbf25
use mock clock for IPNS record generation (#894)
dennis-tra Sep 13, 2023
f607a79
Use MapDatastore for provider backend tests instead of leveldb (#896)
dennis-tra Sep 13, 2023
36328b1
revert some merge residuals
dennis-tra Sep 14, 2023
961da3e
style: minor coding clean up (#898)
dennis-tra Sep 15, 2023
f28c2fc
Target go language version 1.20 and add 1.20.8 to build matrix
iand Sep 15, 2023
7e13876
Target go language version 1.20 and add 1.20.8 to build matrix
iand Sep 15, 2023
5665cda
WIP
iand Sep 15, 2023
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
4 changes: 4 additions & 0 deletions .github/uci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
files: # Configure what Unified CI templates should be used for your repository; defaults to primary language default fileset
- .github/workflows/go-check.yml
- .github/workflows/go-test.yml
force: true # Configure whether Unified CI should overwrite existing workflows; defaults to false
56 changes: 48 additions & 8 deletions .github/workflows/go-check.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.

on: [push, pull_request]
name: Go Checks

defaults:
run:
working-directory: ./v2


on:
pull_request:
push:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
unit:
runs-on: ubuntu-latest
Expand All @@ -13,15 +27,37 @@ jobs:
with:
submodules: recursive
- id: config
uses: protocol/.github/.github/actions/read-config@master
- uses: actions/setup-go@v3
uses: pl-strflt/uci/.github/actions/read-config@main
- id: go-mod
uses: pl-strflt/uci/.github/actions/read-go-mod@main
- id: go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
go-version: '1.21.1'
cache: false
- name: Run repo-specific setup
uses: ./.github/actions/go-check-setup
if: hashFiles('./.github/actions/go-check-setup') != ''
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@4970552d932f48b71485287748246cf3237cebdf # 2023.1 (v0.4.0)
env:
STATICCHECK_VERSIONS: |
{
"1.21": "9e12e6014d3b0a854950490051ad1338fc6badd1",
"1.20": "9e12e6014d3b0a854950490051ad1338fc6badd1",
"1.19": "376210a89477dedbe6fdc4484b233998650d7b3c",
"1.18": "376210a89477dedbe6fdc4484b233998650d7b3c",
"1.17": "c8caa92bad8c27ae734c6725b8a04932d54a147b",
"1.16": "4dc1992c9bb4310ba1e98b30c8d7d46444891d3b",
"1.15": "5b7de96f09104e2be384aa93a7c821eb5e77378b",
"1.14": "5b7de96f09104e2be384aa93a7c821eb5e77378b",
"1.13": "afd67930eec2a9ed3e9b19f684d17a062285f16a"
}
GO_VERSION: ${{ steps.go.outputs.go-version }}
GO111MODULE: on
run: |
version="$(jq -nr 'env.STATICCHECK_VERSIONS | fromjson | .[env.GO_VERSION | sub("\\.[^.]+$"; "")] // "latest"')"
echo "Installing staticcheck@$version"
go install honnef.co/go/tools/cmd/staticcheck@$version || go get honnef.co/go/tools/cmd/staticcheck@$version
- name: Check that go.mod is tidy
uses: protocol/[email protected]
with:
Expand All @@ -32,6 +68,7 @@ jobs:
exit 1
fi
git diff --exit-code -- go.sum go.mod
working-directory: ./v2
- name: gofmt
if: success() || failure() # run this step even if the previous one failed
run: |
Expand All @@ -45,13 +82,15 @@ jobs:
uses: protocol/[email protected]
with:
run: go vet ./...
working-directory: ./v2
- name: staticcheck
if: success() || failure() # run this step even if the previous one failed
uses: protocol/[email protected]
with:
run: |
set -o pipefail
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
working-directory: ./v2
- name: go generate
uses: protocol/[email protected]
if: (success() || failure()) && fromJSON(steps.config.outputs.json).gogenerate == true
Expand All @@ -65,3 +104,4 @@ jobs:
git status --short
exit 1
fi
working-directory: ./v2
95 changes: 68 additions & 27 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,87 @@
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.

on: [push, pull_request]
name: Go Test

on:
pull_request:
push:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
unit:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu", "windows", "macos" ]
go: ["1.19.x","1.20.x"]
go: ["1.21.1"]
env:
COVERAGES: ""
GOTESTFLAGS: -cover -coverprofile=module-coverage.txt -coverpkg=./...
GO386FLAGS: ''
GORACEFLAGS: ''
runs-on: ${{ fromJSON(vars[format('UCI_GO_TEST_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }}
name: ${{ matrix.os }} (go ${{ matrix.go }})
steps:
- name: Use msys2 on windows
if: matrix.os == 'windows'
# The executable for msys2 is also called bash.cmd
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells
# If we prepend its location to the PATH
# subsequent 'shell: bash' steps will use msys2 instead of gitbash
run: echo "C:/msys64/usr/bin" >> $GITHUB_PATH
- uses: actions/checkout@v3
with:
submodules: recursive
# Update to v4 is blocked by https://github.com/actions/setup-go/pull/411
# - uses: actions/setup-go@v4
- uses: actions/setup-go@v3
with:
go-version: stable
# cache: false
- id: config
uses: protocol/.github/.github/actions/read-config@master
uses: pl-strflt/uci/.github/actions/read-config@main
- id: go-mod
uses: pl-strflt/uci/.github/actions/read-go-mod@main
- id: go
uses: actions/setup-go@v4
with:
go-version: '1.21.1'
cache: false
- if: toJSON(fromJSON(steps.config.outputs.json).shuffle) != 'false'
run: |
echo "GOTESTFLAGS=-shuffle=on $GOTESTFLAGS" >> $GITHUB_ENV
echo "GO386FLAGS=-shuffle=on $GO386FLAGS" >> $GITHUB_ENV
echo "GORACEFLAGS=-shuffle=on $GORACEFLAGS" >> $GITHUB_ENV
- if: toJSON(fromJSON(steps.config.outputs.json).verbose) != 'false'
run: |
echo "GOTESTFLAGS=-v $GOTESTFLAGS" >> $GITHUB_ENV
echo "GO386FLAGS=-v $GO386FLAGS" >> $GITHUB_ENV
echo "GORACEFLAGS=-v $GORACEFLAGS" >> $GITHUB_ENV
# Update to v4 is blocked by https://github.com/actions/setup-go/pull/411
# - uses: actions/setup-go@v4
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
go-version: ${{ steps.go.outputs.version }}
- name: Go information
run: |
go version
go env
- name: Use msys2 on windows
if: matrix.os == 'windows'
shell: bash
# The executable for msys2 is also called bash.cmd
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells
# If we prepend its location to the PATH
# subsequent 'shell: bash' steps will use msys2 instead of gitbash
run: echo "C:/msys64/usr/bin" >> $GITHUB_PATH
- name: Run repo-specific setup
uses: ./.github/actions/go-test-setup
if: hashFiles('./.github/actions/go-test-setup') != ''
- name: Run tests
if: contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
uses: protocol/[email protected]
env:
GOFLAGS: ${{ format('{0} {1}', env.GOTESTFLAGS, env.GOFLAGS) }}
with:
# Use -coverpkg=./..., so that we include cross-package coverage.
# If package ./A imports ./B, and ./A's tests also cover ./B,
# this means ./B's coverage will be significantly higher than 0%.
run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./...
run: go test ./...
working-directory: ./v2
- name: Run tests (32 bit)
# can't run 32 bit tests on OSX.
if: matrix.os != 'macos' &&
Expand All @@ -55,22 +90,28 @@ jobs:
uses: protocol/[email protected]
env:
GOARCH: 386
GOFLAGS: ${{ format('{0} {1}', env.GO386FLAGS, env.GOFLAGS) }}
with:
run: |
export "PATH=$PATH_386:$PATH"
go test -v -shuffle=on ./...
go test ./...
working-directory: ./v2
- name: Run tests with race detector
# speed things up. Windows and OSX VMs are slow
if: matrix.os == 'ubuntu' &&
fromJSON(steps.config.outputs.json).skipRace != true &&
contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
uses: protocol/[email protected]
env:
GOFLAGS: ${{ format('{0} {1}', env.GORACEFLAGS, env.GOFLAGS) }}
with:
run: go test -v -race ./...
run: go test -race ./...
working-directory: ./v2
- name: Collect coverage files
shell: bash
run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
id: coverages
run: echo "files=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_OUTPUT
- name: Upload coverage to Codecov
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
with:
files: '${{ env.COVERAGES }}'
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}
files: ${{ steps.coverages.outputs.files }}
env_vars: OS=${{ matrix.os }}, GO=${{ steps.go.outputs.version }}
18 changes: 12 additions & 6 deletions .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.

name: Release Checker

on:
pull_request_target:
paths: [ 'version.json' ]
types: [ opened, synchronize, reopened, labeled, unlabeled ]
workflow_dispatch:

permissions:
contents: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release-check:
uses: protocol/.github/.github/workflows/release-check.yml@master
with:
go-version: 1.20.x
uses: pl-strflt/uci/.github/workflows/[email protected]
14 changes: 10 additions & 4 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.

name: Releaser

on:
push:
paths: [ 'version.json' ]
workflow_dispatch:

permissions:
contents: write

concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true

jobs:
releaser:
uses: protocol/.github/.github/workflows/releaser.yml@master
uses: pl-strflt/uci/.github/workflows/releaser.yml@v0.0
14 changes: 10 additions & 4 deletions .github/workflows/tagpush.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.

name: Tag Push Checker

on:
push:
tags:
- v*

permissions:
contents: read
issues: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
releaser:
uses: protocol/.github/.github/workflows/tagpush.yml@master
uses: pl-strflt/uci/.github/workflows/tagpush.yml@v0.0
4 changes: 2 additions & 2 deletions v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ type Config struct {
// instantiate a fully functional [DHT] client. All fields that are nil require
// some additional information to instantiate. The default values for these
// fields come from separate top-level methods prefixed with Default.
func DefaultConfig() *Config {
func DefaultConfig() (*Config, error) {
Copy link
Contributor

@dennis-tra dennis-tra Sep 13, 2023

Choose a reason for hiding this comment

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

I guess this is a result from a merge. We don't need an error return value here. This is the source for the comparatively large diff here.

Copy link
Author

Choose a reason for hiding this comment

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

I've removed in the next PR in the chain #887

Copy link
Author

Choose a reason for hiding this comment

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

Will remove here though - didn't realise there were so many

return &Config{
Clock: clock.New(),
Mode: ModeOptAutoClient,
Expand All @@ -193,7 +193,7 @@ func DefaultConfig() *Config {
AddressFilter: AddrFilterPrivate,
MeterProvider: otel.GetMeterProvider(),
TracerProvider: otel.GetTracerProvider(),
}
}, nil
}

// DefaultRoutingTable returns a triert.TrieRT routing table. This routing table
Expand Down
Loading