Skip to content

Update code quality section page copy #125

Update code quality section page copy

Update code quality section page copy #125

name: Playwright GitHub Page (manual, pr/push)
#I'm using a different Playwright configuration for Github Actions
#because I like to have sloMo and headed mode enabled in my local
#environment so I can watch the tests run and I don't want those settings in the
#GitHub runner..otherwise I'd have an unstaged change of the config file always
#present. Having unique config files for Playwright local vs CI/CD solves the problem.
#So I created a repository variable in the GitHub repo settings and included it
#in this YAML below, and further down below you can see I used the --config flag
#and specify the variable when starting the tests
#If you go look in the root of the Playwright repo, you'll see two separate config files
env:
PLAYWRIGHT_ACTIONS_CONFIG: ${{ vars.PLAYWRIGHT_ACTIONS_CONFIG }}
on:
push:
pull_request:
workflow_dispatch:
jobs:
Playwright-GitHub-Page-Test:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Message
run: |
echo "This action executes Playwright tests against pull requests and commits"
echo "User: [${{ github.actor }}] initiated this test run"
echo "Commit subject: ${{ github.event.commits[0].message }}"
echo "Commit hash: ${{ github.sha }}"
echo "Branch: ${{ github.ref_name }}"
echo "GitHub workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# We will check out two repos because the website files
# exist in one repo and Playwright exists in a different repo
# Check out primary repo where I will start a server locally in the GH Runner environment
- name: Checkout Website Repo
uses: actions/checkout@v4.1.6
# Check out secondary repo where Playwright scripts live
- name: Checkout Playwright Repo
uses: actions/checkout@v4.1.6
with:
repository: readytotest/test-playwright
#token: ${{ secrets.GH_PAT }} If checking out a private repo, create a secret called `GH_PAT` that contains your personal access token
ref: main
path: ./playwright-tests #Copy the Playwright repo to this directory within the GitHub page repo
- name: List current directory
run: ls
- name: Install dependencies
working-directory: ./playwright-tests #This is the sub-directory where the Playwright repo was copied to
run: npm ci
- name: Setup Node.js environment with most recent version
uses: actions/setup-node@v4.0.2
with:
node-version: 'latest'
- name: Start Local Webserver in GH Runner environment (http://localhost:3000)
run: | #We need the & sleep 1 or it will hang on this step and won't progress
chmod +x start-server.sh
./start-server.sh &
sleep 1
- name: CD to playwright-tests directory, print node version, and list contents
run: |
cd playwright-tests
node -v
ls
- name: Install Playwright Browsers
working-directory: ./playwright-tests #This is the sub-directory where the Playwright repo was copied to
run: npx playwright install --with-deps
- name: Run Playwright tests
working-directory: ./playwright-tests #This is the sub-directory where the Playwright repo was copied to
#Tests against http://localhost:3000
run: npx playwright test tests/indexHtm.spec.ts --config $PLAYWRIGHT_ACTIONS_CONFIG
- name: Upload Report to GitHub
uses: actions/upload-artifact@v4.3.3
if: always()
with:
name: Test Results + Video
path: ./playwright-tests/playwright-report/
if-no-files-found: warn
retention-days: 60