diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..3833fc22 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,11 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + +name: Automerge +on: [ pull_request ] + +jobs: + automerge: + uses: protocol/.github/.github/workflows/automerge.yml@master + with: + job: 'automerge' diff --git a/.github/workflows/go-check.yml b/.github/workflows/go-check.yml index 6972415d..80d04905 100644 --- a/.github/workflows/go-check.yml +++ b/.github/workflows/go-check.yml @@ -1,3 +1,6 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + name: Go Checks on: @@ -14,5 +17,62 @@ concurrency: cancel-in-progress: true jobs: - go-check: - uses: ipdxco/unified-github-workflows/.github/workflows/go-check.yml@v1.0.22 + unit: + runs-on: ubuntu-latest + name: All + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - id: config + uses: protocol/.github/.github/actions/read-config@master + - uses: actions/setup-go@v3 + with: + go-version: 1.20.x + - name: Run repo-specific setup + uses: ./.github/actions/go-check-setup + if: hashFiles('./.github/actions/go-check-setup') != '' + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@4970552d932f48b71485287748246cf3237cebdf # 2023.1 (v0.4.0) + - name: Check that go.mod is tidy + uses: protocol/multiple-go-modules@v1.2 + with: + run: | + go mod tidy + if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then + echo "go.sum was added by go mod tidy" + exit 1 + fi + git diff --exit-code -- go.sum go.mod + - name: gofmt + if: success() || failure() # run this step even if the previous one failed + run: | + out=$(gofmt -s -l .) + if [[ -n "$out" ]]; then + echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}' + exit 1 + fi + - name: go vet + if: success() || failure() + uses: protocol/multiple-go-modules@v1.2 + with: + run: go vet ./... + - name: staticcheck + if: success() || failure() + uses: protocol/multiple-go-modules@v1.2 + with: + run: | + set -o pipefail + staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g' + - name: go generate + uses: protocol/multiple-go-modules@v1.2 + if: (success() || failure()) && fromJSON(steps.config.outputs.json).gogenerate == true + with: + run: | + git clean -fd + go generate -x ./... + if ! $(git add . && git diff-index HEAD --exit-code --quiet); then + echo "go generate caused changes to the repository:" + git status --short + exit 1 + fi diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index cb43a3ae..aefabf36 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -1,3 +1,6 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + name: Go Test on: @@ -14,5 +17,63 @@ concurrency: cancel-in-progress: true jobs: - go-test: - uses: ipdxco/unified-github-workflows/.github/workflows/go-test.yml@v1.0 + unit: + strategy: + fail-fast: false + matrix: + os: [ "ubuntu", "windows", "macos" ] + go: ["1.19.x", "1.20.x"] + env: + COVERAGES: "" + runs-on: ${{ fromJSON(vars[format('UCI_GO_TEST_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }} + name: ${{ matrix.os }} (go ${{ matrix.go }}) + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - id: config + uses: protocol/.github/.github/actions/read-config@master + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - name: Go information + run: | + go version + go env + - name: Use msys2 on windows + if: matrix.os == 'windows' + shell: bash + run: echo "C:/msys64/usr/bin" >> $GITHUB_PATH + - name: Run repo-specific setup + uses: ./.github/actions/go-test-setup + if: hashFiles('./.github/actions/go-test-setup') != '' + - name: Run tests + if: contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false + uses: protocol/multiple-go-modules@v1.2 + with: + run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./... + - name: Run tests (32 bit) + if: matrix.os != 'macos' && + fromJSON(steps.config.outputs.json).skip32bit != true && + contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false + uses: protocol/multiple-go-modules@v1.2 + env: + GOARCH: 386 + with: + run: | + export "PATH=$PATH_386:$PATH" + go test -v -shuffle=on ./... + - name: Run tests with race detector + if: matrix.os == 'ubuntu' && + contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false + uses: protocol/multiple-go-modules@v1.2 + with: + run: go test -v -race ./... + - name: Collect coverage files + shell: bash + run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV + - name: Upload coverage to Codecov + uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + files: '${{ env.COVERAGES }}' + env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }} diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml index 0dada63e..ca1cb7cc 100644 --- a/.github/workflows/release-check.yml +++ b/.github/workflows/release-check.yml @@ -1,3 +1,6 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + name: Release Checker on: @@ -16,4 +19,6 @@ concurrency: jobs: release-check: - uses: ipdxco/unified-github-workflows/.github/workflows/release-check.yml@v0.0 + uses: protocol/.github/.github/workflows/release-check.yml@master + with: + go-version: 1.20.x diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml index 2ebdbed3..cd0c06ef 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -1,3 +1,6 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + name: Releaser on: @@ -14,4 +17,4 @@ concurrency: jobs: releaser: - uses: ipdxco/unified-github-workflows/.github/workflows/releaser.yml@v1.0 + uses: protocol/.github/.github/workflows/releaser.yml@master diff --git a/.github/workflows/tagpush.yml b/.github/workflows/tagpush.yml index 72efb2d4..64b9c2b0 100644 --- a/.github/workflows/tagpush.yml +++ b/.github/workflows/tagpush.yml @@ -1,3 +1,6 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + name: Tag Push Checker on: @@ -15,4 +18,4 @@ concurrency: jobs: releaser: - uses: ipdxco/unified-github-workflows/.github/workflows/tagpush.yml@v0.0 + uses: protocol/.github/.github/workflows/tagpush.yml@master diff --git a/go.mod b/go.mod index 612b2d2d..ea0c1711 100644 --- a/go.mod +++ b/go.mod @@ -67,6 +67,7 @@ require ( github.com/rjNemo/underscore v0.5.0 github.com/robfig/cron/v3 v3.0.1 github.com/sashabaranov/go-openai v1.14.1 + github.com/shirou/gopsutil/v3 v3.23.3 // indirect github.com/stretchr/testify v1.10.0 github.com/swaggo/echo-swagger v1.4.0 github.com/swaggo/swag v1.16.1 @@ -309,7 +310,6 @@ require ( github.com/rfjakob/eme v1.1.2 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/shirou/gopsutil/v3 v3.23.3 // indirect github.com/shoenig/go-m1cpu v0.1.4 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect diff --git a/version.json b/version.json new file mode 100644 index 00000000..51b0d58d --- /dev/null +++ b/version.json @@ -0,0 +1,3 @@ +{ + "version": "v0.2.33" +}