Skip to content

Commit b616d21

Browse files
committed
Workflow to run related tests
Signed-off-by: Shveta Sachdeva <[email protected]>
1 parent 91402f1 commit b616d21

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

.github/workflows/pr-related-tests.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ on:
66
paths:
77
- "client/src/app/pages/**"
88
- "cypress/e2e/**"
9-
- ".github/test-mapping.json"
9+
- "package.json"
10+
- "package-lock.json"
11+
- "cypress/test-mapping.json"
1012
- ".github/scripts/get-related-tests.js"
1113

1214
concurrency:
@@ -19,6 +21,7 @@ jobs:
1921
outputs:
2022
test_patterns: ${{ steps.get-tests.outputs.test_patterns }}
2123
should_run_tests: ${{ steps.get-tests.outputs.should_run_tests }}
24+
2225
steps:
2326
- name: Checkout code
2427
uses: actions/checkout@v4
@@ -32,15 +35,16 @@ jobs:
3235
- name: Detect related tests
3336
id: get-tests
3437
run: |
35-
node .github/scripts/get-related-tests.js origin/${{ github.base_ref }} HEAD > output.txt
38+
echo "Running related tests detector..."
39+
40+
# IMPORTANT fix: use ... syntax + add --expand
41+
node .github/scripts/get-related-tests.js origin/${{ github.base_ref }} HEAD --expand > output.txt
3642
cat output.txt
3743
38-
# Extract the TEST_PATTERNS line
3944
TEST_PATTERNS=$(grep "^TEST_PATTERNS=" output.txt | sed 's/^TEST_PATTERNS=//')
4045
4146
echo "test_patterns=${TEST_PATTERNS}" >> $GITHUB_OUTPUT
4247
43-
# Check if we should run tests
4448
if [ -n "$TEST_PATTERNS" ]; then
4549
echo "should_run_tests=true" >> $GITHUB_OUTPUT
4650
else
@@ -49,7 +53,7 @@ jobs:
4953
5054
echo "Tests to run: ${TEST_PATTERNS}"
5155
52-
- name: Upload test patterns
56+
- name: Upload test patterns (debug)
5357
if: steps.get-tests.outputs.should_run_tests == 'true'
5458
run: |
5559
echo "${{ steps.get-tests.outputs.test_patterns }}" > test-patterns.txt
@@ -59,11 +63,10 @@ jobs:
5963
needs: detect-changes
6064
if: needs.detect-changes.outputs.should_run_tests == 'true'
6165
runs-on: ubuntu-latest
66+
6267
strategy:
6368
fail-fast: false
6469
matrix:
65-
# This will be populated dynamically based on test patterns
66-
# For now, we'll run all detected tests in a single job
6770
test_group: [related]
6871

6972
steps:
@@ -75,27 +78,30 @@ jobs:
7578
with:
7679
node-version: "20.12.2"
7780
cache: "npm"
78-
cache-dependency-path: "cypress/package-lock.json"
7981

8082
- name: Upgrade npm
8183
run: npm install -g [email protected]
8284

85+
# Install monorepo dependencies (root)
86+
- name: Install root dependencies
87+
run: npm ci
88+
89+
# Install Cypress dependencies (workspace)
8390
- name: Install Cypress dependencies
8491
working-directory: cypress
8592
run: npm ci
8693

8794
- name: Run Cypress tests
8895
working-directory: cypress
8996
run: |
90-
# Convert test patterns to cypress spec parameter
9197
TEST_PATTERNS="${{ needs.detect-changes.outputs.test_patterns }}"
9298
9399
if [ -n "$TEST_PATTERNS" ]; then
94-
# Cypress expects comma-separated list for --spec
95100
SPECS="$(echo "$TEST_PATTERNS" | tr ' ' ',')"
101+
echo "Running specs: $SPECS"
96102
npx cypress run --spec "$SPECS"
97103
else
98-
echo "No test patterns specified, skipping tests"
104+
echo "No test patterns specified, skipping tests."
99105
fi
100106
env:
101107
CYPRESS_BASE_URL: http://localhost:3000
File renamed without changes.

0 commit comments

Comments
 (0)