name: CI on: push: branches: - main tags: - "*" pull_request: workflow_dispatch: permissions: contents: read jobs: build: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: mode: - cgo - wasm2go - wazero os: - macos-15 - ubuntu-24.04 - windows-2025 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: curioswitch/go-build/.github/actions/setup-go@338fc9f50df6cb664134b5c600630dcbc483d81f # v0.7.3 - name: setup re2 for cgo (linux) if: ${{ startsWith(matrix.os, 'ubuntu-') && matrix.mode == 'cgo' }} run: sudo apt-get update && sudo apt-get install -y libre2-dev - name: setup re2 for cgo (mac) if: ${{ startsWith(matrix.os, 'macos-') && matrix.mode == 'cgo' }} run: brew install re2 - name: setup msys2 for cgo (windows) if: ${{ startsWith(matrix.os, 'windows-') && matrix.mode == 'cgo' }} uses: msys2/setup-msys2@e9898307ac31d1a803454791be09ab9973336e1c # v2.31.1 with: update: true # This version of go is not sync with setup-go, but this is probably the best we can do pacboy: gcc:p re2:p go:p pkg-config:p diffutils:p - name: run checks run: go run ./build ${{ startsWith(matrix.os, 'ubuntu-') && 'check' || 'test' }} if: ${{ !startsWith(matrix.os, 'windows-') || matrix.mode != 'cgo' }} env: RE2_TEST_MODE: ${{ matrix.mode }} # General coverage should be good enough to not need to slow down development # on these slow tests. RE2_TEST_EXHAUSTIVE: ${{ github.event_name != 'pull_request' && '1' || '0'}} # Windows runner seems to not have enough CPU performance to keep up without a memory limit GOMEMLIMIT: ${{ github.event_name != 'pull_request' && '1GiB' || '' }} # Race detector currently fails with Windows TEST_NORACE: ${{ startsWith(matrix.os, 'windows-') && (matrix.mode == 'wazero' || matrix.mode == 'wasm2go') && 'true' || '' }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: run tests (windows cgo) run: go run ./build test if: ${{ startsWith(matrix.os, 'windows-') && matrix.mode == 'cgo' }} # Shell does not support conditional expressions using matrix, so for now we duplicate the steps shell: "msys2 {0}" env: RE2_TEST_MODE: ${{ matrix.mode }} # General coverage should be good enough to not need to slow down development # on these slow tests. RE2_TEST_EXHAUSTIVE: ${{ github.event_name != 'pull_request' && '1' || '0'}} # Windows runner seems to not have enough CPU performance to keep up without a memory limit GOMEMLIMIT: ${{ github.event_name != 'pull_request' && '1GiB' || '' }} test-bsd: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: curioswitch/go-build/.github/actions/setup-go@338fc9f50df6cb664134b5c600630dcbc483d81f # v0.7.3 - name: Build run: go test -c . env: GOOS: freebsd - name: Test uses: cross-platform-actions/action@0c165ad7eb2d6a7e8552d6af5aad2bbedfc646b0 # v1.1.0 with: operating_system: freebsd version: "14.0" shell: bash run: ./go-re2.test -test.v -test.short sync_files: runner-to-vm # Runs tests using wazero inside a minimal golang docker image. This makes sure the code builds # even when there is no C toolchain available. It is possible for code to work fine with CGO_ENABLED=0 # but not build without a C toolchain available, e.g. if C source files are checked into the repo # without a build tag to exclude them from pure-Go builds. docker-build: runs-on: ubuntu-24.04 container: image: golang:alpine steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - run: if command -v gcc &> /dev/null; then echo "GCC found but not expected"; exit 2; fi - run: go run ./build test env: TEST_NORACE: "true"