From 135fab6a1caec2d25e0e65175a336325bd1d4182 Mon Sep 17 00:00:00 2001 From: Alexey Sharov Date: Thu, 13 Aug 2026 10:35:01 +0700 Subject: [PATCH] ci: add golangci-lint, cross-platform build, and actionlint The repo had no CI. Both Go files are cgo wrappers over the vendored evmone/intx C++ sources, so the checks build with CGO_ENABLED=1 and a current toolchain -- go.mod declares go 1.17 only as the module minimum, which is too old to run golangci-lint v2. - lint: golangci-lint v2.12.2 (standard set + misspell, unconvert, usestdlibvars, and govet's unsafeptr, since the package is entirely unsafe.Pointer conversions into C++). gofmt/goimports run as v2 formatters, so `run` fails on unformatted files too. - build: go build/vet/test on ubuntu-latest and macos-latest. cgo with -std=c++20 resolves differently under gcc and clang, so both matter. - actionlint: lints these workflows. Verified locally on macOS: golangci-lint reports 0 issues, and actionlint accepts the workflow. The Linux leg runs here for the first time. --- .github/workflows/ci.yml | 87 ++++++++++++++++++++++++++++++++++++++++ .golangci.yml | 22 ++++++++++ 2 files changed, 109 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .golangci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b92d0e5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,87 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +defaults: + run: + shell: bash + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +env: + # Both Go files are cgo wrappers over the vendored evmone/intx C++ sources. + CGO_ENABLED: "1" + # go.mod declares go 1.17 as the module minimum; build with a current toolchain. + GO_VERSION: "1.25" + +jobs: + lint: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - uses: actions/setup-go@v7 + with: + go-version: ${{ env.GO_VERSION }} + # The module has no dependencies and no go.sum, so there is nothing + # for the dependency cache to key on. + cache: false + + - uses: golangci/golangci-lint-action@v9 + with: + version: v2.12.2 + + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 20 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - uses: actions/setup-go@v7 + with: + go-version: ${{ env.GO_VERSION }} + cache: false + + - name: Compiler versions + run: | + go version + ${CXX:-c++} --version + + - run: go build ./... + + - run: go vet ./... + + - run: go test ./... + + actionlint: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: actionlint + run: | + curl -sSfL \ + "https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz" \ + | tar -xz -C /usr/local/bin actionlint + actionlint diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..1a346fa --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,22 @@ +version: "2" + +run: + # Every package here is cgo; without this the linter sees no Go code at all. + build-tags: [] + +linters: + default: standard + enable: + - misspell + - unconvert + - usestdlibvars + settings: + govet: + enable: + # The whole package is unsafe.Pointer conversions into C++. + - unsafeptr + +formatters: + enable: + - gofmt + - goimports