name: Test
on:
  pull_request:
jobs:
  # Bump the membrane version
  test:
    name: Run Tests
    runs-on: ubuntu-latest
    outputs:
      version_id: ${{ steps.tag_version.outputs.new_tag }}
      upload_url: ${{ steps.create_release.outputs.upload_url }}
    steps:
      - uses: actions/checkout@v2
      - name: Cache Dependencies
        uses: actions/cache@v2
        with:
          path: 'node_modules'
          key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}

      - name: Use Node 16
        uses: actions/setup-node@v1
        with:
          node-version: 16
          registry-url: 'https://registry.npmjs.org'
          always-auth: true
      
      - name: Install Dependencies
        run: yarn install

      - name: Generate Sources
        run: yarn gen:protos 

      - name: Check worktree clean
        run: |
          git update-index -q --refresh
          if ! git diff-files --quiet; then
              >&2 echo "error: working tree is not clean, aborting!"
              git status
              git diff
              exit 1
          fi