Skip to content

Commit

Permalink
Use Cypress split for forked prs (#7294)
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar authored Mar 4, 2024
1 parent 51530fc commit dbf4f88
Show file tree
Hide file tree
Showing 4 changed files with 3,592 additions and 3,319 deletions.
46 changes: 45 additions & 1 deletion .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,25 @@ jobs:
max_attempts: 5
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: Install dependencies 📦
run: npm install

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

- name: Cypress run 🥬
- name: Install Specific Chrome Version
run: |
sudo apt-get install -y wget
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: Cypress run for Non-Forked PRs 🥬
if: steps.pr_origin.outputs.is_forked == 'false'
uses: cypress-io/github-action@v5
with:
env: SKIP_PREFLIGHT_CHECK=true
Expand All @@ -60,6 +71,7 @@ jobs:
browser: chrome
record: true
parallel: true
group: "UI-Chrome"
env:
CARE_API: http://localhost:9000
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
Expand All @@ -68,9 +80,41 @@ jobs:
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}}

- name: Cypress run for Forked PRs 🥬
if: steps.pr_origin.outputs.is_forked == 'true'
uses: cypress-io/github-action@v5
with:
env: SKIP_PREFLIGHT_CHECK=true
install: false
start: "npx vite preview --host"
wait-on: "http://localhost:4000"
wait-on-timeout: 300
browser: chrome
record: true
parallel: true
group: "UI-Chrome"
env:
CYPRESS_SPLIT_TESTS: "true"
CARE_API: http://localhost:9000
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max_old_space_size=4096
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}}
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}

- name: Upload cypress screenshots on failure 📸
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots

- name: Upload cypress videos 📹
uses: actions/upload-artifact@v3
if: steps.pr_origin.outputs.is_forked == 'true'
with:
name: cypress-videos
path: cypress/videos

6 changes: 6 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "cypress";
import fs from "fs";
import cypressSplit from "cypress-split";

export default defineConfig({
projectId: "wf7d2m",
Expand All @@ -19,6 +20,11 @@ export default defineConfig({
return null;
},
});

if (process.env.CYPRESS_SPLIT_TESTS === "true") {
cypressSplit(on, config);
}

return config;
},
baseUrl: "http://localhost:4000",
Expand Down
Loading

0 comments on commit dbf4f88

Please sign in to comment.