name: End-to-end tests
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
jobs:
  cypress-run:
    runs-on: ubuntu-latest
    steps:      
      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 16

      - name: Checkout
        uses: actions/checkout@v3

      - name: Cypress run
        uses: cypress-io/github-action@v2
        with:
          build: npm run build
          start: npm run serve
          wait-on: http://localhost:5000
          config: baseUrl=http://localhost:5000
          browser: chrome
        env:
          VITE_NO_WELCOME: 1
          VITE_CI: 1
          VITE_SOCKET_URL: https://public.jeremiez.net/
          VITE_SOCKET_PATH: /wamp/socket.io
          VITE_API_ENDPOINT: https://ricochetjs-deploy-production.up.railway.app/
          VITE_RICOCHET_SITEID: airboardgame
          ACTIONS_ALLOW_UNSECURE_COMMANDS: true
      - uses: actions/upload-artifact@v1
        if: failure()
        with:
          name: cypress-screenshots
          path: cypress/screenshots
      # Test run video was always captured, so this action uses "always()" condition
      - uses: actions/upload-artifact@v1
        if: always()
        with:
          name: cypress-videos
          path: cypress/videos
