0

I have a Monorepo which contains a front-end app and a node.js API. I would like to run both the front-end app and the node.js API, in order to run some end-to-end tests. However I can not figure out how to run these two applications before running the tests. Here is my actions file so far.

name: Test Client

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x]

    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: Initial Setup
        run: |
          npm install yarn -g
      - name: yarn install, build, and test
        working-directory: client-app
        run: |
          yarn install
          yarn build
          yarn test
        env:
          CI: true

I would like to run an API in a different directory, before running the client-app tests. Is this possible without using a third-party service?

3
  • 1
    As you're using Node, the easiest way is probably something like npmjs.com/package/concurrently (e.g. like I set up here: github.com/textbook/starter-kit/blob/…). You could alternatively look to see whether GitHub Actions supports "backgrounding" a step. Commented Jan 27, 2020 at 19:16
  • Thanks @jonrsharpe you post led me to a little bash command "&" which allows to run tasks in the background. for example "yarn start-api &". This means the CI pipeline does not hang on the command. :) Commented Jan 27, 2020 at 20:01
  • This is a valid question, i.e. how to start a front-end app and a back-end app together in github action. Not sure why someone downvoted it. Commented Feb 24, 2022 at 6:46

1 Answer 1

2

You can ensure the pipeline does not hang on a command by adding "&" to the end of the command: see: https://github.com/orgs/community/discussions/26864#discussioncomment-3253713

For example now I can do:

yarn start-api &
yarn start-client &
yarn test
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.