From 11b51081fec9345959d366f1c19e5f20d09e3573 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Tue, 15 Aug 2023 05:28:42 -0700 Subject: [PATCH] tests: Use Go 1.21.x (#851) * tests: Use Go 1.21.x * Fix vet * Upgrade goreleaser & garble * Install in pre-hook only. * Remove deprecated replacements. * Work around garble compiler issue --- .github/workflows/go.yml | 17 +++++++---------- .github/workflows/release.yml | 7 ++----- .goreleaser.yml | 20 +++----------------- s2/index.go | 20 +++++++++----------- zstd/fuzz_test.go | 8 ++++---- 5 files changed, 25 insertions(+), 47 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4b6d6d89cd..f00c06aea8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,7 +12,7 @@ jobs: build: strategy: matrix: - go-version: [1.18.x, 1.19.x, 1.20.x] + go-version: [1.19.x, 1.20.x, 1.21.x] os: [ubuntu-latest, macos-latest, windows-latest] env: CGO_ENABLED: 0 @@ -54,7 +54,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.20.x + go-version: 1.21.x - name: Checkout code uses: actions/checkout@v2 @@ -76,7 +76,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.20.x + go-version: 1.21.x - name: Checkout code uses: actions/checkout@v2 @@ -90,14 +90,11 @@ jobs: - name: Build s2c run: go build github.com/klauspost/compress/s2/cmd/s2c && go build github.com/klauspost/compress/s2/cmd/s2d&&./s2c -verify s2c &&./s2d s2c.s2&&rm ./s2c&&rm s2d&&rm s2c.s2 - - name: install garble - run: go install mvdan.cc/garble@v0.9.2 - - name: goreleaser deprecation - run: curl -sfL https://git.io/goreleaser | VERSION=v1.9.2 sh -s -- check + run: curl -sfL https://git.io/goreleaser | VERSION=v1.20.0 sh -s -- check - name: goreleaser snapshot - run: curl -sL https://git.io/goreleaser | VERSION=v1.9.2 sh -s -- --snapshot --skip-publish --rm-dist + run: curl -sL https://git.io/goreleaser | VERSION=v1.20.0 sh -s -- --snapshot --skip-publish --rm-dist - name: Test S2 GOAMD64 v3 env: @@ -119,7 +116,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.20.x + go-version: 1.21.x - name: Checkout code uses: actions/checkout@v2 @@ -190,7 +187,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.20.x + go-version: 1.21.x - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d62271f1a6..d9ca40bae2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,15 +21,12 @@ jobs: name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.20.x - - - name: install garble - run: go install mvdan.cc/garble@v0.9.2 + go-version: 1.21.x - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: - version: 1.9.2 + version: 1.20.0 args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 7a008a4d23..4c28dff465 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -3,7 +3,7 @@ before: hooks: - ./gen.sh - - go install mvdan.cc/garble@v0.9.3 + - go install mvdan.cc/garble@v0.10.1 builds: - @@ -92,16 +92,7 @@ builds: archives: - id: s2-binaries - name_template: "s2-{{ .Os }}_{{ .Arch }}_{{ .Version }}" - replacements: - aix: AIX - darwin: OSX - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 - freebsd: FreeBSD - netbsd: NetBSD + name_template: "s2-{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" format_overrides: - goos: windows format: zip @@ -125,7 +116,7 @@ changelog: nfpms: - - file_name_template: "s2_package_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + file_name_template: "s2_package__{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" vendor: Klaus Post homepage: https://github.com/klauspost/compress maintainer: Klaus Post @@ -134,8 +125,3 @@ nfpms: formats: - deb - rpm - replacements: - darwin: Darwin - linux: Linux - freebsd: FreeBSD - amd64: x86_64 diff --git a/s2/index.go b/s2/index.go index dd9ecfe718..18a4f7acd6 100644 --- a/s2/index.go +++ b/s2/index.go @@ -511,24 +511,22 @@ func IndexStream(r io.Reader) ([]byte, error) { // JSON returns the index as JSON text. func (i *Index) JSON() []byte { + type offset struct { + CompressedOffset int64 `json:"compressed"` + UncompressedOffset int64 `json:"uncompressed"` + } x := struct { - TotalUncompressed int64 `json:"total_uncompressed"` // Total Uncompressed size if known. Will be -1 if unknown. - TotalCompressed int64 `json:"total_compressed"` // Total Compressed size if known. Will be -1 if unknown. - Offsets []struct { - CompressedOffset int64 `json:"compressed"` - UncompressedOffset int64 `json:"uncompressed"` - } `json:"offsets"` - EstBlockUncomp int64 `json:"est_block_uncompressed"` + TotalUncompressed int64 `json:"total_uncompressed"` // Total Uncompressed size if known. Will be -1 if unknown. + TotalCompressed int64 `json:"total_compressed"` // Total Compressed size if known. Will be -1 if unknown. + Offsets []offset `json:"offsets"` + EstBlockUncomp int64 `json:"est_block_uncompressed"` }{ TotalUncompressed: i.TotalUncompressed, TotalCompressed: i.TotalCompressed, EstBlockUncomp: i.estBlockUncomp, } for _, v := range i.info { - x.Offsets = append(x.Offsets, struct { - CompressedOffset int64 `json:"compressed"` - UncompressedOffset int64 `json:"uncompressed"` - }{CompressedOffset: v.compressedOffset, UncompressedOffset: v.uncompressedOffset}) + x.Offsets = append(x.Offsets, offset{CompressedOffset: v.compressedOffset, UncompressedOffset: v.uncompressedOffset}) } b, _ := json.MarshalIndent(x, "", " ") return b diff --git a/zstd/fuzz_test.go b/zstd/fuzz_test.go index ed7ce6703e..2cd32bab76 100644 --- a/zstd/fuzz_test.go +++ b/zstd/fuzz_test.go @@ -30,12 +30,12 @@ func FuzzDecodeAll(f *testing.F) { decLow, err := NewReader(nil, WithDecoderLowmem(true), WithDecoderConcurrency(2), WithDecoderMaxMemory(20<<20), WithDecoderMaxWindow(1<<20), IgnoreChecksum(true)) if err != nil { - f.Fatal(err) + t.Fatal(err) } defer decLow.Close() decHi, err := NewReader(nil, WithDecoderLowmem(false), WithDecoderConcurrency(2), WithDecoderMaxMemory(20<<20), WithDecoderMaxWindow(1<<20), IgnoreChecksum(true)) if err != nil { - f.Fatal(err) + t.Fatal(err) } defer decHi.Close() b1, err1 := decLow.DecodeAll(b, make([]byte, 0, len(b))) @@ -82,14 +82,14 @@ func FuzzDecoder(f *testing.F) { brHi.Reset(b) decLow, err := NewReader(brLow, WithDecoderLowmem(true), WithDecoderConcurrency(2), WithDecoderMaxMemory(20<<20), WithDecoderMaxWindow(1<<20), IgnoreChecksum(true), WithDecodeBuffersBelow(8<<10)) if err != nil { - f.Fatal(err) + t.Fatal(err) } defer decLow.Close() // Test with high memory, but sync decoding decHi, err := NewReader(brHi, WithDecoderLowmem(false), WithDecoderConcurrency(1), WithDecoderMaxMemory(20<<20), WithDecoderMaxWindow(1<<20), IgnoreChecksum(true), WithDecodeBuffersBelow(8<<10)) if err != nil { - f.Fatal(err) + t.Fatal(err) } defer decHi.Close()