|
| 1 | +# GitHub Actions CI — mirrors the Makefile's verification discipline |
| 2 | +# (vet → test/race → conformance → build, plus bench) on pull requests and |
| 3 | +# pushes to main, and only when source files change (doc-only changes are |
| 4 | +# skipped). The Makefile is the single source of truth: jobs call `make <target>` |
| 5 | +# where a target exists; the extra hardening steps (gofmt gate, govulncheck, |
| 6 | +# cross-platform build, coverage) are CI-only and call `go` directly. |
| 7 | +# |
| 8 | +# luapure is a zero-dependency pure-Go port, so there is no go.sum: `make test` |
| 9 | +# is already race-enabled and `make conformance` runs the official Lua 5.4 |
| 10 | +# fixtures as a hard gate. |
| 11 | + |
| 12 | +name: CI |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - "**/*.go" |
| 19 | + - "go.mod" |
| 20 | + - "Makefile" |
| 21 | + - "conformance/**" |
| 22 | + - "_lua5.4-tests/**" |
| 23 | + - "_glue5.4-tests/**" |
| 24 | + - ".github/workflows/ci.yml" |
| 25 | + pull_request: |
| 26 | + paths: |
| 27 | + - "**/*.go" |
| 28 | + - "go.mod" |
| 29 | + - "Makefile" |
| 30 | + - "conformance/**" |
| 31 | + - "_lua5.4-tests/**" |
| 32 | + - "_glue5.4-tests/**" |
| 33 | + - ".github/workflows/ci.yml" |
| 34 | + |
| 35 | +concurrency: |
| 36 | + group: ci-${{ github.ref }} |
| 37 | + cancel-in-progress: true |
| 38 | + |
| 39 | +jobs: |
| 40 | + # Fast fail on formatting before spending time on the heavier jobs. |
| 41 | + format: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v7 |
| 45 | + - uses: actions/setup-go@v6 |
| 46 | + with: |
| 47 | + go-version-file: go.mod |
| 48 | + - name: gofmt |
| 49 | + run: | |
| 50 | + unformatted=$(gofmt -l .) |
| 51 | + if [ -n "$unformatted" ]; then |
| 52 | + echo "These files are not gofmt-clean:"; echo "$unformatted" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | +
|
| 56 | + # The canonical pre-push gate: vet → race-enabled tests (with coverage) → |
| 57 | + # official Lua 5.4 conformance fixtures. Equivalent to `make check` minus the |
| 58 | + # build step (which the cross-platform build job below proves separately). |
| 59 | + verify: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v7 |
| 63 | + - uses: actions/setup-go@v6 |
| 64 | + with: |
| 65 | + go-version-file: go.mod # tracks the toolchain pinned in go.mod |
| 66 | + cache: true # build cache, keyed on go.mod (no go.sum: zero deps) |
| 67 | + - run: make vet |
| 68 | + # `make test` is `go test -race -count=1 ./...`; add a coverage profile. |
| 69 | + # covermode=atomic is required under -race. |
| 70 | + - name: test (race, with coverage) |
| 71 | + run: go test -race -covermode=atomic -coverprofile=coverage.out -count=1 ./... |
| 72 | + - name: conformance (official Lua 5.4 fixtures) |
| 73 | + run: make conformance |
| 74 | + - name: upload coverage |
| 75 | + uses: actions/upload-artifact@v7 |
| 76 | + with: |
| 77 | + name: coverage |
| 78 | + path: coverage.out |
| 79 | + if-no-files-found: warn |
| 80 | + |
| 81 | + # Scan dependencies and code for known vulnerabilities. |
| 82 | + govulncheck: |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v7 |
| 86 | + - uses: actions/setup-go@v6 |
| 87 | + with: |
| 88 | + go-version-file: go.mod |
| 89 | + cache: true |
| 90 | + - name: govulncheck |
| 91 | + env: |
| 92 | + # govulncheck@latest requires a newer Go than go.mod pins; allow the |
| 93 | + # toolchain to auto-upgrade for the tool install. setup-go v6 defaults |
| 94 | + # GOTOOLCHAIN to "local", which otherwise blocks this. |
| 95 | + GOTOOLCHAIN: auto |
| 96 | + run: | |
| 97 | + go install golang.org/x/vuln/cmd/govulncheck@latest |
| 98 | + govulncheck ./... |
| 99 | +
|
| 100 | + # build runs only after verify passes, mirroring the Makefile's |
| 101 | + # "build only after tests pass", and proves the engine + all `go` targets are |
| 102 | + # cross-platform. `make` isn't assumed on Windows, so call `go` directly. |
| 103 | + build: |
| 104 | + needs: verify |
| 105 | + strategy: |
| 106 | + fail-fast: false |
| 107 | + matrix: |
| 108 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 109 | + runs-on: ${{ matrix.os }} |
| 110 | + steps: |
| 111 | + - uses: actions/checkout@v7 |
| 112 | + - uses: actions/setup-go@v6 |
| 113 | + with: |
| 114 | + go-version-file: go.mod |
| 115 | + cache: true |
| 116 | + - run: go vet ./... |
| 117 | + - run: go build ./... |
| 118 | + |
| 119 | + # bench is observational, not a gate — a slow/noisy run must not fail CI. |
| 120 | + bench: |
| 121 | + needs: verify |
| 122 | + runs-on: ubuntu-latest |
| 123 | + continue-on-error: true |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@v7 |
| 126 | + - uses: actions/setup-go@v6 |
| 127 | + with: |
| 128 | + go-version-file: go.mod |
| 129 | + cache: true |
| 130 | + - run: make bench |
0 commit comments