Skip to content

Commit

Permalink
bump tested Go versions to just 1.20 and 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
extemporalgenome committed Dec 1, 2023
1 parent 74be2f5 commit c9c213a
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 72 deletions.
88 changes: 45 additions & 43 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,63 @@
---
name: Benchmark

on:
- pull_request
"on":
- pull_request

jobs:
benchmark:
strategy:
matrix:
ref:
- master
- ${{ github.sha }}
- master
- ${{ github.sha }}

runs-on: ubuntu-latest

steps:
- name: Steup Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ matrix.ref }}

- name: Run Benchmarks
run: go test -v -run '^$' -bench '(Marshal|Unmarshal)$/codeResponse' -benchmem -benchtime 3s -cpu 1 -count 5 ./json | tee bench.txt

- name: Upload Benchmarks
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.ref }}
path: bench.txt
- name: Steup Go
uses: actions/setup-go@v2
with:
go-version: "1.21"

- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ matrix.ref }}

- name: Run Benchmarks
# Without 6 iterations, benchstat will claim statistical insignificance.
run: go test -v -run '^$' -bench '(Marshal|Unmarshal)$/codeResponse' -benchmem -benchtime 3s -cpu 1 -count 6 ./json | tee bench.txt

- name: Upload Benchmarks
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.ref }}
path: bench.txt

benchstat:
needs: [benchmark]
runs-on: ubuntu-latest

steps:
- name: Steup Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Setup Benchstat
run: go install golang.org/x/perf/cmd/benchstat@latest

- name: Download Benchmark Results
uses: actions/download-artifact@v2
with:
path: .

- name: Run Benchstat
run: benchstat ./master/bench.txt ./${{ github.sha }}/bench.txt | tee benchstat.txt

- name: Upload Benchstat Results
uses: actions/upload-artifact@v2
with:
name: benchstat
path: benchstat.txt
- name: Steup Go
uses: actions/setup-go@v2
with:
go-version: "1.21"

- name: Setup Benchstat
run: go install golang.org/x/perf/cmd/benchstat@latest

- name: Download Benchmark Results
uses: actions/download-artifact@v2
with:
path: .

- name: Run Benchstat
run: benchstat ./master/bench.txt ./${{ github.sha }}/bench.txt | tee benchstat.txt

- name: Upload Benchstat Results
uses: actions/upload-artifact@v2
with:
name: benchstat
path: benchstat.txt
29 changes: 14 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
---
name: Test

on:
- pull_request
"on":
- pull_request

jobs:
test:
strategy:
matrix:
go:
- 1.14
- 1.15
- 1.16
- 1.17
- "1.20"
- "1.21"

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Download Dependencies
run: go mod download
- name: Download Dependencies
run: go mod download

- name: Run Tests
run: make test
- name: Run Tests
run: make test
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: test bench-simple clean update-golang-test fuzz fuzz-json

golang.version ?= 1.15.2
golang.version ?= 1.21
golang.tmp.root := /tmp/golang$(golang.version)
golang.tmp.json.root := $(golang.tmp.root)/go-go$(golang.version)/src/encoding/json
golang.test.files := $(wildcard json/golang_*_test.go)
Expand All @@ -10,7 +10,7 @@ go-fuzz-build := ${GOPATH}/bin/go-fuzz-build
go-fuzz-corpus := ${GOPATH}/src/github.com/dvyukov/go-fuzz-corpus
go-fuzz-dep := ${GOPATH}/src/github.com/dvyukov/go-fuzz/go-fuzz-dep

test: test-ascii test-json test-json-bugs test-json-1.17 test-proto test-iso8601 test-thrift test-purego
test: test-ascii test-json test-json-bugs test-proto test-iso8601 test-thrift test-purego

test-ascii:
go test -cover -race ./ascii
Expand All @@ -21,9 +21,6 @@ test-json:
test-json-bugs:
go test -race ./json/bugs/...

test-json-1.17:
go test -cover -race -tags go1.17 ./json

test-proto:
go test -cover -race ./proto

Expand Down
6 changes: 3 additions & 3 deletions json/golang_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"bytes"
"compress/gzip"
"fmt"
"io/ioutil"
"io"
"os"
"reflect"
"runtime"
Expand Down Expand Up @@ -51,7 +51,7 @@ func codeInit() {
if err != nil {
panic(err)
}
data, err := ioutil.ReadAll(gz)
data, err := io.ReadAll(gz)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -88,7 +88,7 @@ func BenchmarkCodeEncoder(b *testing.B) {
b.StartTimer()
}
b.RunParallel(func(pb *testing.PB) {
enc := NewEncoder(ioutil.Discard)
enc := NewEncoder(io.Discard)
for pb.Next() {
if err := enc.Encode(&codeStruct); err != nil {
b.Fatal("Encode:", err)
Expand Down
3 changes: 1 addition & 2 deletions proto/fixtures/generate/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"io/ioutil"
"os"

"github.com/golang/protobuf/proto"
Expand All @@ -28,6 +27,6 @@ func main() {

for _, test := range tests {
b, _ := proto.Marshal(&test.value)
ioutil.WriteFile("protobuf/"+test.name, b, 0644)
os.WriteFile("protobuf/"+test.name, b, 0644)
}
}
4 changes: 2 additions & 2 deletions proto/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package proto
import (
"encoding/binary"
"fmt"
"io/ioutil"
"math"
"os"
"reflect"
"testing"
)
Expand Down Expand Up @@ -366,7 +366,7 @@ func TestMarshalUnmarshal(t *testing.T) {
}

func loadProtobuf(t *testing.T, fileName string) RawMessage {
b, err := ioutil.ReadFile("fixtures/protobuf/" + fileName)
b, err := os.ReadFile("fixtures/protobuf/" + fileName)
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions thrift/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"reflect"
"sync/atomic"
)
Expand Down Expand Up @@ -656,7 +655,7 @@ func skipBinary(r Reader) error {
case *bufio.Reader:
_, err = x.Discard(int(n))
default:
_, err = io.CopyN(ioutil.Discard, x, int64(n))
_, err = io.CopyN(io.Discard, x, int64(n))
}
return dontExpectEOF(err)
}
Expand Down

0 comments on commit c9c213a

Please sign in to comment.