Set up github actions to run cypress tests on localhost from 2 different repositories

Viewed 829

I have my front-end (repUI) and cypress tests (repTest) in separate repositories., I am trying to run the tests by checkout both from repTest. Once the repUI is set up (install and build), the localhost:8000 is ready for tests to run.

So far the following workflow is designed:

name: Cypress E2E Tests on Dev

on:
 workflow_dispatch:
 push:
    branches-ignore: [ main ]
 schedule:
    - cron:  '0 0 * * 1-5'
jobs:
 setup:
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        node-version: [14.x]

    steps:
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    
   # Checkout UI repo 
    - name: Checkout voy-frontend repo
      uses: actions/checkout@v2
      with:
        repository: orgName/xyz-frontend
        path: xyz-frontend 
        ssh-key: ${{ secrets.GIT_SSH_KEY }}
        
   # Install voy-f dependancies
    - name: Install dependancies for application
      run: | 
       cd voy-frontend
       pwd
       npm install
      
    - name: Get npm cache directory
      id: npm-cache-dir
      run: |
        echo "::set-output name=dir::$(npm config get cache)"
    - uses: actions/cache@v2
      id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
      with:
        path: ${{ steps.npm-cache-dir.outputs.dir }}
        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
        restore-keys: |
          ${{ runner.os }}-node-
   
       
    # Run application
    - name: Run application
      run: | 
       pwd
       cd voy-frontend
       npm run serve
       
 cypress-test:
    name: Test
    needs: setup
    runs-on: ubuntu-latest
    steps:
    # Checkout test automation repo 
    - name: git checkout
      uses: actions/checkout@v2
      with:
        ref: main
        
   # Install cypress dependancies
    - name: Cypress install
      uses: cypress-io/github-action@v2
      
    # Run cypress tests  
    - name: Cypress run - localhost
      run: npm run cy:r -- --env TENANT=${{ secrets.TENANT }},CLIENT_ID=${{ secrets.CLIENT_ID }},CLIENT_SECRET=${{ secrets.CLIENT_SECRET }},ORG_SCOPE=${{ secrets.ORG_SCOPE }},G_SCOPE=${{ secrets.G_SCOPE }}  --spec "cypress/integration/specs/Search.feature" --headless --browser chrome 
      
    - uses: actions/upload-artifact@v2
      if: failure()
      with:
        name: cypress-videos
        path: |
         cypress/reports
         cypress/videos
         cypress/screenshots
        retention-days: 1

The problem is if I run the build command npm run serve for repUI, the applications successfully getting started but it is not proceeding further instead it just waits. If I comment out the npm run serve, all other jobs are running as it should.

Here is the screenshot: enter image description here

For building, it only took ~60 seconds, and then it waits until I cancel it. Same case if I trigger the job again and always.

What needs to be done in order to proceed to the cypress-test job once the build is ready.?

0 Answers
Related