Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor cypress action; separate setup and run #8460

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 45 additions & 16 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
name: Cypress Tests

on:
schedule:
- cron: "30 22 * * *"
pull_request:
branches:
- develop
- staging
workflow_dispatch:

jobs:
cypress-run:
setup:
permissions: write-all
if: github.repository == 'ohcnetwork/care_fe'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- name: Checkout 📥
uses: actions/checkout@v3
Expand All @@ -30,7 +24,7 @@ jobs:
else
echo "branch=develop" >> $GITHUB_OUTPUT
fi

- name: Checkout care 📥
uses: actions/checkout@v3
with:
Expand All @@ -45,7 +39,7 @@ jobs:
make docker_config_file=docker-compose.pre-built.yaml up
make docker_config_file=docker-compose.pre-built.yaml load-dummy-data
cd ..

- name: Wait for care to be up ♻
uses: nick-fields/retry@v2
with:
Expand All @@ -54,19 +48,15 @@ jobs:
command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000
on_retry_command: sleep 5

- name: Determine PR Origin
id: pr_origin
run: echo "::set-output name=is_forked::$( echo ${{ github.event.pull_request.head.repo.fork }})"

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install dependencies 📦
run: npm install
run: npm ci

- name: Build & Compile rescript files ⚙️
- name: Build files ⚙️
run: npm run build

- name: Install Specific Chrome Version
Expand All @@ -75,6 +65,45 @@ jobs:
sudo wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt-get install ./google-chrome-stable_current_amd64.deb

- name: Cache Cypress Binary
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-cache

- name: Cache build artifacts
uses: actions/cache@v3
with:
path: |
./*
key: ${{ runner.os }}-build-${{ github.sha }}

cypress-run:
needs: setup
permissions: write-all
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- name: Restore cached build artifacts
uses: actions/cache@v3
with:
path: |
./*
key: ${{ runner.os }}-build-${{ github.sha }}

- name: Restore Cypress Cache
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-cache

- name: Determine PR Origin
id: pr_origin
run: echo "::set-output name=is_forked::$( echo ${{ github.event.pull_request.head.repo.fork }})"

- name: Cypress run for Non-Forked PRs 🥬
if: steps.pr_origin.outputs.is_forked == 'false'
uses: cypress-io/github-action@v5
Expand Down Expand Up @@ -132,4 +161,4 @@ jobs:
if: steps.pr_origin.outputs.is_forked == 'true'
with:
name: cypress-videos
path: cypress/videos
path: cypress/videos
Loading