From 968dc9c6ac19cee34d842480b12c555aa3afb8e8 Mon Sep 17 00:00:00 2001 From: Pramod Kumar Yadav Date: Mon, 29 Jan 2024 13:21:48 +0100 Subject: [PATCH 1/6] Fixes warning in github action: Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v3, actions/setup-node@v3, actions/upload-artifact@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/. --- .github/workflows/playwright.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 5156520..6435081 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -9,8 +9,8 @@ jobs: timeout-minutes: 60 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: 18 - name: Install dependencies @@ -19,7 +19,7 @@ jobs: run: npx playwright install --with-deps - name: Run Playwright tests run: npx playwright test - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: name: playwright-report From d00b71d6cd79f29156ab1ecee10fbd8171287b75 Mon Sep 17 00:00:00 2001 From: Pramod Kumar Yadav Date: Tue, 30 Jan 2024 11:59:30 +0100 Subject: [PATCH 2/6] - Added steps to make html test report available on GitHub pages for easy access. - Also updated Readme file with necessary instructions. --- .github/workflows/playwright.yml | 85 +++++++++++++++++++++++++------- README.md | 15 ++++-- 2 files changed, 79 insertions(+), 21 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 6435081..4e1f658 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,27 +1,76 @@ -name: Playwright Tests +# Simple workflow for running tests and deploying static html test reports to GitHub Pages +name: Test and Publish results to GitHub Pages + on: + # Runs on pushes targeting the default branch push: - branches: [ main ] + branches: ["main"] + + # Runs on pull requests to the default branch. actions/deploy-pages step would be skipped for PRs. pull_request: branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Grant GITHUB_TOKEN the permissions required to make a Pages deployment +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + jobs: test: timeout-minutes: 60 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npx playwright test - - uses: actions/upload-artifact@v4 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install project dependencies + run: npm ci + + - name: Install Playwright Browsers + run: npx playwright install --with-deps + + - name: Run Playwright tests + run: npx playwright test + + - name: Setup and Enable Pages + if: always() + uses: actions/configure-pages@v4 + + - name: Upload artifact playwright-report + if: always() + uses: actions/upload-pages-artifact@v3 + with: + path: 'playwright-report' + + # Publish test results job + publish-results: + # Add a dependency to the test job + needs: test + if: always() + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + # Specify runner + deployment step + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action diff --git a/README.md b/README.md index bfc8eb6..d442a1a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This repo is used to demonstrate various testing scenarios with [Playwright](https://playwright.dev/) 🎭 with Node.js. -## Run Playwright example tests +## 🚀 Getting started ### Install dependencies @@ -12,13 +12,22 @@ Start by cloning the repo and installing the dependencies: npm install ``` + ### Run Playwright example tests Use the [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) to run the tests in the tests folder from VS Code or run the following command in the terminal: ```bash npx playwright test --ui ``` -## Contributing +## 🐞 Playwright Test report + +Test report URL for the latest run in CI is available in the run itself and here: https://microsoft.github.io/playwright-examples/ + +> [!NOTE] +> For the above report to be available, as a one time measure, a project admin or maintainer has to manually enable `Pages` settings to use `GithHub Actions` as a source for `Build and Deployment`. The detailed steps are mentioned in github official docs [here: Required steps are from step 1 till 4. Step 5 is to be skipped, since we already have workflow in our repository](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow). + + +## 🫱🏻‍🫲🏾 Contributing This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us @@ -32,7 +41,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. -## Trademarks +## ™ Trademarks This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow From ecb0e0faf3d80738b9a768566733e3a95b8d0e6d Mon Sep 17 00:00:00 2001 From: Pramod Kumar Yadav Date: Tue, 30 Jan 2024 12:51:16 +0100 Subject: [PATCH 3/6] reformated notes --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d442a1a..9ba67f6 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ npx playwright test --ui Test report URL for the latest run in CI is available in the run itself and here: https://microsoft.github.io/playwright-examples/ > [!NOTE] -> For the above report to be available, as a one time measure, a project admin or maintainer has to manually enable `Pages` settings to use `GithHub Actions` as a source for `Build and Deployment`. The detailed steps are mentioned in github official docs [here: Required steps are from step 1 till 4. Step 5 is to be skipped, since we already have workflow in our repository](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow). +> - For the above report to be available, as a one time measure, a project admin or maintainer has to manually enable `Pages` settings to use `GithHub Actions` as a source for `Build and Deployment`. +> - The detailed steps are mentioned in github official docs [here: Required steps are from step 1 till 4. Step 5 is to be skipped, since we already have workflow in our repository](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow). ## 🫱🏻‍🫲🏾 Contributing From 584a8c1b7a4c3354dca822645fa98c18d9bb03cd Mon Sep 17 00:00:00 2001 From: Pramod Kumar Yadav Date: Tue, 30 Jan 2024 12:52:10 +0100 Subject: [PATCH 4/6] remove extra space --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9ba67f6..a09a093 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,6 @@ Test report URL for the latest run in CI is available in the run itself and here > - For the above report to be available, as a one time measure, a project admin or maintainer has to manually enable `Pages` settings to use `GithHub Actions` as a source for `Build and Deployment`. > - The detailed steps are mentioned in github official docs [here: Required steps are from step 1 till 4. Step 5 is to be skipped, since we already have workflow in our repository](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow). - ## 🫱🏻‍🫲🏾 Contributing This project welcomes contributions and suggestions. Most contributions require you to agree to a From bb57e73a8568db68f099d04eda3ea1f056cea336 Mon Sep 17 00:00:00 2001 From: Pramod Kumar Yadav Date: Tue, 30 Jan 2024 12:52:57 +0100 Subject: [PATCH 5/6] remove extra space --- .github/workflows/playwright.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index b91bd4d..4e1f658 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -74,4 +74,3 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action - \ No newline at end of file From b125a3888bbc18382f46838ab5886a88fd31e807 Mon Sep 17 00:00:00 2001 From: Pramod Kumar Yadav Date: Tue, 30 Jan 2024 13:03:14 +0100 Subject: [PATCH 6/6] add reference info in workflow --- .github/workflows/playwright.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 4e1f658..4772567 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,4 +1,5 @@ # Simple workflow for running tests and deploying static html test reports to GitHub Pages +# Reference: https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow name: Test and Publish results to GitHub Pages on: