update #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python Selenium CI/CD | |
on: [push, pull_request] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.7 | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Install Chrome | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y google-chrome-stable | |
- name: Install ChromeDriver | |
run: | | |
set -e | |
CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+' || echo "unknown") | |
CHROME_MAJOR_VERSION=$(echo $CHROME_VERSION | cut -d '.' -f 1) | |
echo "Detected Chrome version: $CHROME_VERSION" | |
echo "Detected Chrome major version: $CHROME_MAJOR_VERSION" | |
# Try to get the exact matching ChromeDriver version | |
DRIVER_VERSION=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION || echo "") | |
# Fallback to major version | |
if [ -z "$DRIVER_VERSION" ]; then | |
echo "Exact ChromeDriver version not found. Trying major version..." | |
DRIVER_VERSION=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAJOR_VERSION || echo "") | |
fi | |
# Fallback to generic latest release | |
if [ -z "$DRIVER_VERSION" ]; then | |
echo "Major version ChromeDriver also not found. Falling back to latest release..." | |
DRIVER_VERSION=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE || echo "") | |
fi | |
echo "Using ChromeDriver version: $DRIVER_VERSION" | |
wget --tries=3 https://chromedriver.storage.googleapis.com/$DRIVER_VERSION/chromedriver_linux64.zip | |
unzip chromedriver_linux64.zip | |
sudo mv chromedriver /usr/bin/chromedriver | |
sudo chmod +x /usr/bin/chromedriver | |
chromedriver --version | |
google-chrome --version | |
- name: Set environment variable (Test) | |
run: echo "ENV=test" >> $GITHUB_ENV | |
- name: Run tests | |
run: | | |
echo "Running tests in $ENV environment" | |
pytest --maxfail=1 --disable-warnings -q --html=report.html | |
- name: Upload test report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pytest-report | |
path: report.html |