0

I have a CI pipeline setup using Github Action/Workflows, where I want to run Cypress Automated tests; however I am having some problems of when trying to run my dev server. Let me show you my pipeline:

name: Nuxt CI Pipeline

on:
  push:
    branches: [ CI-pipeline ]
  # pull_request:
  #   branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [ 14.x ]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - name: Make envfile
      uses: SpicyPizza/create-envfile@v1
      with:
        envkey_ENV: staging
        file_name: .env
    - run: npm ci
    - run: npm run dev
    - run: | 
        cd e2e
        ls -l
        npm ci
        npx cypress run

Now I want to spin up the devserver and run the tests on that port usually 3000; however the problem is when the command npm run dev is executed, the pipeline keeps on waiting there and doesn't move forward to the next commands, which makes sense as devserver doesn't return a response – it listens on that port until explicitly closed. I'm stuck here. My knowledge of devops is the bare minimum; can someone point out what I am missing?

1 Answer 1

1

The pipeline is configured correctly, you were just missing one piece of the puzzle called service containers.

Basically, the service containers also known as sidecars will run alongside your "main" pipeline logic and support your commands. In your case, you will run the npm run dev in a service container once the build job starts and when the npx cypress run runs it will have a dev server to connect to.

Follow the example GitHub added for Redis

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.