-
Couldn't load subscription status.
- Fork 9
[MOB-12020] playwright GitHub actions setup #536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ffce020
add playwright to ci.yml
jyu115 6b3513b
add readme about playwright CI
jyu115 8d2c4f2
Fix corrupted yarn.lock file
jyu115 9cbb53d
add failsafe step for lockfile regeneration
jyu115 757a66f
add jwt_generator to .env
jyu115 edbe7b7
fix yarn command
jyu115 9adad4e
fix webpack parsing error
jyu115 39da37b
fix test
jyu115 d952ade
set permissions according to best practice
jyu115 38c25a4
cache browsers to optimize CI resources
jyu115 98024bf
increase worker count to 2
jyu115 8f45764
test: Fix Node PATH in Git hooks
jyu115 2923dc4
test: verify node path fix
jyu115 6f5f5cd
cleanup: remove test file
jyu115 a9e6dfc
refactor basepage
jyu115 f382e7d
fix typo
jyu115 ed111b0
fix auth test
jyu115 d0047df
refactor: add server mgmt, enhanced reporting, improved caching
jyu115 49d7a83
update right version for wait-on
jyu115 9449464
try again
jyu115 7be69f4
remove redundant config and optimize browser installation
jyu115 11d1339
optimize browser installation more
jyu115 677e414
tweak and optimize CI config
jyu115 721483f
finetune playwright configs
jyu115 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,8 @@ | |
| - name: Use Node.js 18.12.0 | ||
| uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | ||
| with: | ||
| node-version: '18.12.0' | ||
| cache: 'yarn' | ||
| node-version: "18.12.0" | ||
| cache: "yarn" | ||
| - run: yarn install --frozen-lockfile | ||
| - run: yarn prepublishOnly | ||
| - run: node index.node.js | ||
|
|
@@ -31,3 +31,68 @@ | |
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| - run: yarn check-deps | ||
|
|
||
| e2e-tests: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
|
|
||
| strategy: | ||
| matrix: | ||
| browser: [chromium, firefox, webkit] | ||
| fail-fast: false | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
| - name: Use Node.js 18.12.0 | ||
| uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | ||
| with: | ||
| node-version: "18.12.0" | ||
| cache: "yarn" | ||
| - run: yarn install --frozen-lockfile | ||
| - run: yarn prepublishOnly | ||
| - name: Install React example dependencies | ||
| working-directory: ./react-example | ||
| run: yarn install --frozen-lockfile | ||
| - name: Install Playwright browsers | ||
| working-directory: ./react-example | ||
| run: yarn playwright install --with-deps ${{ matrix.browser }} | ||
| - name: Create environment configuration | ||
| working-directory: ./react-example | ||
| run: | | ||
| cat > .env << 'EOF' | ||
| API_KEY=${{ secrets.ITERABLE_API_KEY }} | ||
| JWT_SECRET=${{ secrets.JWT_SECRET }} | ||
| USE_JWT=true | ||
| [email protected] | ||
| EOF | ||
| - name: Build React example app | ||
| working-directory: ./react-example | ||
| run: yarn build | ||
| - name: Start React example server | ||
| working-directory: ./react-example | ||
| run: | | ||
| npx webpack serve --config webpack.config.js --port 8080 & | ||
| for i in {1..15}; do | ||
| if curl -f http://localhost:8080 >/dev/null 2>&1; then | ||
| echo "Server is ready" | ||
| break | ||
| fi | ||
| if [ $i -eq 15 ]; then | ||
| echo "Server failed to start after 75 seconds" | ||
| exit 1 | ||
| fi | ||
| echo "Waiting for server... (attempt $i/15)" | ||
| sleep 5 | ||
| done | ||
| - name: Run Playwright tests | ||
| working-directory: ./react-example | ||
| run: yarn playwright test --project=${{ matrix.browser }} | ||
| env: | ||
| CI: true | ||
| - name: Upload Playwright report | ||
| uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: playwright-report-${{ matrix.browser }} | ||
| path: react-example/playwright-report/ | ||
| retention-days: 30 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2740,6 +2740,73 @@ yarn start # In one terminal | |
| yarn playwright # In another terminal | ||
| ``` | ||
|
|
||
| ## CI/CD with GitHub Actions | ||
|
|
||
| The project uses GitHub Actions for continuous integration, including automated Playwright E2E testing across multiple browsers. | ||
|
|
||
| ### CI Pipeline Overview | ||
|
|
||
| The CI pipeline (`/.github/workflows/ci.yml`) runs: | ||
|
|
||
| 1. **Unit Tests**: SDK build verification and Jest unit tests | ||
| 2. **E2E Tests**: Playwright tests across Chromium, Firefox, and WebKit browsers | ||
|
|
||
| ### Playwright CI Configuration | ||
|
|
||
| The E2E tests run automatically on every push and pull request: | ||
|
|
||
| - **Browsers**: Tests run simultaneously on Chromium, Firefox, and WebKit | ||
| - **Environment**: Automatically configured with test API keys | ||
| - **Reports**: Test results and screenshots are uploaded as artifacts | ||
| - **Retry Strategy**: Failed tests are retried twice on CI | ||
|
|
||
| ### Required GitHub Secrets | ||
|
|
||
| The repository uses these configured secrets for Playwright E2E testing in CI: | ||
|
|
||
| - **`ITERABLE_API_KEY`**: Iterable web API key for SDK authentication during testing | ||
| - **`JWT_SECRET`**: JWT secret associated with the API key for token generation | ||
|
|
||
| These secrets are already configured in the repository's GitHub Actions settings. They enable the CI environment to authenticate with Iterable's API and test SDK functionality with real API endpoints. | ||
|
|
||
| **Test Configuration Details:** | ||
| - **Default Test User**: `[email protected]` is used as the default test user for CI testing | ||
| - **Test Project**: The API_KEY uses Iterable's production test project: | ||
| - **Project**: Mobile SDK Test (Do Not Delete) (Project ID: 1226) | ||
| - **URL**: https://app.iterable.com/campaigns/manage?projectId=1226 | ||
|
|
||
| > **Note for developers**: If you need to update these secrets or configure them in a fork, go to Repository Settings β Secrets and variables β Actions and update the values accordingly. | ||
|
|
||
| ### CI Environment Configuration | ||
|
|
||
| During CI execution, the environment is automatically configured with: | ||
|
|
||
| ```bash | ||
| API_KEY=${{ secrets.ITERABLE_API_KEY }} | ||
| JWT_SECRET=${{ secrets.JWT_SECRET }} | ||
| USE_JWT=true | ||
| [email protected] | ||
| ``` | ||
|
|
||
| ### Features Tested in CI | ||
|
|
||
| The automated tests cover: | ||
|
|
||
| - **Authentication**: Login form functionality and user management | ||
| - **Navigation**: All app sections (Commerce, Events, Users, InApp, Embedded) | ||
| - **UUA Testing**: Unknown user activation and consent management | ||
| - **Core SDK Integration**: Proper initialization and configuration | ||
|
|
||
| ### Accessing CI Results | ||
|
|
||
| After CI runs, you can: | ||
|
|
||
| - View test results in the GitHub Actions tab | ||
| - Download test reports and screenshots from artifacts | ||
| - Debug failed tests using uploaded traces and videos | ||
|
|
||
| For detailed troubleshooting and local development setup, see the [E2E Testing Guide](./react-example/e2e/README.md). | ||
|
|
||
| # Contributing | ||
|
|
||
| Looking to contribute? Please see the [contributing instructions here](./CONTRIBUTING.md) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.