chore: add GitHub CI workflow and update documentation #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| # Cancel in-progress runs when new commits are pushed | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| # Detect what files changed to skip tests on doc-only changes | |
| changes: | |
| name: Detect Changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| code: ${{ steps.filter.outputs.code }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| code: | |
| - '**/*.go' | |
| - 'go.mod' | |
| - 'go.sum' | |
| - '.github/workflows/**' | |
| - '.golangci.yml' | |
| - 'Taskfile.yml' | |
| test: | |
| needs: changes | |
| if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request' | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run tests | |
| run: go test -v -race -timeout=10m ./... | |
| fuzz: | |
| needs: changes | |
| if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request' | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Run fuzz tests (quick) | |
| run: | | |
| # Run each fuzz test for 10 seconds to catch obvious issues | |
| go test -fuzz=FuzzParseScript -fuzztime=10s . | |
| go test -fuzz=FuzzParseExpressions -fuzztime=10s . | |
| go test -fuzz=FuzzEvalExpressions -fuzztime=10s . | |
| lint: | |
| needs: changes | |
| if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request' | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Run golangci-lint | |
| uses: golangci/golangci-lint-action@v6 | |
| with: | |
| version: latest | |
| args: --timeout 5m | |
| - name: Install govulncheck | |
| run: go install golang.org/x/vuln/cmd/govulncheck@latest | |
| - name: Run govulncheck | |
| run: govulncheck ./... | |
| build: | |
| needs: changes | |
| if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request' | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Build | |
| run: go build -v ./... | |
| - name: Cross-compile check | |
| run: | | |
| echo "Cross-compiling for Linux (amd64)..." | |
| GOOS=linux GOARCH=amd64 go build -v ./... | |
| echo "Cross-compiling for Linux (arm64)..." | |
| GOOS=linux GOARCH=arm64 go build -v ./... | |
| echo "Cross-compiling for Windows (amd64)..." | |
| GOOS=windows GOARCH=amd64 go build -v ./... | |
| echo "Cross-compiling for macOS (amd64)..." | |
| GOOS=darwin GOARCH=amd64 go build -v ./... | |
| echo "Cross-compiling for macOS (arm64)..." | |
| GOOS=darwin GOARCH=arm64 go build -v ./... | |
| coverage: | |
| needs: changes | |
| if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request' | |
| timeout-minutes: 15 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Run tests with coverage | |
| run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| file: ./coverage.txt | |
| flags: unittests | |
| fail_ci_if_error: false |