Debian Codegraph @

.github/workflows/ci.yaml

raw symbols SCIP
1 name: CI
2 on:
3 push:
4 branches:
5 - main
6 tags:
7 - "*"
8 pull_request:
9 workflow_dispatch:
10
11 permissions:
12 contents: read
13
14 jobs:
15 build:
16 runs-on: ${{ matrix.os }}
17 strategy:
18 fail-fast: false
19 matrix:
20 mode:
21 - cgo
22 - wasm2go
23 - wazero
24 os:
25 - macos-15
26 - ubuntu-24.04
27 - windows-2025
28 steps:
29 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30 - uses: curioswitch/go-build/.github/actions/setup-go@338fc9f50df6cb664134b5c600630dcbc483d81f # v0.7.3
31
32 - name: setup re2 for cgo (linux)
33 if: ${{ startsWith(matrix.os, 'ubuntu-') && matrix.mode == 'cgo' }}
34 run: sudo apt-get update && sudo apt-get install -y libre2-dev
35 - name: setup re2 for cgo (mac)
36 if: ${{ startsWith(matrix.os, 'macos-') && matrix.mode == 'cgo' }}
37 run: brew install re2
38 - name: setup msys2 for cgo (windows)
39 if: ${{ startsWith(matrix.os, 'windows-') && matrix.mode == 'cgo' }}
40 uses: msys2/setup-msys2@e9898307ac31d1a803454791be09ab9973336e1c # v2.31.1
41 with:
42 update: true
43 # This version of go is not sync with setup-go, but this is probably the best we can do
44 pacboy: gcc:p re2:p go:p pkg-config:p diffutils:p
45
46 - name: run checks
47 run: go run ./build ${{ startsWith(matrix.os, 'ubuntu-') && 'check' || 'test' }}
48 if: ${{ !startsWith(matrix.os, 'windows-') || matrix.mode != 'cgo' }}
49 env:
50 RE2_TEST_MODE: ${{ matrix.mode }}
51 # General coverage should be good enough to not need to slow down development
52 # on these slow tests.
53 RE2_TEST_EXHAUSTIVE: ${{ github.event_name != 'pull_request' && '1' || '0'}}
54 # Windows runner seems to not have enough CPU performance to keep up without a memory limit
55 GOMEMLIMIT: ${{ github.event_name != 'pull_request' && '1GiB' || '' }}
56 # Race detector currently fails with Windows
57 TEST_NORACE: ${{ startsWith(matrix.os, 'windows-') && (matrix.mode == 'wazero' || matrix.mode == 'wasm2go') && 'true' || '' }}
58 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59
60 - name: run tests (windows cgo)
61 run: go run ./build test
62 if: ${{ startsWith(matrix.os, 'windows-') && matrix.mode == 'cgo' }}
63 # Shell does not support conditional expressions using matrix, so for now we duplicate the steps
64 shell: "msys2 {0}"
65 env:
66 RE2_TEST_MODE: ${{ matrix.mode }}
67 # General coverage should be good enough to not need to slow down development
68 # on these slow tests.
69 RE2_TEST_EXHAUSTIVE: ${{ github.event_name != 'pull_request' && '1' || '0'}}
70 # Windows runner seems to not have enough CPU performance to keep up without a memory limit
71 GOMEMLIMIT: ${{ github.event_name != 'pull_request' && '1GiB' || '' }}
72
73 test-bsd:
74 runs-on: ubuntu-24.04
75
76 steps:
77 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
78 - uses: curioswitch/go-build/.github/actions/setup-go@338fc9f50df6cb664134b5c600630dcbc483d81f # v0.7.3
79
80 - name: Build
81 run: go test -c .
82 env:
83 GOOS: freebsd
84
85 - name: Test
86 uses: cross-platform-actions/action@0c165ad7eb2d6a7e8552d6af5aad2bbedfc646b0 # v1.1.0
87 with:
88 operating_system: freebsd
89 version: "14.0"
90 shell: bash
91 run: ./go-re2.test -test.v -test.short
92 sync_files: runner-to-vm
93
94 # Runs tests using wazero inside a minimal golang docker image. This makes sure the code builds
95 # even when there is no C toolchain available. It is possible for code to work fine with CGO_ENABLED=0
96 # but not build without a C toolchain available, e.g. if C source files are checked into the repo
97 # without a build tag to exclude them from pure-Go builds.
98 docker-build:
99 runs-on: ubuntu-24.04
100 container:
101 image: golang:alpine
102 steps:
103 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
104
105 - run: if command -v gcc &> /dev/null; then echo "GCC found but not expected"; exit 2; fi
106
107 - run: go run ./build test
108 env:
109 TEST_NORACE: "true"