Github Actions - Move onto the next step/job when the previous step is a running process (i.e. backend server in a monorepo)
Viewed 3 times
I want to use Github Actions for CI and run tests before the branch can be merged.
I have a monorepo with Nest & Angular. I am using Cypress/Jest for my tests.
I need my backend running for my frontend cypress tests to pass...
Currently GH Actions doesn't move onto the next step because the backend process is running - but that's what I want...
How do I successfully move onto the next step within github actions once my Nest backend process is up and running? (I am open to constructing my workflow file however i need to)
name: test
on: [push]
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OTHER_SECRETS: ${{ secrets.otherSecrets }}
jobs:
cypress-run:
runs-on: macos-11
steps:
# start cypress w/github action: https://github.com/cypress-io/github-action
- name: Setup Node.js environment
uses: actions/setup-node@v2.5.0
with:
node-version: '16.13.0'
- name: Checkout
uses: 'actions/checkout@v2'
- name: "Start Backend"
run: |
cd server &&
npm install &&
npm run build &&
npm run start:prod
- name: "Start Frontend"
run: |
npm install &&
npm run build &&
npm run start
- name: Cypress run
uses: cypress-io/github-action@v2
with:
record: true
browser: chrome
- name: "Run Jest Tests"
run: |
cd server &&
npm run test
#note: I have tried appending the "&& sleep 10 && curl http://localhost:port -i" option to the npm commands - and it hasn't worked for me.
#note2: It's my first time w/ GH Actions, so maybe I'm missing something obvious!!