From 52ae64103bf1ecf18d4f8ad2fa977523deef6e45 Mon Sep 17 00:00:00 2001 From: bulletmys Date: Sun, 10 Oct 2021 19:42:20 +0300 Subject: [PATCH 1/8] fix allocs expectations in tests --- tests/intern_test.go | 8 ++++---- tests/nocopy_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/intern_test.go b/tests/intern_test.go index 480f87c..4c73002 100644 --- a/tests/intern_test.go +++ b/tests/intern_test.go @@ -20,8 +20,8 @@ func TestStringIntern(t *testing.T) { t.Fatalf("wrong value: %q", i.Field) } }) - if allocsPerRun != 1 { - t.Fatalf("expected 1 allocs, got %f", allocsPerRun) + if allocsPerRun > 1 { + t.Fatalf("expected <= 1 allocs, got %f", allocsPerRun) } var n NoIntern @@ -35,7 +35,7 @@ func TestStringIntern(t *testing.T) { t.Fatalf("wrong value: %q", n.Field) } }) - if allocsPerRun != 2 { - t.Fatalf("expected 2 allocs, got %f", allocsPerRun) + if allocsPerRun > 2 { + t.Fatalf("expected <= 2 allocs, got %f", allocsPerRun) } } diff --git a/tests/nocopy_test.go b/tests/nocopy_test.go index 05dccee..63dfc5f 100644 --- a/tests/nocopy_test.go +++ b/tests/nocopy_test.go @@ -53,8 +53,8 @@ func TestNocopy(t *testing.T) { t.Fatalf("wrong value: %q", res.B) } }) - if allocsPerRun != 1 { - t.Fatalf("noCopy field unmarshal: expected 1 allocs, got %f", allocsPerRun) + if allocsPerRun > 1 { + t.Fatalf("noCopy field unmarshal: expected <= 1 allocs, got %f", allocsPerRun) } data = []byte(`{"a": "valueNoCopy"}`) @@ -67,7 +67,7 @@ func TestNocopy(t *testing.T) { t.Fatalf("wrong value: %q", res.A) } }) - if allocsPerRun != 2 { - t.Fatalf("copy field unmarshal: expected 2 allocs, got %f", allocsPerRun) + if allocsPerRun > 2 { + t.Fatalf("copy field unmarshal: expected <= 2 allocs, got %f", allocsPerRun) } } From 4f5f962fb8a7322b7b9d1e0a36ea48001d51a786 Mon Sep 17 00:00:00 2001 From: bulletmys Date: Sun, 10 Oct 2021 20:12:06 +0300 Subject: [PATCH 2/8] add github actions --- .github/workflows/go.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..c9f9231 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,28 @@ +name: Go + +on: + push: + branches: [ master, upd_ci ] + pull_request: + branches: [ master ] + +jobs: + + build: + runs-on: ubuntu-latest + strategy: + matrix: + go: [ '1.17', '1.16', '1.15' ] + steps: + - uses: actions/checkout@v2 + + - name: Set up Go ${{ matrix.go }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + + - name: Install golint + run: go get golang.org/x/lint/golint + + - name: Build and Run tests + run: make From 7c1e3c1c97a094770cf2f327cdd2f2043d667e79 Mon Sep 17 00:00:00 2001 From: bulletmys Date: Sun, 10 Oct 2021 20:22:25 +0300 Subject: [PATCH 3/8] upd github actions --- .github/workflows/go.yml | 3 ++- Makefile | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c9f9231..58e2dc9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,6 +11,7 @@ jobs: build: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: go: [ '1.17', '1.16', '1.15' ] steps: @@ -22,7 +23,7 @@ jobs: go-version: ${{ matrix.go }} - name: Install golint - run: go get golang.org/x/lint/golint + run: go install golang.org/x/lint/golint - name: Build and Run tests run: make diff --git a/Makefile b/Makefile index c527340..cc5ebba 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ clean: rm -rf benchmark/*_easyjson.go build: - go build -i -o ./bin/easyjson ./easyjson + go build -o ./bin/easyjson ./easyjson generate: build bin/easyjson -stubs \ From 3c100a79a35233cf8e3c7327814ee00a8248b159 Mon Sep 17 00:00:00 2001 From: bulletmys Date: Sun, 10 Oct 2021 20:24:20 +0300 Subject: [PATCH 4/8] upd github actions --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 58e2dc9..655602b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -23,7 +23,7 @@ jobs: go-version: ${{ matrix.go }} - name: Install golint - run: go install golang.org/x/lint/golint + run: go get golang.org/x/lint/golint && go install golang.org/x/lint/golint - name: Build and Run tests run: make From 5fd7585ed45596e1962ef83219f180b3a8acac1c Mon Sep 17 00:00:00 2001 From: bulletmys Date: Sun, 10 Oct 2021 20:46:21 +0300 Subject: [PATCH 5/8] upd github actions --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 655602b..4704a20 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -23,7 +23,7 @@ jobs: go-version: ${{ matrix.go }} - name: Install golint - run: go get golang.org/x/lint/golint && go install golang.org/x/lint/golint + run: go get golang.org/x/lint/golint && go mod tidy - name: Build and Run tests run: make From 309f1b66b9142a4823158f7185fc62eecc704e75 Mon Sep 17 00:00:00 2001 From: bulletmys Date: Sun, 10 Oct 2021 21:05:35 +0300 Subject: [PATCH 6/8] add non amd64 actions --- .github/workflows/easyjson.yml | 59 ++++++++++++++++++++++++++++++++++ .github/workflows/go.yml | 29 ----------------- 2 files changed, 59 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/easyjson.yml delete mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/easyjson.yml b/.github/workflows/easyjson.yml new file mode 100644 index 0000000..b032980 --- /dev/null +++ b/.github/workflows/easyjson.yml @@ -0,0 +1,59 @@ +name: easyjson + +on: + push: + branches: [ master, upd_ci ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + go: [ '1.17', '1.16', '1.15' ] + steps: + - uses: actions/checkout@v2 + + - name: Set up Go ${{ matrix.go }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + + - name: Install golint + run: go get golang.org/x/lint/golint && go mod tidy + + - name: Build and Run tests + run: make + + test-non-amd64: + strategy: + matrix: + arch: + - name: POWER8 + architecture: "ppc64le" + runs-on: ubuntu-latest + name: Build on ${{ matrix.arch.name }} + steps: + - uses: actions/checkout@v2 + - uses: uraimo/run-on-arch-action@master + env: + GOARCH: ${{ matrix.arch.architecture }} + with: + architecture: ${{ matrix.arch.architecture }} + distribution: ubuntu20.04 + additionalArgs: -e GOARCH + install: | + apt-get update + apt install -y curl wget + latestGo=$(curl "https://golang.org/VERSION?m=text") + wget "https://dl.google.com/go/${latestGo}.linux-${GOARCH}.tar.gz" + rm -f $(which go) + rm -rf /usr/local/go + tar -C /usr/local -xzf "${latestGo}.linux-${GOARCH}.tar.gz" + export PATH=/usr/local/go/bin:$PATH + printf "Go Version: $(go version)\n" + run: | + go get golang.org/x/lint/golint && go mod tidy + make \ No newline at end of file diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index 4704a20..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Go - -on: - push: - branches: [ master, upd_ci ] - pull_request: - branches: [ master ] - -jobs: - - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - go: [ '1.17', '1.16', '1.15' ] - steps: - - uses: actions/checkout@v2 - - - name: Set up Go ${{ matrix.go }} - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go }} - - - name: Install golint - run: go get golang.org/x/lint/golint && go mod tidy - - - name: Build and Run tests - run: make From 738f356010a1a4e818935856ab796dc0868d036f Mon Sep 17 00:00:00 2001 From: bulletmys Date: Sun, 10 Oct 2021 21:15:09 +0300 Subject: [PATCH 7/8] fix run-on-arch-action actions --- .github/workflows/easyjson.yml | 39 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/easyjson.yml b/.github/workflows/easyjson.yml index b032980..0679163 100644 --- a/.github/workflows/easyjson.yml +++ b/.github/workflows/easyjson.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - go: [ '1.17', '1.16', '1.15' ] + go: [ 1.17, 1.16, 1.15 ] steps: - uses: actions/checkout@v2 @@ -21,39 +21,42 @@ jobs: with: go-version: ${{ matrix.go }} - - name: Install golint + - name: Install golint (for old go version) + if: matrix.go < 1.16 run: go get golang.org/x/lint/golint && go mod tidy + - name: Install golint + if: matrix.go > 1.15 + run: go install golang.org/x/lint/golint@latest + - name: Build and Run tests run: make test-non-amd64: + runs-on: ubuntu-latest + name: Build on ${{ matrix.distro }} ${{ matrix.arch }} strategy: matrix: - arch: - - name: POWER8 - architecture: "ppc64le" - runs-on: ubuntu-latest - name: Build on ${{ matrix.arch.name }} + include: + - arch: ppc64le + distro: ubuntu20.04 steps: - uses: actions/checkout@v2 - uses: uraimo/run-on-arch-action@master - env: - GOARCH: ${{ matrix.arch.architecture }} with: - architecture: ${{ matrix.arch.architecture }} - distribution: ubuntu20.04 - additionalArgs: -e GOARCH + arch: ${{ matrix.arch }} + distro: ${{ matrix.distro }} install: | apt-get update - apt install -y curl wget + apt install -y curl wget make gcc latestGo=$(curl "https://golang.org/VERSION?m=text") - wget "https://dl.google.com/go/${latestGo}.linux-${GOARCH}.tar.gz" + wget --quiet "https://dl.google.com/go/${latestGo}.linux-${{ matrix.arch }}.tar.gz" rm -f $(which go) rm -rf /usr/local/go - tar -C /usr/local -xzf "${latestGo}.linux-${GOARCH}.tar.gz" - export PATH=/usr/local/go/bin:$PATH - printf "Go Version: $(go version)\n" + tar -C /usr/local -xzf "${latestGo}.linux-${{ matrix.arch }}.tar.gz" run: | - go get golang.org/x/lint/golint && go mod tidy + export PATH=/usr/local/go/bin:$PATH + export PATH=~/go/bin:$PATH + printf "Go Version: $(go version)\n" + go install golang.org/x/lint/golint@latest make \ No newline at end of file From 42b87bff63480a7126797bcfde59240ec6d70284 Mon Sep 17 00:00:00 2001 From: bulletmys Date: Sun, 10 Oct 2021 23:14:44 +0300 Subject: [PATCH 8/8] upd readme and delete .travis.yml --- .github/workflows/easyjson.yml | 5 +++-- .travis.yml | 15 --------------- README.md | 2 +- 3 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/easyjson.yml b/.github/workflows/easyjson.yml index 0679163..5f0b6e1 100644 --- a/.github/workflows/easyjson.yml +++ b/.github/workflows/easyjson.yml @@ -2,13 +2,14 @@ name: easyjson on: push: - branches: [ master, upd_ci ] + branches: [ master ] pull_request: branches: [ master ] jobs: test: runs-on: ubuntu-latest + name: Test with Go ${{ matrix.go }} strategy: fail-fast: false matrix: @@ -34,7 +35,7 @@ jobs: test-non-amd64: runs-on: ubuntu-latest - name: Build on ${{ matrix.distro }} ${{ matrix.arch }} + name: Test on ${{ matrix.distro }} ${{ matrix.arch }} strategy: matrix: include: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1e0fa4c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -arch: - - amd64 - - ppc64le -language: go - -go: - - tip - - stable - -matrix: - allow_failures: - - go: tip - -install: - - go get golang.org/x/lint/golint diff --git a/README.md b/README.md index 37345e8..5ae07a9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# easyjson [![Build Status](https://travis-ci.org/mailru/easyjson.svg?branch=master)](https://travis-ci.org/mailru/easyjson) [![Go Report Card](https://goreportcard.com/badge/github.com/mailru/easyjson)](https://goreportcard.com/report/github.com/mailru/easyjson) +# easyjson [![Build Status](https://github.com/mailru/easyjson/actions/workflows/easyjson.yml/badge.svg)](https://travis-ci.org/mailru/easyjson) [![Go Report Card](https://goreportcard.com/badge/github.com/mailru/easyjson)](https://goreportcard.com/report/github.com/mailru/easyjson) Package easyjson provides a fast and easy way to marshal/unmarshal Go structs to/from JSON without the use of reflection. In performance tests, easyjson