Format Go sources #69
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, master] | |
| pull_request: | |
| branches: [main, master] | |
| permissions: | |
| contents: read | |
| jobs: | |
| actionlint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| cache: true | |
| - name: Install actionlint | |
| run: go install github.com/rhysd/actionlint/cmd/actionlint@latest | |
| - name: Lint GitHub workflows | |
| run: | | |
| "$(go env GOPATH)/bin/actionlint" -color | |
| detect-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| go_core: ${{ steps.filter.outputs.go_core }} | |
| python_client: ${{ steps.filter.outputs.python_client }} | |
| typescript_client: ${{ steps.filter.outputs.typescript_client }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Detect changed paths | |
| id: filter | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| filters: | | |
| go_core: | |
| - 'api/**' | |
| - 'cmd/**' | |
| - 'pkg/**' | |
| - 'tests/**' | |
| - 'go.mod' | |
| - 'go.sum' | |
| - 'Makefile' | |
| - '.github/workflows/ci.yml' | |
| typescript_client: | |
| - 'clients/typescript/**' | |
| - 'api/proto/membrane/v1/membrane.proto' | |
| - '.github/workflows/ci.yml' | |
| python_client: | |
| - 'clients/python/**' | |
| - 'api/proto/membrane/v1/membrane.proto' | |
| - '.github/workflows/ci.yml' | |
| build-and-test: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.go_core == 'true' | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: pgvector/pgvector:pg16 | |
| env: | |
| POSTGRES_DB: membrane_test | |
| POSTGRES_USER: membrane | |
| POSTGRES_PASSWORD: membrane | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd="pg_isready -U membrane -d membrane_test" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=10 | |
| strategy: | |
| matrix: | |
| go-version: ['1.22', '1.23'] | |
| env: | |
| TEST_POSTGRES_DSN: postgres://membrane:membrane@127.0.0.1:5432/membrane_test?sslmode=disable | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Wait for Postgres | |
| run: | | |
| for attempt in $(seq 1 30); do | |
| if pg_isready -h 127.0.0.1 -p 5432 -U membrane -d membrane_test; then | |
| exit 0 | |
| fi | |
| echo "Waiting for Postgres (${attempt}/30)..." | |
| sleep 2 | |
| done | |
| echo "Postgres did not become ready in time" >&2 | |
| exit 1 | |
| - name: Check formatting | |
| run: test -z "$(gofmt -l .)" | |
| - name: Check go mod tidy | |
| run: | | |
| go mod tidy | |
| git diff --exit-code go.mod go.sum | |
| - name: Build | |
| run: go build ./... | |
| - name: Run tests with coverage | |
| run: go test -v -race -count=1 -coverprofile=coverage.out ./... | |
| - name: Vet | |
| run: go vet ./... | |
| - name: Install and run staticcheck | |
| if: matrix.go-version == '1.23' | |
| run: | | |
| go install honnef.co/go/tools/cmd/staticcheck@latest | |
| staticcheck ./... | |
| typescript-client: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.typescript_client == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: npm | |
| cache-dependency-path: clients/typescript/package-lock.json | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| cache: true | |
| - name: Download Go dependencies | |
| run: go mod download | |
| - name: Install TypeScript client dependencies | |
| run: npm ci | |
| working-directory: clients/typescript | |
| - name: Verify proto sync | |
| run: npm run check:proto-sync | |
| working-directory: clients/typescript | |
| - name: Typecheck TypeScript client | |
| run: npm run typecheck | |
| working-directory: clients/typescript | |
| - name: Test TypeScript client | |
| run: npm test | |
| working-directory: clients/typescript | |
| python-client: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.python_client == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Python client dependencies | |
| run: python -m pip install -e "clients/python[dev]" | |
| - name: Test Python client | |
| run: python -m pytest clients/python/tests/ |