Skip to content

Commit

Permalink
Add Updates to yml and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafamohab committed Dec 6, 2024
1 parent fdf5d64 commit f421508
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
54 changes: 33 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Playwright Tests

'on':
pull_request:
branches:
Expand All @@ -13,73 +14,84 @@ name: Playwright Tests
- firefox
- chrome
- microsoftedge

jobs:
Custom_Linux_Grid:
runs-on: ubuntu-latest
steps:

steps:
# Step 1: Checkout the code
- name: Checkout Code
uses: actions/checkout@v4

# Step 2: Set up Node.js environment
- name: Setup Node.js env
uses: actions/setup-node@v4
with:
node-version: lts/*

# Step 3: Install Yarn (if not installed)
- name: Install Yarn
run: |
npm install -g yarn
# Step 4: Install dependencies using Yarn
- name: Install dependencies
run: |
npm install
npm install playwright
npm install typescript ts-node @types/node
yarn install
yarn add playwright
yarn add typescript ts-node @types/node
# Step 5: Install Playwright Browsers
- name: Install Playwright Browsers
run: npx playwright install --with-deps
run: yarn playwright install --with-deps

# Step 6: Log Browser Version
- name: Log Browser Version
run: >
run: |
if [ '${{ github.event.inputs.targetBrowser }}' == 'firefox' ]; then
BROWSER_VERSION=$(npx playwright show-browser firefox --version)
BROWSER_VERSION=$(yarn playwright show-browser firefox --version)
echo "Firefox Browser Version: $BROWSER_VERSION"
elif [ '${{ github.event.inputs.targetBrowser }}' == 'chrome' ]; then
BROWSER_VERSION=$(npx playwright show-browser chromium --version)
BROWSER_VERSION=$(yarn playwright show-browser chromium --version)
echo "Google Chrome Browser Version: $BROWSER_VERSION"
elif [ '${{ github.event.inputs.targetBrowser }}' == 'microsoftedge'
]; then
BROWSER_VERSION=$(npx playwright show-browser webkit --version)
elif [ '${{ github.event.inputs.targetBrowser }}' == 'microsoftedge' ]; then
BROWSER_VERSION=$(yarn playwright show-browser webkit --version)
echo "Microsoft Edge Browser Version: $BROWSER_VERSION"
else
echo "Browser not supported"
fi
# Step 7: Compile TypeScript
- name: Compile TypeScript
run: npx tsc
run: yarn tsc

# Step 8: Run Playwright Tests with xvfb-run
- name: Run Playwright Tests with xvfb-run
run: >
run: |
# Check if Xvfb is needed (for headed mode)
if [ '${{ github.event.inputs.targetBrowser }}' == 'firefox' ]
||
[ '${{ github.event.inputs.targetBrowser }}' == 'chrome' ] ||
if [ '${{ github.event.inputs.targetBrowser }}' == 'firefox' ] ||
[ '${{ github.event.inputs.targetBrowser }}' == 'chrome' ] ||
[ '${{ github.event.inputs.targetBrowser }}' == 'microsoftedge' ]; then
echo "Running tests with xvfb-run to simulate display"
xvfb-run -a npx playwright test --project="${{ github.event.inputs.targetBrowser || 'chromium' }}"
xvfb-run -a yarn playwright test --project="${{ github.event.inputs.targetBrowser || 'chromium' }}"
else
echo "Running tests headlessly"
npx playwright test --project="${{ github.event.inputs.targetBrowser || 'chromium' }}"
yarn playwright test --project="${{ github.event.inputs.targetBrowser || 'chromium' }}"
fi
# Step 9: Upload Playwright Report as Pipeline Artifact
- name: Upload Playwright Report as Pipeline Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: Playwright_Report
path: playwright-report/

# Step 10: Upload Playwright Report HTML as Pipeline Artifact
- name: Upload Playwright Report HTML as Pipeline Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: Playwright_Report_HTML
path: playwright-report/index.html
path: playwright-report/index.html
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ Tools and Technologies:
9- Github Actions

10- xvfb-run

11- Yarn

0 comments on commit f421508

Please sign in to comment.