-
Notifications
You must be signed in to change notification settings - Fork 4
97 lines (81 loc) · 2.94 KB
/
selenium_tests.yml
File metadata and controls
97 lines (81 loc) · 2.94 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Selenium Tests
on:
workflow_dispatch: # Allows manual triggering
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
jobs:
selenium-test:
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
# copies your repository's code from GitHub and places it in the Ubuntu runner's default workspace directory at: /home/runner/work/your-repo/your-repo
- name: Checkout code
uses: actions/checkout@v4
# OPTIMIZED CACHE 1: Chrome binaries
- name: Cache Chrome and ChromeDriver
uses: actions/cache@v3
id: chrome-cache
with:
path: |
/opt/chrome
/usr/local/bin/chromedriver
key: chrome-130.0.6723.58
- name: Install Chrome for Testing
if: steps.chrome-cache.outputs.cache-hit != 'true'
run: |
CHROME_VERSION="130.0.6723.58"
echo "Downloading Chrome for Testing $CHROME_VERSION..."
wget -q "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chrome-linux64.zip"
unzip -q chrome-linux64.zip
sudo mkdir -p /opt/chrome
sudo mv chrome-linux64/* /opt/chrome/
sudo ln -sf /opt/chrome/chrome /usr/bin/google-chrome
wget -q "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chromedriver-linux64.zip"
unzip -q chromedriver-linux64.zip
sudo mv chromedriver-linux64/chromedriver /usr/local/bin/
sudo chmod +x /usr/local/bin/chromedriver
- name: Verify Chrome installation
run: |
google-chrome --version
chromedriver --version
# OPTIMIZED CACHE 2: Python (built-in, fastest)
- name: Set up Python with cache
uses: actions/setup-python@v6
with:
python-version: '3.13'
cache: 'pip' # ← Built-in caching
cache-dependency-path: 'requirements.txt'
- name: Install dependencies
run: |
python -m pip install -r requirements.txt
# OPTIMIZED CACHE 3: apt packages
- name: Cache apt packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libapache2-mod-php8.1
version: 1.0
- name: Switch Apache MPM and enable PHP
run: |
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo a2enmod php8.1
- name: Start Apache2 web server
run: |
# Create swe30009 subdirectory in web root
sudo mkdir -p /var/www/html/swe30009
# Copy folder containing your web application files
sudo cp -r ./swe30009/* /var/www/html/swe30009/
sudo systemctl start apache2
sleep 3 # Give it time to start
- name: Run Selenium tests
run: |
python ./tests/activity3_GitHub_Actions.py
- name: Upload test results (optional)
uses: actions/upload-artifact@v4
if: always()
with:
name: test-screenshots
path: |
*.png