ci: Add org-wide project automation workflow #1
Workflow file for this run
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: | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
| TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | |
| jobs: | |
| ci: | |
| name: Build & Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: apps/gateway -> target | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v5 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Generate Prisma client | |
| run: pnpm --filter @onecli/db generate | |
| - name: Lint, format & type check | |
| run: pnpm check | |
| # Gateway is excluded — clippy (check) and cargo test already compile it. | |
| # Release builds only happen in publish.yml for Docker images. | |
| - name: Build | |
| run: pnpm build --filter='!@onecli/gateway' | |
| - name: Test | |
| run: pnpm test | |
| # Checks that schema.prisma is fully covered by migrations. | |
| # Spins up a temporary Postgres only when Prisma files changed. | |
| - name: Check for Prisma changes | |
| id: prisma-changes | |
| run: | | |
| CHANGED=$(gh pr diff ${{ github.event.pull_request.number }} --name-only | grep -c '^packages/db/prisma/' || true) | |
| echo "changed=$CHANGED" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Check migration drift | |
| if: steps.prisma-changes.outputs.changed != '0' | |
| run: | | |
| docker run -d --name shadow-db -e POSTGRES_USER=ci -e POSTGRES_PASSWORD=ci -e POSTGRES_DB=shadow -p 5433:5432 postgres:18-alpine | |
| until docker exec shadow-db pg_isready; do sleep 1; done | |
| pnpm --filter @onecli/db exec prisma migrate diff \ | |
| --from-migrations ./prisma/migrations \ | |
| --to-schema-datamodel ./prisma/schema.prisma \ | |
| --shadow-database-url postgresql://ci:ci@localhost:5433/shadow \ | |
| --exit-code; EXIT_CODE=$? | |
| docker rm -f shadow-db | |
| exit $EXIT_CODE |