From f17ac90a0b660384fc1144ff8b55357760457dc4 Mon Sep 17 00:00:00 2001 From: liuqiang Date: Thu, 13 Feb 2025 12:10:16 +0800 Subject: [PATCH] chore: fix ci --- .github/workflows/codeql-analysis.yml | 86 +++++++++++++++++++ .github/workflows/fuzzing-linux-x64.yml | 33 ------- ...{fuzzing-linux-opt-X64.yml => fuzzing.yml} | 4 +- .github/workflows/generic_test-opt.yml | 27 ------ .github/workflows/generic_test.yml | 27 ------ .github/workflows/license-check.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 72 ++++++++++++++++ .github/workflows/unit_test-linux-arm.yml | 42 --------- .github/workflows/unit_test-linux-opt-x64.yml | 46 ---------- .github/workflows/unit_test-linux-x64.yml | 58 ------------- ast/node.go | 4 +- internal/decoder/optdec/node.go | 2 +- 13 files changed, 165 insertions(+), 240 deletions(-) create mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 .github/workflows/fuzzing-linux-x64.yml rename .github/workflows/{fuzzing-linux-opt-X64.yml => fuzzing.yml} (88%) delete mode 100644 .github/workflows/generic_test-opt.yml delete mode 100644 .github/workflows/generic_test.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/unit_test-linux-arm.yml delete mode 100644 .github/workflows/unit_test-linux-opt-x64.yml delete mode 100644 .github/workflows/unit_test-linux-x64.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..db79009d7 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,86 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '35 21 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: [self-hosted, X64] + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Clear repository + run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # πŸ“š https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/fuzzing-linux-x64.yml b/.github/workflows/fuzzing-linux-x64.yml deleted file mode 100644 index 14d89ccbd..000000000 --- a/.github/workflows/fuzzing-linux-x64.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Fuzz Test Linux-X64 - -on: pull_request - -jobs: - build: - strategy: - matrix: - os: [macos-latest, X64] - runs-on: ${{ matrix.os }} - steps: - - name: Clear repository - run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE - - - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.20.x - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Fuzz sonic - run: | - cd ./fuzz - make fuzz - make run \ No newline at end of file diff --git a/.github/workflows/fuzzing-linux-opt-X64.yml b/.github/workflows/fuzzing.yml similarity index 88% rename from .github/workflows/fuzzing-linux-opt-X64.yml rename to .github/workflows/fuzzing.yml index fc653c780..a3c2125c8 100644 --- a/.github/workflows/fuzzing-linux-opt-X64.yml +++ b/.github/workflows/fuzzing.yml @@ -6,7 +6,7 @@ jobs: build: strategy: matrix: - os: [macos-latest, X64] + os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest] runs-on: ${{ matrix.os }} steps: - name: Clear repository @@ -30,4 +30,4 @@ jobs: run: | cd ./fuzz make fuzz - make runopt \ No newline at end of file + make runopt diff --git a/.github/workflows/generic_test-opt.yml b/.github/workflows/generic_test-opt.yml deleted file mode 100644 index 11262d261..000000000 --- a/.github/workflows/generic_test-opt.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Generic Test Go1.18-Linux-X64 - -on: pull_request - -jobs: - build: - runs-on: [self-hosted, X64] - steps: - - name: Clear repository - run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE - - - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.18 - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Generic Test - run: GOMAXPROCS=4 SONIC_USE_OPTDEC=1 SONIC_USE_FASTMAP=1 SONIC_ENCODER_USE_VM=1 go test -v -race ./generic_test \ No newline at end of file diff --git a/.github/workflows/generic_test.yml b/.github/workflows/generic_test.yml deleted file mode 100644 index 3ebe1a8dc..000000000 --- a/.github/workflows/generic_test.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Generic Test Go1.18-Linux-X64 - -on: pull_request - -jobs: - build: - runs-on: [self-hosted, X64] - steps: - - name: Clear repository - run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE - - - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.18 - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Generic Test - run: GOMAXPROCS=4 go test -v -race ./generic_test \ No newline at end of file diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml index a2142dc1a..b44751c8c 100644 --- a/.github/workflows/license-check.yml +++ b/.github/workflows/license-check.yml @@ -4,7 +4,7 @@ on: pull_request jobs: build: - runs-on: [self-hosted, X64] + runs-on: ubuntu-latest steps: - name: Clear repository run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e8ae2b90a..8abf64740 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,4 +10,4 @@ jobs: - name: spell check uses: codespell-project/actions-codespell@v2 with: - skip: loader/internal/iasm/obj/macho.go,loader/internal/iasm/obj/macho.go,loader/internal/iasm/obj/macho.go,loader/internal/iasm/obj/macho.go,loader/internal/iasm/x86_64/encodings.go:720,loader/internal/iasm/x86_64/program.go,loader/internal/iasm/x86_64/program.go,loader/internal/iasm/x86_64/program.go,loader/internal/iasm/expr/ast.go,loader/internal/iasm/expr/errors.go + skip: ./loader/internal/iasm/obj/macho.go,./loader/internal/iasm/x86_64/encodings.go,./loader/internal/iasm/x86_64/program.go,./loader/internal/iasm/expr/ast.go,./loader/internal/iasm/expr/errors.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..55d65441b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,72 @@ + +name: Unit Test + +on: pull_request + +jobs: + build: + strategy: + max-parallel: 4 + matrix: + go-version: [1.20.x, 1.21.x, 1.22.x, 1.23.x] + runner_arch: [ubuntu-latest, ubuntu-24.04-arm, macos-latest] + include: + # ζŽ’ι™€ ARM ζžΆζž„δΈŠηš„ζ—§η‰ˆζœ¬ + - runner_arch: ubuntu-latest + go-version: 1.17.x + - runner_arch: ubuntu-latest + go-version: 1.18.x + - runner_arch: ubuntu-latest + go-version: 1.19.x + + runs-on: ${{ matrix.runner_arch }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + cache: true + + - name: Cache Go modules + uses: actions/cache@v3 + with: + path: | + ~/go/pkg/mod + ${{ github.workspace }}/go.sum + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + + - name: Unit Test JIT + run: | + GOMAXPROCS=4 go test -race -covermode=atomic -coverprofile=coverage.txt ./... + + - name: Unit Test VM + run: | + SONIC_USE_OPTDEC=1 SONIC_USE_FASTMAP=1 SONIC_ENCODER_USE_VM=1 GOMAXPROCS=4 go test -race -covermode=atomic -coverprofile=coverage.txt ./... + + - name: Loader Test + run: | + cd ./loader + go test -v -race ./... + + - name: Data Race + run: | + ./scripts/test_race.sh + + - name: PCSP Test + env: + GOVERSION: ${{ matrix.go-version }} + run: python3 ./scripts/test_pcsp.py + + - name: Generic Test JIT + if: ${{ !startsWith(matrix.go-version, '1.17.') }} + run: GOMAXPROCS=4 go test -v -race ./generic_test + + - name: Generic Test VM + if: ${{ !startsWith(matrix.go-version, '1.17.') }} + run: GOMAXPROCS=4 SONIC_USE_OPTDEC=1 SONIC_USE_FASTMAP=1 SONIC_ENCODER_USE_VM=1 go test -v -race ./generic_test + + - name: Codecov + run: bash <(curl -s https://codecov.io/bash) diff --git a/.github/workflows/unit_test-linux-arm.yml b/.github/workflows/unit_test-linux-arm.yml deleted file mode 100644 index c2a02a1b6..000000000 --- a/.github/workflows/unit_test-linux-arm.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Unit Test Linux macos-latest - -on: push - -jobs: - build: - strategy: - matrix: - # TODO: 1.17.x, 1.18.x, 1.19.x not supported because golang asm bug - go-version: [1.20.x, 1.21.x, 1.22.x, 1.23.x] - runs-on: [macos-latest] - steps: - - name: Clear repository - run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE - - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Unit Test - run: | - go test -race -covermode=atomic -coverprofile=coverage.txt $(go list ./... | grep -v -E 'loader|jit|avx|x86|sse') - - - name: external - run: | - cd ./external_jsonlib_test - GOMAXPROCS=4 go test -v -race ./... - - - name: Codecov - run: bash <(curl -s https://codecov.io/bash) diff --git a/.github/workflows/unit_test-linux-opt-x64.yml b/.github/workflows/unit_test-linux-opt-x64.yml deleted file mode 100644 index 3ebfcd3e3..000000000 --- a/.github/workflows/unit_test-linux-opt-x64.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Unit Test Linux X64 - -on: push - -jobs: - build: - strategy: - matrix: - go-version: [1.17.x, 1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x] - runs-on: [self-hosted, X64] - steps: - - name: Clear repository - run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE - - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Unit Test - run: | - GOMAXPROCS=4 SONIC_USE_OPTDEC=1 SONIC_USE_FASTMAP=1 SONIC_ENCODER_USE_VM=1 go test -race -covermode=atomic -coverprofile=coverage.txt ./... - - - name: external - run: | - cd ./external_jsonlib_test - SONIC_USE_OPTDEC=1 SONIC_USE_FASTMAP=1 SONIC_ENCODER_USE_VM=1 go test -v -race ./... - - - name: external - run: | - cd ./loader - SONIC_USE_OPTDEC=1 SONIC_USE_FASTMAP=1 SONIC_ENCODER_USE_VM=1 go test -v -race ./... - - - name: Codecov - run: bash <(curl -s https://codecov.io/bash) diff --git a/.github/workflows/unit_test-linux-x64.yml b/.github/workflows/unit_test-linux-x64.yml deleted file mode 100644 index b3ddd1174..000000000 --- a/.github/workflows/unit_test-linux-x64.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Unit Test Linux X64 - -on: push - -jobs: - build: - strategy: - max-parallel: 4 - matrix: - go-version: [1.17.x, 1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x] - runs-on: [self-hosted, X64] - steps: - - name: Clear repository - run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE - - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Data Race - run: | - ./scripts/test_race.sh - - - name: PCSP Test - env: - GOVERSION: ${{ matrix.go-version }} - run: python3 ./scripts/test_pcsp.py - - - - - name: Unit Test - run: | - GOMAXPROCS=4 go test -race -covermode=atomic -coverprofile=coverage.txt ./... - - - name: external - run: | - cd ./external_jsonlib_test - go test -v -race ./... - - - name: external - run: | - cd ./loader - go test -v -race ./... - - - name: Codecov - run: bash <(curl -s https://codecov.io/bash) diff --git a/ast/node.go b/ast/node.go index 2bb504850..3b1aee47c 100644 --- a/ast/node.go +++ b/ast/node.go @@ -71,7 +71,7 @@ func (self *Node) UnmarshalJSON(data []byte) (err error) { /** Node Type Accessor **/ // Type returns json type represented by the node -// It will be one of belows: +// It will be one of bellows: // V_NONE = 0 (empty node, key not exists) // V_ERROR = 1 (error node) // V_NULL = 2 (json value `null`, key exists) @@ -89,7 +89,7 @@ func (self Node) Type() int { } // Type concurrently-safe returns json type represented by the node -// It will be one of belows: +// It will be one of bellows: // V_NONE = 0 (empty node, key not exists) // V_ERROR = 1 (error node) // V_NULL = 2 (json value `null`, key exists) diff --git a/internal/decoder/optdec/node.go b/internal/decoder/optdec/node.go index b23901e38..c44b97d5c 100644 --- a/internal/decoder/optdec/node.go +++ b/internal/decoder/optdec/node.go @@ -551,7 +551,7 @@ func (val Node) AsRaw(ctx *Context) string { node := ptrCast(val.cptr) len := int(node.val) offset := val.Position() - // add start abd end quote + // add start and end quote ref := rt.Str2Mem(ctx.Parser.Json)[offset-1 : offset+len+1] return rt.Mem2Str(ref) case KRawNumber: fallthrough