1- name : Build and Run Tests
1+ name : Selenium Tests
22
33on :
4- pull_request :
4+ workflow_dispatch : # Allows running manually
5+ schedule :
6+ - cron : ' 0 0 * * *' # Run every day at 00:00 UTC
57
68jobs :
7- build :
8- name : Build and Run Tests
9- runs-on : ubuntu-latest
9+ selenium-tests :
10+ runs-on : macos-latest
11+ env :
12+ DEV_URL : ${{ vars.DEV_URL }}
13+ STAG_URL : ${{ vars.STAG_URL }}
14+
15+ permissions :
16+ checks : write
1017
1118 steps :
12- - name : Checkout Code
19+ - name : Checkout repository
1320 uses : actions/checkout@v3
1421
15- - name : Set up Python
22+ - name : Setup Python
1623 uses : actions/setup-python@v3
1724 with :
18- python-version : " 3.10 "
25+ python-version : " 3.12 "
1926
2027 - name : Cache Dependencies
2128 uses : actions/cache@v3
2229 with :
23- path : ~/.cache/pip
24- key : python-cache-${{ runner.os }}-${{ hashFiles('requirements.txt') }}
30+ path : |
31+ ~/.cache/pip
32+ .venv
33+ key : python-cache-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
2534 restore-keys : |
2635 python-cache-${{ runner.os }}-
2736
28- - name : Install Dependencies
37+ - name : Install Chrome and WebDriver if not already installed
38+ run : |
39+ if ! command -v google-chrome &>/dev/null; then
40+ echo "Installing Chrome"
41+ brew install --cask google-chrome
42+ else
43+ echo "Chrome is already installed"
44+ fi
45+
46+ - name : Install Poetry
2947 run : |
3048 python -m pip install --upgrade pip
31- pip install -r requirements.txt
49+ pip install poetry
50+
51+ - name : Install dependencies with Poetry
52+ run : |
53+ poetry install
3254
33- - name : Run Tests
55+ - name : Run Selenium Tests
3456 run : |
35- pytest --junit-xml=build/test-results/test/TEST-results.xml --verbose
36- continue-on-error : true # Ensures that test results are collected even if some tests fail
57+ poetry run pytest --verbose --junit-xml=reports/test-results.xml --capture=tee-sys
58+ continue-on-error : true # Ensure other steps run even if tests fail
59+
60+ - name : Publish Test Report
61+ uses : mikepenz/action-junit-report@v3
62+ if : always() # Always run this step, even if tests fail
63+ with :
64+ report_paths : ' reports/test-results.xml'
65+ detailed_summary : true
66+ include_passed : true
67+ check_name : ' Test Results'
68+
69+ - name : Upload Screenshots
70+ if : failure()
71+ uses : actions/upload-artifact@v3
72+ with :
73+ name : screenshots
74+ path : reports/screenshots/*
3775
38- - name : Upload Test Report
76+ - name : Upload Test Results
77+ if : always()
3978 uses : actions/upload-artifact@v3
40- if : always() # Always run this step even if tests fail
4179 with :
4280 name : junit-test-results
43- path : build /test-results/test/TEST -results.xml
81+ path : reports /test-results.xml
4482 retention-days : 1
0 commit comments