|
| 1 | +name: CI |
| 2 | +env: |
| 3 | + DO_NOT_TRACK: 1 |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + paths: |
| 9 | + - "packages/**" |
| 10 | + pull_request: |
| 11 | + branches: [main] |
| 12 | + paths: |
| 13 | + - "packages/**" |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + services: |
| 19 | + postgres: |
| 20 | + image: postgres:latest |
| 21 | + env: |
| 22 | + POSTGRES_USER: orm |
| 23 | + POSTGRES_PASSWORD: password |
| 24 | + POSTGRES_DB: orm |
| 25 | + ports: |
| 26 | + - 54321:5432 |
| 27 | + options: >- |
| 28 | + --health-cmd pg_isready |
| 29 | + --health-interval 10s |
| 30 | + --health-timeout 5s |
| 31 | + --health-retries 5 |
| 32 | +
|
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v5 |
| 35 | + |
| 36 | + - name: Install pnpm |
| 37 | + uses: pnpm/action-setup@v4 |
| 38 | + with: |
| 39 | + run_install: false |
| 40 | + |
| 41 | + - name: Setup Node.js |
| 42 | + uses: actions/setup-node@v5 |
| 43 | + with: |
| 44 | + node-version-file: ".tool-versions" |
| 45 | + cache: "pnpm" |
| 46 | + |
| 47 | + - name: Get pnpm store directory |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 51 | +
|
| 52 | + - name: Install dependencies |
| 53 | + run: pnpm install --frozen-lockfile |
| 54 | + |
| 55 | + - name: Run tests |
| 56 | + run: pnpm test |
| 57 | + |
| 58 | + - name: Check formatting |
| 59 | + run: pnpm format:check |
| 60 | + |
| 61 | + - name: Lint |
| 62 | + run: pnpm lint |
| 63 | + |
| 64 | + - name: Check dependencies are in sync |
| 65 | + run: pnpm syncpack:check |
| 66 | + |
| 67 | + - name: Check types |
| 68 | + run: pnpm typecheck |
| 69 | + |
| 70 | + - name: Upload coverage reports |
| 71 | + if: github.actor != 'dependabot[bot]' |
| 72 | + uses: actions/upload-artifact@v4 |
| 73 | + with: |
| 74 | + name: coverage-reports |
| 75 | + path: | |
| 76 | + packages/*/coverage |
| 77 | + retention-days: 7 |
| 78 | + |
| 79 | + - name: Extract coverage percentage |
| 80 | + id: coverage |
| 81 | + if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + echo "coverage<<EOF" >> $GITHUB_OUTPUT |
| 85 | + for d in packages/*/coverage/coverage-summary.json; do |
| 86 | + pkg=$(echo $d | cut -d'/' -f2) |
| 87 | + pct=$(jq -r '.total.lines.pct' $d) |
| 88 | + echo "* $pkg: ${pct}%" >> $GITHUB_OUTPUT |
| 89 | + done |
| 90 | + echo "EOF" >> $GITHUB_OUTPUT |
| 91 | +
|
| 92 | + - name: Find Comment |
| 93 | + uses: peter-evans/find-comment@v4 |
| 94 | + if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' |
| 95 | + id: find-comment |
| 96 | + with: |
| 97 | + issue-number: ${{ github.event.pull_request.number }} |
| 98 | + comment-author: "github-actions[bot]" |
| 99 | + body-includes: "Coverage Report" |
| 100 | + |
| 101 | + - name: Create or Update Comment |
| 102 | + uses: peter-evans/create-or-update-comment@v5 |
| 103 | + if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' |
| 104 | + with: |
| 105 | + comment-id: ${{ steps.find-comment.outputs.comment-id }} |
| 106 | + issue-number: ${{ github.event.pull_request.number }} |
| 107 | + body: | |
| 108 | + ### Coverage Report |
| 109 | + ${{ steps.coverage.outputs.coverage }} |
| 110 | + edit-mode: replace |
0 commit comments