{"id":17726528,"url":"https://github.com/atulkrsharma/playwrightinjecttagswithcaching","last_synced_at":"2025-12-30T23:15:03.623Z","repository":{"id":259355233,"uuid":"877678791","full_name":"AtulKrSharma/PlaywrightInjectTagsWithCaching","owner":"AtulKrSharma","description":"This repo shows how to inject tags in the Playwright at the runtime with cache actions","archived":false,"fork":false,"pushed_at":"2024-10-24T05:52:43.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-24T19:35:13.211Z","etag":null,"topics":["docker","github","github-actions","playwright","playwright-typescript"],"latest_commit_sha":null,"homepage":"https://github.com/AtulKrSharma/PlaywrightInjectTagsWithCaching","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AtulKrSharma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-24T03:54:44.000Z","updated_at":"2024-10-24T05:52:46.000Z","dependencies_parsed_at":"2024-10-24T19:38:01.129Z","dependency_job_id":"42530b92-779b-4c54-a281-16031148651c","html_url":"https://github.com/AtulKrSharma/PlaywrightInjectTagsWithCaching","commit_stats":null,"previous_names":["atulkrsharma/playwrightinjecttags"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtulKrSharma%2FPlaywrightInjectTagsWithCaching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtulKrSharma%2FPlaywrightInjectTagsWithCaching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtulKrSharma%2FPlaywrightInjectTagsWithCaching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtulKrSharma%2FPlaywrightInjectTagsWithCaching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AtulKrSharma","download_url":"https://codeload.github.com/AtulKrSharma/PlaywrightInjectTagsWithCaching/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246485160,"owners_count":20785245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","github","github-actions","playwright","playwright-typescript"],"created_at":"2024-10-25T17:05:42.773Z","updated_at":"2025-12-30T23:15:03.577Z","avatar_url":"https://github.com/AtulKrSharma.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Playwright Tests with Runtime Tag Injection and Caching\nThis repository demonstrates how to run Playwright tests with runtime tag injection and cache Node.js dependencies in a GitHub Actions workflow. This ensures that dependencies are only downloaded when necessary, improving CI performance.\n\n![image](https://github.com/user-attachments/assets/32585bc5-b044-4b19-a290-1d7ebb622109)\n\n\n![image](https://github.com/user-attachments/assets/7a76a25d-2cf3-420e-9411-a8de38162c2b)\n\n\nFeatures\nTag Injection at Runtime: Specify test tags (e.g., @smoke, @regression) at runtime to run specific subsets of Playwright tests.\nCaching Node.js Dependencies: Uses GitHub Actions' cache to store and reuse node_modules across runs, reducing the need to install dependencies on every workflow execution.\nHow It Works:-\n1. Tag Injection\nYou can pass a tag (such as @smoke or @regression) at runtime when triggering the GitHub Action, either through a manual workflow dispatch or during push or pull requests. This tag is then used to filter and run specific tests.\n\nBy default, the workflow will use the tag @smoke if no other tag is provided.\n\n2. Caching Dependencies\nThe workflow uses GitHub’s caching mechanism to cache node_modules, ensuring that dependencies are only installed when the package-lock.json changes. This speeds up subsequent runs by avoiding repeated downloads of dependencies.\n\nUsage\nInjecting Tags Manually\nYou can manually trigger the workflow from the GitHub Actions tab and provide a custom test tag. The default tag is @smoke if no input is provided.\n\nExample YAML Workflow\nyaml\nCopy code\nname: Playwright Tests\non:\n  push:\n    branches: [main, master]\n  pull_request:\n    branches: [main, master]\n  workflow_dispatch:  # Allows manual trigger with input\n    inputs:\n      tag:\n        description: 'Tag to run (e.g. @smoke, @regression)'\n        required: true\n        default: '@smoke'\n\njobs:\n  playwright:\n    name: \"Playwright Tests\"\n    runs-on: ubuntu-latest\n    container:\n      image: mcr.microsoft.com/playwright:v1.48.1-jammy\n      options: --user 1001\n    steps:\n      # Step 1: Checkout the code\n      - uses: actions/checkout@v4\n\n      # Step 2: Set up Node.js\n      - uses: actions/setup-node@v4\n        with:\n          node-version: lts/*\n\n      # Step 3: Cache Node.js dependencies\n      - name: Cache Node.js dependencies\n        uses: actions/cache@v4\n        with:\n          path: node_modules\n          key: node-modules-${{ hashFiles('package-lock.json') }}\n          restore-keys: |\n            node-modules-\n\n      # Step 4: Install dependencies\n      - name: Install dependencies\n        run: npm ci\n\n      # Step 5: Run Playwright tests with input tag\n      - name: Run Playwright tests\n        run: npx playwright test --grep \"${{ inputs.tag }}\"\n\n      # Step 6: Upload Playwright test report as an artifact\n      - uses: actions/upload-artifact@v4\n        if: ${{ !cancelled() }}\n        with:\n          name: playwright-report\n          path: playwright-report/\n          retention-days: 30\nKey Components\nTag Injection:\n\nThe tag is passed as an input to the GitHub Action.\nIf no tag is provided, the default tag @smoke is used.\nDependency Caching:\n\nThe actions/cache@v4 action caches the node_modules directory.\nThe cache is based on the package-lock.json file. If the package-lock.json file changes, the cache is invalidated and dependencies are re-installed.\nRunning the Workflow\nAutomatically (on Push or PR)\nWhenever you push to main or master, or open a pull request targeting these branches, the workflow runs with the default @smoke tag unless otherwise specified.\n\nManually (with Custom Tag)\nYou can manually trigger the workflow and specify a custom tag:\n\nGo to the Actions tab in your GitHub repository.\nFind the \"Playwright Tests\" workflow and click on Run workflow.\nEnter a custom tag (e.g., @regression) and run the workflow.\nLicense\nThis project is licensed under the MIT License. See the LICENSE file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkrsharma%2Fplaywrightinjecttagswithcaching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatulkrsharma%2Fplaywrightinjecttagswithcaching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkrsharma%2Fplaywrightinjecttagswithcaching/lists"}