Skip to content

File

ci.yml

.github/workflows/ci.yml · 2535 bytes · Open on GitHub

name: CI

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

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
  integrity:
    # prevents this action from running on forks
    if: github.repository_owner == 'vercel'
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node: [ 20 ]
    steps:
    - name: Checkout
      uses: actions/checkout@v3
    - name: Enable pnpm
      run: corepack enable pnpm
    - name: Use Node.js ${{ matrix.node }}
      uses: actions/setup-node@v3
      with:
        node-version: ${{ matrix.node }}
        cache: 'pnpm'
    - name: Check pnpm
      run: pnpm --version
    - run: pnpm install --frozen-lockfile
    - run: pnpm ci-check

  test:
    # prevents this action from running on forks
    if: github.repository_owner == 'vercel'
    name: Node.js ${{ matrix.node }} on ${{ matrix.os }}
    # Installing compiles the headless-gl dev dependency used by the canvas tests.
    timeout-minutes: 10
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest]
        # The headless-gl dev dependency requires Node.js 20+.
        node: [20, 22]
    runs-on: ${{ matrix.os }}
    permissions:
      contents: write # to be able to publish a GitHub release
      issues: write # to be able to comment on released issues
      pull-requests: write # to be able to comment on released pull requests
      id-token: write # required for npm trusted publishing (OIDC)
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Enable pnpm
        run: corepack enable pnpm
      - name: Use Node.js ${{ matrix.node }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node }}
          cache: 'pnpm'
      - name: Check pnpm
        run: pnpm --version
      - run: pnpm install --frozen-lockfile
      - run: pnpm build
      - run: pnpm test
      - name: Update npm for trusted publishing
        # actions/setup-node ships npm 10.x; OIDC trusted publishing needs >= 11.5.1
        if: matrix.os == 'ubuntu-latest' && matrix.node == 22 && github.event_name == 'push' && github.ref == 'refs/heads/main'
        run: npm install -g npm@latest
      - name: Maybe Release
        if: matrix.os == 'ubuntu-latest' && matrix.node == 22 && github.event_name == 'push' && github.ref == 'refs/heads/main'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: pnpm dlx semantic-release@25.0.5