Run firebase emulators + vitest at once - yaml

The bounty expires in 7 days. Answers to this question are eligible for a +100 reputation bounty.
ARNON wants to draw more attention to this question:
What should I do to make it work? > I would like to run job 2 as soon as the emulator ports are open and finish job 1 only after job 2 finishes.
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"

Related

How to run cron jobs in github action for a particular day and time

How to run cron jobs automatically every Thursday at 10:30 am Australian Standard time irrespective of any other action? I have tried the below, but not sure if it's running. Could someone please advise?
I have the schedule.yml file in my branch.
Should I add the schedule.yml somewhere else?
Branch: cypress-schedule-test-ci-100
.github\workflows\schedule.yml
name: Cypress E2E Tests
on:
schedule:
- cron: "30 10 * * 4"
env:
CYPRESS_BOOKING_PASSWORD: ${{ secrets.CYPRESS_BOOKING_PASSWORD }}
CYPRESS_BOOKING_FREE_USER_PASSWORD: ${{ secrets.CYPRESS_BOOKING_FREE_USER_PASSWORD }}
jobs:
install:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Install dependencies
uses: cypress-io/github-action#v2
with:
# just perform install
runTests: false
tests:
runs-on: ubuntu-22.04
needs: install
steps:
- name: Check out code
uses: actions/checkout#v2
- name: Install dependencies
uses: cypress-io/github-action#v2
with:
# perform installation
runTests: false
- name: Run E2E tests
run: npm run cy:run -- --env grepTags="#MainUITests+-#Failing",ENV="qaserver" --browser chrome
- name: Upload Results
uses: actions/upload-artifact#v3
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
- uses: actions/upload-artifact#v2
if: always()
with:
name: cypress-videos
path: cypress/videos
While working with the schedule cron job, the following points need to keep in mind:
You can schedule a workflow to run at specific UTC times using POSIX cron syntax.
So, you might need to adjust it according to your time zone.
Scheduled workflows run on the latest commit on the default or base branch.
It should be scheduled for the default branch e.g. main. Apparently, this seems to be the reason why your scheduled job isn't working.
And,
Note: The schedule event can be delayed during periods of high loads of GitHub Actions workflow runs. High load times include the start of every hour. To decrease the chance of delay, schedule your workflow to run at a different time of the hour.
You need to account for such delays due to high loads.

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

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:
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.?

Cypress not able to read password from GitHub secrets but it is able to get record key

Here is my .yml file
name: smoke tests`enter code here`
on:
workflow_dispatch:
jobs:
cypress-test:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Install cypress and verify
run: npm install
- name: Run smoke tests
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
run: npx cypress-ntlm run -e TAGS='#smoke',configFile=test --spec 'cypress/integration/cucumber-tests/**/*.feature'
I was able to get password from GitHub secrets using npx cypress-ntlm run -e TAGS='#smoke',configFile=test CYPRESS_PASSWORD=$CYPRESS_PASSWORD --spec 'cypress/integration/cucumber-tests/**/*.feature'

How to run Xcode tests with yml?

It seems like it should be pretty simple, I just want to trigger a build and unit tests to be executed every time a developer pushes to their fork. GithubActions.
I’m creating a macOS app.
Here is what I'm trying. It doesn't work.
name: Smoke Test CI
on: [push, merge]
jobs:
build:
runs-on: macOS-latest
steps:
- uses: actions/checkout#v1
- name: Execute full install
- name: Xcodebuild Action
uses: sersoft-gmbh/xcodebuild-action#v1.3

Gitlab executing next stage even if one fails (with dependency)

I'm setting up a gitlab pipeline with multiple stages and at least two sites each stage. How do iIconditionally allow the next stage to continue even if one site in the first stage failed (and the whole stage as it is marked as failed)? For example: I want to prepare, build and test and I want to do this on Windows & Linux runner. So if my Linux runner failed in preparation but my Windows runner succeeded, then the next stage should start without building the Linux package, because this already failed. But the windows build should start.
My Intention is that if one system fails at least the second is able to continue.
I added dependencies and i thought that this would solve my problem. Because if site "build windows" is dependent on "prepare windows" then it shouldn't matter if "prepare Linux" failed. But this isn't the case :/
image: node:10.6.0
stages:
- prepare
- build
- test
prepare windows:
stage: prepare
tags:
- windows
script:
- npm i
- git submodule foreach 'npm i'
prepare linux:
stage: prepare
tags:
- linux
script:
- npm i
- git submodule foreach 'npm i'
build windows:
stage: build
tags:
- windows
script:
- npm run build-PWA
dependencies:
- prepare windows
build linux:
stage: build
tags:
- linux
script:
- npm run build-PWA
dependencies:
- prepare linux
unit windows:
stage: test
tags:
- windows
script:
- npm run test
dependencies:
- build windows
artifacts:
paths:
- dist/
- package.json
expire_in: 5 days
unit linux:
stage: test
tags:
- linux
script:
- npm run test
dependencies:
- build linux
artifacts:
paths:
- dist/
- package.json
expire_in: 5 days
See allow_failure option:
allow_failure allows a job to fail without impacting the rest of the CI suite.
example:
job1:
stage: test
script:
- execute_script_that_will_fail
allow_failure: true

Resources