Inclusion of Selenium Test Pipeline #36
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: selenium_tests | |
on: pull_request | |
jobs: | |
selenium-tests: | |
permissions: | |
checks: write | |
pull-requests: write # only required if `comment: true` was enabled | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Set up cache for Maven | |
uses: actions/cache@v4 | |
with: | |
path: /home/runner/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
# Set up Docker | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# Pull the Chrome image | |
- name: Pull Selenoid Chrome Image | |
run: docker pull selenoid/chrome:latest | |
# Setup Docker-Compose | |
- name: Docker Compose Action | |
uses: hoverkraft-tech/[email protected] | |
with: | |
compose-file: "selenium/docker-compose.yml" | |
# Wait for the server to be ready before running tests | |
- name: Wait for the application to be ready | |
run: | | |
until curl --output /dev/null --silent --head --fail http://localhost:8080; do | |
echo 'Waiting for the application to be ready...' | |
sleep 5 | |
done | |
until curl --output /dev/null --silent --head --fail http://localhost:4444/status; do | |
echo 'Waiting for Selenoid to be ready...' | |
sleep 5 | |
done | |
# Set up Python and run Selenium tests | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.13' # Specify the version of Python you are using | |
- name: Cache Python dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('selenium/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: pip install -r selenium/requirements.txt # Ensure your Selenium and other dependencies are listed here | |
- name: Run Selenium tests | |
run: | | |
python3 selenium/selenium_tests.py > test-results.log | |
- name: Save results to env | |
if: always() && github.event_name == 'pull_request' | |
id: test_report | |
run: echo "SELENIUM_TEST_SUMMARY=$(base64 -w 0 test-results.log)" >> $GITHUB_ENV | |
# Install GitHub CLI | |
- name: Install GitHub CLI | |
run: sudo apt-get update && sudo apt-get install -y gh | |
- name: Decode results and comment | |
if: always() && github.event_name == 'pull_request' | |
run: | | |
decoded_results=$(echo "${{ env.SELENIUM_TEST_SUMMARY }}" | base64 --decode) | |
echo "### Selenium Test Results" > comment_body.md | |
echo "\`\`\`plaintext" >> comment_body.md | |
echo "$decoded_results" >> comment_body.md | |
echo "\`\`\`" >> comment_body.md | |
gh pr comment ${{ github.event.pull_request.number }} --body-file comment_body.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check maven folder | |
run: | | |
cd ~/.m2 | |
pwd | |
ls -lah . | |
ls -lah /home/runner/work/MoPat/MoPat | |
ls -lah /home/runner/work/MoPat |