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

all: run builds and tests with go1.18rc1 #4143

Merged
merged 19 commits into from
Feb 24, 2022
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
9 changes: 6 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go: [1.17]
go: [1.17, 1.18.0-rc1]
Copy link
Contributor

@acharb acharb Feb 24, 2022

Choose a reason for hiding this comment

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

out of curiosity do you know why 1.16.7 isn't included in this check job but is in the build and test jobs below? wondering if it's something we can remove below as well to speed up the workflow time (or should have here as well)

Copy link
Member Author

Choose a reason for hiding this comment

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

We support the last two versions of Go, but checks can change from one version to the next in subtle ways and there's little value in running the checks twice. What's more important is running tests and building against the previous version to be sure that we aren't using an API that isn't supported in the previous version, or to detect subtle API changes. Subtle API changes are so rare in Go that we probably will never see a error.

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
stable: ${{ !contains(matrix.go, 'rc') }}
- run: ./gomod.sh
- run: ./gofmt.sh
- run: ./gogenerate.sh
Expand All @@ -29,21 +30,22 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go: [1.17, 1.16.7]
go: [1.17, 1.16.7, 1.18.0-rc1]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
stable: ${{ !contains(matrix.go, 'rc') }}
- run: go build ./...

test:
strategy:
matrix:
os: [ubuntu-latest]
go: [1.17, 1.16.7]
go: [1.17, 1.16.7, 1.18.0-rc1]
pg: [9.6.5, 10]
runs-on: ${{ matrix.os }}
services:
Expand Down Expand Up @@ -83,4 +85,5 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
stable: ${{ !contains(matrix.go, 'rc') }}
- run: go test -race -cover ./...
16 changes: 13 additions & 3 deletions staticcheck.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#! /bin/bash
set -e

gover=$(go version | { read _ _ gover _; printf $gover; })

version='2020.1.4'
if [[ "$gover" = "go1.18"* ]]; then
version='d5c28addcbbbafca0b9a0f9ad8957912e9371015'
fi

staticcheck='go run honnef.co/go/tools/cmd/staticcheck@'"$version"

printf "Running staticcheck $version...\n"
Expand All @@ -10,6 +16,10 @@ ls -d */ \
| egrep -v '^vendor|^docs' \
| xargs -I {} $staticcheck -tests=false -checks="all,-ST1003,-SA1019,-ST1005,-ST1000,-ST1016,-S1039,-ST1021,-ST1020,-ST1019,-SA4022" ./{}...


# Check horizon for unused exported symbols (relying on the fact that it should be self-contained)
$staticcheck -unused.whole-program -checks='U*' ./services/horizon/...
# Whole program unused checks were removed from staticcheck in newer versions,
# so this check is being sunset and will be removed once Go 1.18 is released and
# a proper release of staticcheck is released that supports it.
if [ "$version" = "2020.1.4" ]; then
# Check horizon for unused exported symbols (relying on the fact that it should be self-contained)
$staticcheck -unused.whole-program -checks='U*' ./services/horizon/...
fi
Comment on lines +19 to +25
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI @stellar/horizon-committers. We'll be losing this check in the very near future because it was removed from staticcheck sometime ago. When Go 1.18 is released we'll upgrade our version of staticcheck and that version won't have the whole program unused check anymore. See dominikh/go-tools@5cfc85b.