name: pr

on: [pull_request]

jobs:
  test:
    strategy:
      matrix:
        node-version: [10.x, 12.x]
        os: [macos-latest, ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: Install Dependencies
        run: yarn --frozen-lockfile
      - name: Test
        run: yarn -s test
  test-examples:
    strategy:
      matrix:
        example:
          - apollo-fullstack
          - ghost
          - kitchen-sink
          - ts-ast-reader
          # - githunt-api requires node 8
          # - star-wars requires special commands
          # rm examples/star-wars/src/star-wars-typegen.ts
          # rm examples/star-wars/star-wars-schema.graphql
          # node examples/star-wars/dist/schema.js
          # git diff --exit-code
        node-version: [10.x]
        os: [macos-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: Install Dependencies
        run: yarn --frozen-lockfile
      - name: Link
        run: yarn link
      - name: Example Install
        run: yarn --cwd=examples/${{ matrix.example }} --frozen-lockfile
      - name: Example Use Link
        run: yarn --cwd=examples/${{ matrix.example }} link @nexus/schema
      - name: Example Typecheck
        run: yarn --cwd=examples/${{ matrix.example }} tsc
