name: qawolf
on:
  push:
    # test every branch
    # edit below if you only want certain branches tested
    branches: "*"
  # schedule:
  #   # test on schedule using cron syntax
  #   - cron: "0 * * * *" # every hour
jobs:
  test:
    runs-on: ubuntu-18.04

    steps:
      - uses: actions/checkout@v2

      - uses: actions/setup-node@v1

      - uses: microsoft/playwright-github-action@v1

      - uses: actions/cache@v1
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm install

      # - name: Start local server
      #   run: npm run start & npx wait-on http://localhost:3000

      - run: npx qawolf test --headless
        env:
          # configure tests with environment variables
          FFMPEG_PATH: /usr/bin/ffmpeg # for recording video
          QAW_ARTIFACT_PATH: ${{ github.workspace }}/artifacts
          # you can also use GitHub secrets for environment variables
          # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets
          # LOGIN_PASSWORD: ${{ secrets.PASSWORD }}
      
      - name: Upload Artifacts
        if: always()
        uses: actions/upload-artifact@master
        with:
          name: qawolf
          path: ${{ github.workspace }}/artifacts