Playwright Tests #154
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: Playwright Tests | |
on: | |
schedule: | |
# Playwright tests are running automatically in Firefox on each Monday & in Chromium on each Friday. | |
- cron: '0 5 * * 1,5' | |
workflow_dispatch: | |
inputs: | |
Browsers: | |
description: Browsers | |
required: true | |
default: firefox | |
type: choice | |
options: | |
- firefox | |
- chromium | |
TestSuite: | |
description: Test Suite to run | |
required: true | |
default: All | |
type: choice | |
options: | |
- All | |
- homePageTests | |
- topNavbarTests | |
- footerSectionTests | |
- contributePagesTests | |
- messagingSystem | |
- User Pages | |
- contactSupportPage | |
- productSolutionsPage | |
- productSupportPage | |
- productTopicsPage | |
- AAQ | |
- KB Articles | |
- kbRestrictedVisibility | |
- KB Article Translation | |
- recentRevisionsDashboard | |
- kbDashboard | |
- exploreByTopics | |
- searchTests | |
- userGroupsTests | |
- antiSpamTests | |
env: | |
TEST_ACCOUNT_12: ${{secrets.AUTOMATION_TEST_ACCOUNT_12}} | |
TEST_ACCOUNT_13: ${{secrets.AUTOMATION_TEST_ACCOUNT_13}} | |
TEST_ACCOUNT_MESSAGE_1: ${{secrets.AUTOMATION_TEST_ACCOUNT_MESSAGE_1}} | |
TEST_ACCOUNT_MESSAGE_2: ${{secrets.AUTOMATION_TEST_ACCOUNT_MESSAGE_2}} | |
TEST_ACCOUNT_MESSAGE_3: ${{secrets.AUTOMATION_TEST_ACCOUNT_MESSAGE_3}} | |
TEST_ACCOUNT_MESSAGE_4: ${{secrets.AUTOMATION_TEST_ACCOUNT_MESSAGE_4}} | |
TEST_ACCOUNT_MESSAGE_5: ${{secrets.AUTOMATION_TEST_ACCOUNT_MESSAGE_5}} | |
TEST_ACCOUNT_MESSAGE_6: ${{secrets.AUTOMATION_TEST_ACCOUNT_MESSAGE_6}} | |
TEST_ACCOUNT_SPECIAL_CHARS: ${{secrets.AUTOMATION_TEST_ACCOUNT_SPECIAL_CHARS}} | |
TEST_ACCOUNTS_PS: ${{secrets.AUTOMATION_ACCOUNTS_PASSWORD}} | |
TEST_ACCOUNT_MODERATOR: ${{secrets.AUTOMATION_MODERATOR_ACCOUNT}} | |
BROWSER: ${{secrets.BROWSER}} | |
DATABASE_URL: postgres://kitsune:kitsune@postgres:5432/kitsune | |
SECRET_KEY: secret | |
REDIS_DEFAULT_URL=: edis://redis:6379/1 | |
REDIS_HELPFULVOTES_URL: redis://redis:6379/2 | |
jobs: | |
playwright_tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
if: success() || failure() | |
run: | | |
sudo apt-get update | |
pip3 install --user poetry | |
poetry install | |
- name: Download NLTK Data | |
run: | | |
poetry run python -m nltk.downloader wordnet omw-1.4 | |
- name: Ensure Playwright browsers are installed | |
run: | | |
pip3 install playwright | |
python -m playwright install | |
- name: Set up browsers env | |
if: "github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'" | |
run: | | |
if [ "${{ github.event_name }}" == 'schedule' ]; then | |
current_day=$(date +\%u) | |
if [ $current_day -eq 1 ]; then | |
echo "BROWSER=firefox" >> $GITHUB_ENV | |
elif [ $current_day -eq 5 ]; then | |
echo "BROWSER=chromium" >> $GITHUB_ENV | |
fi | |
elif [ "${{ github.event_name }}" == 'workflow_dispatch' ]; then | |
echo "BROWSER=${{inputs.Browsers}}" >> $GITHUB_ENV | |
fi | |
- name: Creating User Sessions for ${{ env.BROWSER }} | |
id: create-sessions | |
working-directory: playwright_tests | |
run: | | |
poetry run pytest -m loginSessions --browser ${{ env.BROWSER }} --reruns 1 | |
- name: Run ${{inputs.TestSuite}} Playwright Tests | |
working-directory: playwright_tests | |
if: success() || failure() && steps.create-sessions.outcome == 'success' | |
run: | | |
declare dispatch_test_suite="${{inputs.TestSuite}}" | |
declare all_test_suites=("homePageTests" "topNavbarTests" "footerSectionTests" "contributePagesTests" "messagingSystem" "messagingSystemCleanup" "userContributionTests" "userProfile" "userSettings" "editUserProfileTests" "userQuestions" "contactSupportPage" "productSolutionsPage" "productSupportPage" "productTopicsPage" "aaqPage" "postedQuestions" "kbProductsPage" "kbArticleCreationAndAccess" "beforeThreadTests" "articleThreads" "afterThreadTests" "kbArticleShowHistory" "recentRevisionsDashboard" "kbDashboard" "kbRestrictedVisibility" "kbArticleTranslation" "exploreByTopics" "searchTests" "userGroupsTests", "antiSpamTests") | |
if [ "$dispatch_test_suite" == "All" ] || [ "${{ github.event_name}}" == "schedule" ] ; then | |
for test in "${all_test_suites[@]}"; do | |
if ! poetry run pytest -m ${test} --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2; then | |
any_failures=true | |
fi | |
done | |
elif [ "$dispatch_test_suite" == "User Pages" ]; then | |
for test in "userContributionTests" "userProfile" "userSettings" "editUserProfileTests" "userQuestions"; do | |
if ! poetry run pytest -m ${test} --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2; then | |
any_failures=true | |
fi | |
done | |
elif [ "$dispatch_test_suite" == "AAQ" ]; then | |
for test in "aaqPage" "postedQuestions"; do | |
if ! poetry run pytest -m ${test} --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2; then | |
any_failures=true | |
fi | |
done | |
elif [ "$dispatch_test_suite" == "KB Articles" ]; then | |
for test in "kbProductsPage" "kbArticleCreationAndAccess" "beforeThreadTests" "articleThreads" "afterThreadTests" "kbArticleShowHistory"; do | |
if ! poetry run pytest -m ${test} --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2; then | |
any_failures=true | |
fi | |
done | |
elif [ "$dispatch_test_suite" == "KB Article Translation" ]; then | |
if ! poetry run pytest -m kbArticleTranslation --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2; then | |
any_failures=true | |
fi | |
else | |
if ! poetry run pytest -m $dispatch_test_suite --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2; then | |
any_failures=true | |
fi | |
fi | |
echo "TESTS_FAILED=$any_failures" >> $GITHUB_ENV | |
- name: Generating Allure Report | |
working-directory: playwright_tests | |
if: success() || failure() | |
run: | | |
curl -o allure-2.32.0.tgz -L https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.32.0/allure-commandline-2.32.0.tgz | |
tar -zxvf allure-2.32.0.tgz | |
export PATH=$PATH:$PWD/allure-2.32.0/bin | |
allure generate --single-file reports/allure_reports | |
- name: Upload the combined test report as artifact | |
if: success() || failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Playwright test report | |
path: | | |
playwright_tests/allure-report | |
- name: Playwright Test Status | |
if: env.TESTS_FAILED == 'true' | |
run: exit 1 |