.github/workflows/ci.yml

name: ci

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read

jobs:
  test:
    name: test
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: "1.22"
          cache: true
      - name: go vet
        run: go vet ./...
      - name: go test
        run: go test -race ./...
      - name: go build
        run: go build -trimpath -o bin/tilstream ./
      - name: upload binary
        uses: actions/upload-artifact@v4
        with:
          name: tilstream-linux-amd64
          path: bin/tilstream
          if-no-files-found: error
          retention-days: 7

  docs:
    name: build example site
    runs-on: ubuntu-22.04
    needs: test
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: "1.22"
          cache: true
      - name: build example
        run: |
          go run ./ -input ./examples/notes -output ./_public
      - name: upload site
        uses: actions/upload-artifact@v4
        with:
          name: example-site
          path: _public
          if-no-files-found: error
          retention-days: 7