2021-01-12 10:48:33 +00:00
|
|
|
name: run-checks
|
|
|
|
|
2022-02-15 14:50:51 +00:00
|
|
|
# Declare default permissions as read only.
|
|
|
|
permissions: read-all
|
|
|
|
|
2021-01-12 10:48:33 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
jobs:
|
2021-01-27 13:57:41 +00:00
|
|
|
linux-main-checks:
|
|
|
|
# https://github.com/actions/virtual-environments#available-environments
|
2021-01-12 10:48:33 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-05-17 09:34:58 +00:00
|
|
|
# Include all major maintenance + active LTS + current Node.js versions.
|
2021-01-12 10:48:33 +00:00
|
|
|
# https://github.com/nodejs/Release#release-schedule
|
2022-05-03 06:59:40 +00:00
|
|
|
node: [14, 16]
|
2021-01-12 10:48:33 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-03-02 08:30:11 +00:00
|
|
|
uses: actions/checkout@v3
|
2021-01-12 10:48:33 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 2
|
|
|
|
|
|
|
|
- name: Set up Node.js
|
2022-05-24 08:00:11 +00:00
|
|
|
uses: actions/setup-node@v3.2.0
|
2021-01-12 10:48:33 +00:00
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node }}
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
sudo apt-get install xvfb
|
|
|
|
# Ensure both a Chromium and a Firefox binary are available.
|
|
|
|
PUPPETEER_PRODUCT=firefox npm install
|
|
|
|
npm install
|
|
|
|
ls .local-chromium .local-firefox
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
npm run build
|
|
|
|
|
|
|
|
- name: Run code checks
|
|
|
|
run: |
|
2021-05-14 11:02:36 +00:00
|
|
|
npm run ensure-pinned-deps
|
2021-01-12 10:48:33 +00:00
|
|
|
npm run lint
|
2021-10-19 13:29:47 +00:00
|
|
|
# Skipping as it's flakey and we are not currently using the new documentation site in the wild yet.
|
|
|
|
# See https://github.com/puppeteer/puppeteer/issues/7710 for more info
|
|
|
|
# npm run generate-docs
|
2021-01-12 10:48:33 +00:00
|
|
|
npm run ensure-correct-devtools-protocol-revision
|
fix: wider compat TS types and CI checks to ensure correct type defs (#6855)
* fix: wider compat TS types and CI checks to ensure correct type defs
This PR improves our TS types further to make sure they are usable in a
TS environment where ES Modules are the target output. Our use of
`export =` is problematic this environment as TypeScript does not allow
`export =` to be used and it errors.
The fix for the type issues to avoid `export =` is to instead define the
functions that you gain access to when you import Puppeteer as top level
functions in our `types.d.ts` file. We can do this by declaring them
explicitly in `src/node.ts`. These are then rolled into `lib/types.d.ts`
at build time. The downside to this is that we have to keep those
declarations in sync with the Puppeteer API; should we add a new method
to the `Puppeteer` class, we must add it to the `nodes.ts` declarations.
However, this could easily be automated by a small script that walks the
AST and generates these. I will do that in a follow-up PR, but I
consider this low risk given how rarely the very top level API of
Puppeteer changes. The nice thing about this approach is we no longer
need our script that hacks on changes to `lib/types.d.ts`.
To avoid yet more releases to fix issues in one particular TS
environment, this PR also includes a suite of example setups that we
test on each CI run. Each sample folder contains `good.ts`, which should
have no TS errors, and `bad.ts`, which should have some errors. The test
first packs Puppeteer into a tar, and then installs it from that tar
into each project. This should replicate how the published package
behaves when it is installed. We then check that we get no errors on
`good.ts`, and the expected errors on `bad.ts`.
We have a variety of test projects that cover both TS and JS source
code, and CJS and ESM imports and outputs.
2021-02-10 12:04:36 +00:00
|
|
|
npm run test-types-file
|
2021-01-12 10:48:33 +00:00
|
|
|
|
2022-02-04 19:42:15 +00:00
|
|
|
- name: Run commit lint
|
|
|
|
run: |
|
|
|
|
npm run commitlint
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
|
2021-01-12 10:48:33 +00:00
|
|
|
- name: Run unit tests
|
2021-05-26 13:30:16 +00:00
|
|
|
uses: nick-invision/retry@v2
|
2021-01-12 10:48:33 +00:00
|
|
|
env:
|
|
|
|
CHROMIUM: true
|
2021-05-26 13:30:16 +00:00
|
|
|
with:
|
|
|
|
max_attempts: 3
|
|
|
|
command: xvfb-run --auto-servernum npm run unit
|
|
|
|
timeout_minutes: 10
|
2021-01-12 10:48:33 +00:00
|
|
|
|
|
|
|
- name: Run unit tests with coverage
|
|
|
|
env:
|
|
|
|
CHROMIUM: true
|
|
|
|
run: |
|
|
|
|
xvfb-run --auto-servernum npm run unit-with-coverage
|
|
|
|
xvfb-run --auto-servernum npm run assert-unit-coverage
|
|
|
|
|
2021-02-18 10:51:55 +00:00
|
|
|
- name: Run unit tests on Firefox
|
2021-05-26 13:30:16 +00:00
|
|
|
uses: nick-invision/retry@v2
|
2021-02-18 10:51:55 +00:00
|
|
|
env:
|
|
|
|
FIREFOX: true
|
|
|
|
MOZ_WEBRENDER: 0
|
2021-05-26 13:30:16 +00:00
|
|
|
with:
|
|
|
|
max_attempts: 3
|
|
|
|
timeout_minutes: 10
|
|
|
|
command: xvfb-run --auto-servernum npm run funit
|
|
|
|
|
2021-01-12 10:48:33 +00:00
|
|
|
- name: Run browser tests
|
|
|
|
run: |
|
|
|
|
npm run test-browser
|
|
|
|
|
|
|
|
- name: Test bundling and installation
|
|
|
|
env:
|
|
|
|
CHROMIUM: true
|
|
|
|
run: |
|
|
|
|
# Note: this modifies package.json to test puppeteer-core.
|
|
|
|
npm run test-install
|
|
|
|
# Undo those changes.
|
|
|
|
git checkout --force
|
2021-01-27 13:57:41 +00:00
|
|
|
|
|
|
|
macos:
|
|
|
|
# https://github.com/actions/virtual-environments#available-environments
|
|
|
|
runs-on: macos-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-03-02 08:30:11 +00:00
|
|
|
uses: actions/checkout@v3
|
2021-01-27 13:57:41 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 2
|
|
|
|
|
|
|
|
- name: Set up Node.js
|
2022-05-24 08:00:11 +00:00
|
|
|
uses: actions/setup-node@v3.2.0
|
2021-01-27 13:57:41 +00:00
|
|
|
with:
|
|
|
|
# Test only the oldest maintenance LTS Node.js version.
|
|
|
|
# https://github.com/nodejs/Release#release-schedule
|
2022-05-03 06:59:40 +00:00
|
|
|
node-version: 14
|
2021-01-27 13:57:41 +00:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
# Test platform-specific browser binary fetching for both
|
|
|
|
# Chromium and Firefox.
|
|
|
|
PUPPETEER_PRODUCT=firefox npm install
|
|
|
|
npm install
|
|
|
|
ls .local-chromium .local-firefox
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
npm run build
|
|
|
|
|
|
|
|
- name: Run unit tests
|
|
|
|
env:
|
|
|
|
CHROMIUM: true
|
|
|
|
run: |
|
|
|
|
npm run unit
|
|
|
|
|
2021-02-18 12:44:36 +00:00
|
|
|
- name: Run unit tests on Firefox
|
2021-05-26 13:30:16 +00:00
|
|
|
uses: nick-invision/retry@v2
|
|
|
|
with:
|
|
|
|
max_attempts: 3
|
|
|
|
timeout_minutes: 10
|
|
|
|
command: npm run funit
|
2021-02-18 12:44:36 +00:00
|
|
|
|
2021-01-27 13:57:41 +00:00
|
|
|
windows:
|
|
|
|
# https://github.com/actions/virtual-environments#available-environments
|
|
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-03-02 08:30:11 +00:00
|
|
|
uses: actions/checkout@v3
|
2021-01-27 13:57:41 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 2
|
|
|
|
|
|
|
|
- name: Set up Node.js
|
2022-05-24 08:00:11 +00:00
|
|
|
uses: actions/setup-node@v3.2.0
|
2021-01-27 13:57:41 +00:00
|
|
|
with:
|
|
|
|
# Test only the oldest maintenance LTS Node.js version.
|
|
|
|
# https://github.com/nodejs/Release#release-schedule
|
2022-05-03 06:59:40 +00:00
|
|
|
node-version: 14
|
2021-01-27 13:57:41 +00:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
# Test platform-specific browser binary fetching for both
|
|
|
|
# Chromium and Firefox.
|
|
|
|
$env:PUPPETEER_PRODUCT='firefox'
|
|
|
|
npm install
|
|
|
|
Remove-Item Env:\PUPPETEER_PRODUCT
|
|
|
|
npm install
|
|
|
|
Get-ChildItem -Path .local-chromium,.local-firefox
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
npm run build
|
|
|
|
|
|
|
|
- name: Run unit tests
|
|
|
|
env:
|
|
|
|
CHROMIUM: true
|
|
|
|
run: |
|
|
|
|
npm run unit
|
2021-03-05 09:00:56 +00:00
|
|
|
|
|
|
|
- name: Run unit tests on Firefox
|
2021-05-26 13:30:16 +00:00
|
|
|
uses: nick-invision/retry@v2
|
2021-10-08 15:23:06 +00:00
|
|
|
continue-on-error: true
|
2021-03-05 09:00:56 +00:00
|
|
|
env:
|
|
|
|
FIREFOX: true
|
|
|
|
MOZ_WEBRENDER: 0
|
2021-05-26 13:30:16 +00:00
|
|
|
with:
|
|
|
|
max_attempts: 3
|
|
|
|
timeout_minutes: 10
|
|
|
|
command: npm run funit
|
2022-04-22 10:40:18 +00:00
|
|
|
|
|
|
|
linux-headful-checks:
|
|
|
|
# https://github.com/actions/virtual-environments#available-environments
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
node: [16]
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 2
|
|
|
|
|
|
|
|
- name: Set up Node.js
|
2022-05-24 08:00:11 +00:00
|
|
|
uses: actions/setup-node@v3.2.0
|
2022-04-22 10:40:18 +00:00
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node }}
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
sudo apt-get install xvfb
|
2022-05-02 09:37:21 +00:00
|
|
|
# Ensure both a Chromium and a Firefox binary are available.
|
|
|
|
PUPPETEER_PRODUCT=firefox npm install
|
2022-04-22 10:40:18 +00:00
|
|
|
npm install
|
2022-05-02 09:37:21 +00:00
|
|
|
ls .local-chromium .local-firefox
|
|
|
|
|
2022-04-22 10:40:18 +00:00
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
npm run build
|
|
|
|
- name: Run unit tests in headful mode
|
|
|
|
uses: nick-invision/retry@v2
|
|
|
|
continue-on-error: true
|
|
|
|
env:
|
|
|
|
CHROMIUM: true
|
|
|
|
HEADLESS: false
|
|
|
|
with:
|
|
|
|
max_attempts: 1
|
|
|
|
command: xvfb-run --auto-servernum npm run unit
|
|
|
|
timeout_minutes: 10
|
2022-04-25 11:11:23 +00:00
|
|
|
|
|
|
|
chrome-headless-checks:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
# https://github.com/actions/virtual-environments#available-environments
|
|
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
|
|
node: [16]
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 2
|
|
|
|
- name: Set up Node.js
|
2022-05-24 08:00:11 +00:00
|
|
|
uses: actions/setup-node@v3.2.0
|
2022-04-25 11:11:23 +00:00
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node }}
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
npm install
|
|
|
|
ls .local-chromium
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
npm run build
|
|
|
|
- name: Run unit tests
|
|
|
|
uses: nick-invision/retry@v2
|
|
|
|
continue-on-error: true
|
|
|
|
env:
|
|
|
|
CHROMIUM: true
|
|
|
|
with:
|
|
|
|
max_attempts: 1
|
|
|
|
command: npm run chrome-headless-unit
|
|
|
|
timeout_minutes: 30
|