{"id":22400098,"url":"https://github.com/currents-dev/playwright-aws-codebuild-example","last_synced_at":"2025-03-27T00:17:28.327Z","repository":{"id":207335697,"uuid":"718994188","full_name":"currents-dev/playwright-aws-codebuild-example","owner":"currents-dev","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-11T01:22:55.000Z","size":186,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T04:52:20.940Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/currents-dev.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}},"created_at":"2023-11-15T08:14:40.000Z","updated_at":"2024-06-27T20:18:40.000Z","dependencies_parsed_at":"2023-11-15T09:43:36.070Z","dependency_job_id":null,"html_url":"https://github.com/currents-dev/playwright-aws-codebuild-example","commit_stats":null,"previous_names":["currents-dev/playwright-aws-codebuild-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/currents-dev%2Fplaywright-aws-codebuild-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/currents-dev%2Fplaywright-aws-codebuild-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/currents-dev%2Fplaywright-aws-codebuild-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/currents-dev%2Fplaywright-aws-codebuild-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/currents-dev","download_url":"https://codeload.github.com/currents-dev/playwright-aws-codebuild-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245755683,"owners_count":20667027,"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":[],"created_at":"2024-12-05T08:11:23.183Z","updated_at":"2025-03-27T00:17:28.305Z","avatar_url":"https://github.com/currents-dev.png","language":"TypeScript","readme":"# 🎭 Currents - Playwright - AWS CodeBuild\n\n\u003cimg src=\"https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiNzlTU0M4NGpZdHFKTWIrTjAyak9uSGRiUDFIazVwMHZzUDJHT2ZiSlcvZ0Z3SnN5a3ZZcTNOcHhkbUU4SUtXMjMydkdEN25sWkZzN01pSjFpM0NCaTgwPSIsIml2UGFyYW1ldGVyU3BlYyI6IlVLMEpZYmJCL21acjZNeVIiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D\u0026branch=main\" /\u003e\n\nThis repository showcases running [Playwright](https://playwright.dev/) tests on AWS CodeBuild in parallel while using [Currents](https://currents.dev) as the reporting dashboard.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"830\" src=\"https://static.currents.dev/currents-playwright-banner-gh.png\" /\u003e\n\u003c/p\u003e\n\n## Documentation\n\nThe repo contains a few Playwright tests, one test always fails (intentionally) for demonstration.\n\nThe example [buildspec.yml](https://github.com/currents-dev/aws-codebuild-example/blob/main/buildspec.yml) defines a configuration for running Playwright tests in parallel mode using 3 workers in [matrix mode](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build.html#batch_build_matrix). The example is designed to be executed as a [batch build](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build.html).\n\n## Results\n\nThe results are being reported to Currents for more efficient troubleshooting, and monitoring test suite flakiness and performance.\n\nCurrents will collect the following information:\n\n- commit details\n- console output\n- screenshots\n- videos\n- trace files\n- timing\n- outcomes\n- flaky tests\n- error details\n- tags for more convenient management of the tests\n\nThe example repository uses an AWS CodeBuild project that runs Playwright tests in parallel on 3 containers using [Playwright Sharding](https://playwright.dev/docs/test-parallel#shard-tests-between-multiple-machines).\n\nHere's an example of a build that has 1 batch job (1) triggering 3 parallel build jobs (2):\n\n![currents-2023-11-15-13 23 30@2x](https://github.com/currents-dev/playwright-aws-codebuild-example/assets/1637928/182580b2-f8c4-4ed1-9dd0-2d217c03954c)\n\nThe corresponding run in Currents dashboard:\n\nhttps://github.com/currents-dev/playwright-aws-codebuild-example/assets/1637928/9c0bc332-add2-476a-812a-645b9c56ce64\n\n## AWS Setup\n\nPlease refer to the [sample output of AWS CodeBuild project configuration](./aws-project-config-output.json) used for this demo. The output was generated using this command: `aws codebuild batch-get-projects --names playwright-currents-example`. Alternatively, follow the instructions below.\n\n### Obtain Currents Credentials\n\n- Create an organization, get your **Record Key** and **Project ID** at https://app.currents.dev.\n- Update the command in `buildspec.yml` file with the **Project ID**: e.g. `npx pwc --project-id \u003cyour-project-id\u003e ...`\n\n### Configure AWS CodeBuild Build Project\n\n#### Configure `CURRENTS_RECORD_KEY`\n\nSave the **Record Key** as `CURRENTS_RECORD_KEY` [Environment variable](https://docs.aws.amazon.com/codebuild/latest/userguide/change-project-console.html#change-project-console-environment). It is strongly recommended to use your **Record Key** in a secure secrets storage. Please refer to the [detailed guide](https://www.learnaws.org/2022/11/18/aws-codebuild-secrets-manager/), here is an overview of the steps:\n\n- Create a new entry in AWS Secrets Manager with the **Record Key**. Please note that the generated secret is a JSON document, you should note the `json_key` of the actual record key value and use it later.\n- Get the secret ARN\n- Update the Build Project environment variables as follows:\n\n  - Variable name: `CURRENTS_RECORD_KEY`\n  - Variable value: the ARN of previously created secret + json_key, for example: `\u003csecret-arn\u003e:\u003cjson-key\u003e`\n\n- Update the IAM execution role to allow reading of previously created secret\n\n#### Configure Source Batch Mode\n\n- Set the **Project Setting \u003e Edit Source**\n- Configure the repository details and the events that should trigger new builds\n- Configure **Primary source webhook events \u003e Build Type** to **Batch build** to start 3 parallel workers in [matrix mode](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build).\n\n## Playwright Parallelization / Sharding\n\nThe `buildspec.yml` file uses [matrix mode](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build) to start 3 containers for running the test in parallel. Each container will have the environment variable `WORKER` set to `1,2,3` correspondingly - we can use it to configure [Playwright Sharding](https://playwright.dev/docs/test-parallel#shard-tests-between-multiple-machines)\n\n```yml\n  build-matrix:\n    dynamic:\n      buildspec:\n        - buildspec.yml\n      env:\n        variables:\n          # Create 3 containers, each container will have the environment variable `WORKER` set to `1,2,3`\n          WORKER:\n            - 1\n            - 2\n            - 3\n\n        # and later, note the use of $WORKER env variable\n      - npx pwc --project-id bnsqNa --key $CURRENTS_RECORD_KEY --ci-build-id $CODEBUILD_INITIATOR --shard $WORKER/3\n```\n\n## CI Build ID for AWS CodeBuild\n\nThe example uses [CODEBUILD_INITIATOR](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html) as a [CI Build ID](https://currents.dev/readme/guides/cypress-ci-build-id). If you trigger the build manually, the `CODEBUILD_INITIATOR` will be set to the username of the build initiator and you can get warnings after recording multiple results for the same CI build ID.\n\nWhen a build is triggered by a push / PR (and a batched build is created), the variable will have a unique ID associated that won' trigger conflict warnings.\n\n## Using Currents Reporter\n\nThe example uses `pwc` CLI command to run the tests. You can use `npx playwright test` command and configure `@currents/playwright` as a reporter. Please refer to the [documentation](https://currents.dev/readme/integration-with-playwright/currents-playwright#currents-playwright-reporter).\n\n## Running Locally\n\nBased on: https://docs.aws.amazon.com/codebuild/latest/userguide/use-codebuild-agent.html\n\n```sh\ncurl -O  https://raw.githubusercontent.com/aws/aws-codebuild-docker-images/master/local_builds/codebuild_build.sh\nchmod +x codebuild_build.sh\n\n# For MacBook M1\n./codebuild_build.sh -i public.ecr.aws/codebuild/amazonlinux2-aarch64-standard:3.0 -l public.ecr.aws/codebuild/local-builds:aarch64\n\n# For Intel\n./codebuild_build.sh -i public.ecr.aws/codebuild/amazonlinux2-standard:3.0\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurrents-dev%2Fplaywright-aws-codebuild-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcurrents-dev%2Fplaywright-aws-codebuild-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurrents-dev%2Fplaywright-aws-codebuild-example/lists"}