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