I'm trying to run two jobs at the same time.
First I need to run firebase emulators
and when the ports are open, I need to run vitest.
This is what I'm doing at the moment:
name: Run Tests
on:
pull_request:
branches: [develop]
workflow_dispatch:
jobs:
job1:
name: Run Emulator
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.14.0
uses: actions/setup-node@v3
with:
node-version: 18.14.0
cache: 'npm'
- name: Execute Emulator
env:
VITE_RELEASE_STAGE: testing
run: |
npm ci
npm install --save firebase-tools
npm run emulators
job2:
name: Run Unit Tests
needs: job1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.14.0
uses: actions/setup-node@v3
with:
node-version: 18.14.0
cache: 'npm'
- name: Execute Unit Tests
env:
VITE_RELEASE_STAGE: testing
run: |
npm ci
npm run test
The doors open perfectly, but the second job never runs.
Here lies my doubt. Because if I don't use needs
the two will run at the same time and I will get an error in job2 because the ports will not be open in job 1.
I would like to run job 2 as soon as the emulator ports are open and finish job 1 only after job 2 finishes.
Does anyone know how I can resolve this?
EDIT
These are the two executed scripts that are in my package.json
:
"test": "vitest",
"emulators": "firebase emulators:start --project celebrityfanalizer --import emulatorData"