Skip to content
go-libfossil Artifact [f17b1976d1]
Login

Artifact [f17b1976d1]

Artifact f17b1976d193e910706d88ab962005d849d1776b1156be3e86521ab8aa8c5c3a:


name: Tests

on:
  push:
    branches: [main]
  pull_request:

jobs:
  test:
    name: Test (modernc)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
      - name: Install Fossil
        run: sudo apt-get update && sudo apt-get install -y fossil
      - name: Build all packages
        # Build every package, not just the cmd/libfossil dependency closure.
        # The `go test $(go list ./...)` step below silently drops any package
        # that fails to compile (go list omits it from stdout instead of
        # failing), so a broken import can vanish from the test run undetected.
        # Building `./...` first makes that a loud, fail-fast build error.
        run: GOWORK=off go build ./...
      - name: Unit tests
        # REQUIRE_FOSSIL_BIN turns "fossil is missing" into a failure rather
        # than an invisible skip. Verifying a real fossil reads what we write
        # is the one thing our own tests cannot substitute for.
        env:
          REQUIRE_FOSSIL_BIN: "1"
        run: GOWORK=off go test $(GOWORK=off go list ./... | grep -v '/dst') -count=1 -timeout=120s
      - name: DST
        run: GOWORK=off go test ./dst/... -count=1 -timeout=300s
      - name: Driver tests (modernc)
        run: cd db/driver/modernc && GOWORK=off go test ./... -count=1
      - name: Vet
        run: GOWORK=off go vet ./...

  test-ncruces:
    name: Test (ncruces)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
      - name: Install Fossil
        run: sudo apt-get update && sudo apt-get install -y fossil
      - name: Build all packages (ncruces)
        # Same fail-fast guard as the modernc leg, under the test_ncruces tag so
        # the ncruces driver's compile surface is covered too.
        run: GOWORK=off go build -tags test_ncruces ./...
      - name: Unit tests (ncruces)
        env:
          REQUIRE_FOSSIL_BIN: "1"
        run: GOWORK=off go test -tags test_ncruces $(GOWORK=off go list ./... | grep -v '/dst' | grep -v 'cmd/libfossil') -count=1 -timeout=120s
      - name: DST (ncruces)
        run: GOWORK=off go test -tags test_ncruces ./dst/... -count=1 -timeout=300s
      - name: Driver tests (ncruces)
        run: cd db/driver/ncruces && GOWORK=off go test ./... -count=1

  test-otel:
    name: Test (observer/otel)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
      - name: OTel sub-module tests
        run: cd observer/otel && GOWORK=off go test ./... -count=1

  test-docs:
    name: Test (docs/site)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
      - name: Install Hugo (extended)
        # docs/site pulls the hextra theme via Hugo Modules, which need both the
        # Go toolchain (setup-go above) and the Hugo binary. Pin the version so a
        # future Hugo release can't silently change build behaviour under us.
        env:
          HUGO_VERSION: "0.162.1"
        run: |
          curl -fsSL "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" \
            | sudo tar -xz -C /usr/local/bin hugo
      - name: Build docs site
        # docs/site is the one module with no Go source of its own: its go.mod
        # exists only to import the hextra theme as a Hugo Module, so `go build
        # ./...` there matches no packages and gates nothing. A real Hugo build
        # is the equivalent compile gate — it resolves the module import,
        # compiles templates, and renders content, failing loud on a broken
        # import or template the way the Go build steps do for the other modules.
        run: cd docs/site && GOWORK=off hugo --gc --minify