-
Notifications
You must be signed in to change notification settings - Fork 178
66 lines (55 loc) · 2.35 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Test
on: [push, pull_request]
jobs:
CypressMockTests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
container: [1, 2, 3, 4, 5] # Creates 5 parallel executions for Cypress tests.
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: '18.x'
- name: Install Node.js packages for Cypress
run: npm install
- name: Get test files
id: test-files
run: |
echo "Current working directory:"
pwd
TEST_DIR="frontend/src/__tests__/cypress/cypress/tests/mocked"
echo "Listing contents of the current directory:"
ls -la
echo "Checking for test files in $TEST_DIR"
echo "Listing contents of frontend/src/__tests__/cypress/cypress/tests:"
ls -la frontend/src/__tests__/cypress/cypress/tests/
if [ -d "$TEST_DIR" ]; then
echo "Listing contents of mocked directory:"
ls -la "$TEST_DIR"
TEST_FILES=$(find "$TEST_DIR" -name "*.cy.ts" | tr '\n' ',')
echo "Found test files: $TEST_FILES"
echo "files=$TEST_FILES" >> $GITHUB_OUTPUT
else
echo "Directory does not exist. No test files found." >> $GITHUB_OUTPUT
echo "files=" >> $GITHUB_OUTPUT # Set empty output if no files found
fi
- name: Run Cypress Mock Tests in Parallel
env:
CONTAINER_INDEX: ${{ matrix.container }}
TEST_FILES: ${{ steps.test-files.outputs.files }}
run: |
echo "Running Cypress tests for container $CONTAINER_INDEX..."
echo "Test Files: $TEST_FILES"
# Generate the list of spec files for this container and trim trailing comma
SPEC_FILES=$(echo "$TEST_FILES" | tr ',' '\n' | awk -v container="$CONTAINER_INDEX" 'NR % 5 == container - 1' | sed 's|^frontend/||' | tr '\n' ',' | sed 's/,$//')
# Check if SPEC_FILES is empty
if [ -z "$SPEC_FILES" ]; then
echo "No spec files found for container $CONTAINER_INDEX. Skipping Cypress tests."
exit 0
else
echo "Spec files for this container- $SPEC_FILES"
cd frontend && CYPRESS_SPEC_PATTERN="$SPEC_FILES" npm run test:cypress-ci
fi