Skip to content

Commit

Permalink
ci: fix not running ./tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaost committed Jul 29, 2024
1 parent 2659f3f commit 2890e1b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 40 deletions.
30 changes: 12 additions & 18 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [ pull_request ]

jobs:
compliant:
runs-on: [ self-hosted, X64 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

Expand All @@ -17,20 +17,13 @@ jobs:
uses: crate-ci/typos@master

staticcheck:
runs-on: [ self-hosted, X64 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.22"

- uses: actions/cache@v3
uses: actions/setup-go@v5
with:
path: ~/go/pkg/mod
key: reviewdog-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
reviewdog-${{ runner.os }}-go-
go-version: stable

- uses: reviewdog/action-staticcheck@v1
with:
Expand All @@ -39,23 +32,24 @@ jobs:
reporter: github-pr-review
# Report all results.
filter_mode: nofilter
# Exit with 1 when it find at least one finding.
# Exit with 1 when it finds at least one finding.
fail_on_error: true
# Set staticcheck flags
# -ST1006 for fixing jit code receiver names like `self`
staticcheck_flags: -checks=inherit,-SA1029, -ST1006

lint:
runs-on: [ self-hosted, X64 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: stable

- name: Golangci Lint
# https://golangci-lint.run/
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: latest
only-new-issues: true
38 changes: 29 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,42 @@ name: Tests
on: [ push, pull_request ]

jobs:
unit-benchmark-test:
compatibility-test-amd64:
strategy:
matrix:
go: [ "1.17", "1.18", "1.19", "1.20", "1.21", "1.22" ]
os: [ X64 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false # don't use cache for self-hosted runners
- name: Test ./...
run: go test -race ./...
- name: Test ./tests
run: cd tests && go test -race ./...
- name: Test Benchmark
run: go test -bench=. -benchmem -run=none ./... -benchtime=100ms

- name: Unit Test
run: go test -race -covermode=atomic -coverprofile=coverage.out ./...

- name: Benchmark
run: go test -bench=. -benchmem -run=none ./...
compatibility-test-arm64:
strategy:
matrix:
go: [ "1.17", "1.18", "1.19", "1.20", "1.21", "1.22" ]
os: [ ARM64 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false # don't use cache for self-hosted runners
- name: Test ./...
run: go test -race ./internal/reflect
- name: Test ./tests
run: cd tests && go test -race
- name: Test Benchmark
run: go test -bench=. -benchmem -run=none ./internal/reflect -benchtime=100ms
13 changes: 0 additions & 13 deletions tests/deep_nested_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package tests

import (
"runtime"
"testing"

"github.com/cloudwego/frugal"
Expand Down Expand Up @@ -95,19 +94,7 @@ var (
)

func TestDeepNested(t *testing.T) {
exit := make(chan int)
go func() {
for {
select {
case <-exit:
t.Logf("exit gc loop")
default:
runtime.GC()
}
}
}()
for i := 0; i < 100; i++ {
frugal.EncodedSize(deepNested)
}
exit <- 0
}
9 changes: 9 additions & 0 deletions tests/frugal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package tests

import (
"reflect"
"runtime"
"testing"

"github.com/davecgh/go-spew/spew"
Expand All @@ -30,6 +31,14 @@ import (
"github.com/cloudwego/frugal/tests/kitex_gen/baseline"
)

func init() {
go func() { // it checks unsafe pointer issues
for {
runtime.GC()
}
}()
}

type MyNode struct {
Name string `thrift:"Name,1" frugal:"1,default,string" json:"Name"`
ID int32 `thrift:"ID,2" frugal:"2,default,i32" json:"ID"`
Expand Down

0 comments on commit 2890e1b

Please sign in to comment.