Skip to content

Commit

Permalink
Add a script to test the bundle that will be uploaded to CDN
Browse files Browse the repository at this point in the history
Add a `test:cdn_bundle` NPM script and run it in CI. This script tests
the bundle that the `.github/workflows/cdn.yml` workflow will upload to
the CDN, by checking that, when this bundle is imported by a web page,
it gives access to a working Spaces client.

The approach (using Playwright and a local web server powered by
Express) is based heavily on that used by the `test:playwright` NPM
script in ably-js at commit 83b4516. I then incorporated Dom’s
suggestion of using Playwright’s built-in test-running functionality,
taking code from his draft PR #218.
  • Loading branch information
lawrence-forooghian committed Oct 19, 2023
1 parent 60a8a0b commit fa95f9f
Show file tree
Hide file tree
Showing 18 changed files with 1,513 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
extends: ['plugin:jsdoc/recommended'],
},
],
ignorePatterns: ['dist', 'build', 'examples'],
ignorePatterns: ['dist', 'build', 'examples', 'test/ably-common'],
settings: {
jsdoc: {
tagNamePreference: {
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cdn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ jobs:
run: |
npm ci
npm run build
# Note: If you modify what we upload to the CDN, you must make sure you keep the `test:cdn-bundle` NPM script in sync with your changes.
- run: |
aws s3 cp ./dist/iife/index.bundle.js s3://${{ github.event.inputs.bucket }}/spaces/${{ github.event.inputs.version }}/iife/index.bundle.js
13 changes: 13 additions & 0 deletions .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,16 @@ jobs:
sourcePath: docs/typedoc/generated
githubToken: ${{ secrets.GITHUB_TOKEN }}
artifactName: typedoc
test-cdn-bundle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-node@v1
with:
node-version: 18
- run: npm ci
- run: npx playwright install chromium
- run: npm run build
- run: npm run test:cdn-bundle
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules/
coverage
.env
docs/typedoc/generated/
test-results/

# Local Netlify folder
.netlify
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "test/ably-common"]
path = test/ably-common
url = https://github.com/ably/ably-common.git
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/ably-common/
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ To run the Jest tests, simply run the following command:
```bash
npm test
```

### CDN bundle test

To test the bundle that we upload to the CDN:

1. Initialize submodules: `git submodule update --init`
2. Install browser for Playwright to use: `npx run playwright install chromium`
3. Build the bundle: `npm run build`
4. Run the test: `npm run test:cdn-bundle`
Loading

0 comments on commit fa95f9f

Please sign in to comment.