jquery/.github/workflows/node.js.yml
Gabriela Gutierrez 0ea85dadaa
Build: Reference GitHub Actions by commit SHAs
The SHAs are verified to come from the original repositories and not forks.

For reference:

https://github.com/actions/checkout/releases/tag/v3.5.2
8e5e7e5ab8

https://github.com/actions/cache/releases/tag/v3.3.1
88522ab9f3

https://github.com/actions/setup-node/releases/tag/v3.6.0
64ed1c7eab

Fixes gh-5266
Closes gh-5269

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>

(cherry picked from commit 784b9ba6e4)
2023-06-13 23:30:48 +02:00

80 lines
2.8 KiB
YAML

name: CI
on: [push, pull_request]
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Node.js 10 is required by jQuery infra
# Do not remove 16.x until jsdom tests are re-enabled on newer Node.js versions.
NODE_VERSION: [10.x, 16.x, 18.x, 20.x]
NPM_SCRIPT: ["test:browserless"]
include:
- NAME: "Browser tests: full build, Chrome, Firefox & WebKit"
NODE_VERSION: "18.x"
NPM_SCRIPT: "test:browser"
BROWSERS: "ChromeHeadless,FirefoxHeadless,WebkitHeadless"
- NAME: "Browser tests: slim build, Chrome"
NODE_VERSION: "18.x"
NPM_SCRIPT: "test:slim"
BROWSERS: "ChromeHeadless"
- NAME: "Browser tests: no-deprecated build, Chrome"
NODE_VERSION: "18.x"
NPM_SCRIPT: "test:no-deprecated"
BROWSERS: "ChromeHeadless"
- NAME: "Browser tests: selector-native build, Chrome"
NODE_VERSION: "18.x"
NPM_SCRIPT: "test:selector-native"
BROWSERS: "ChromeHeadless"
- NAME: "Browser tests: AMD build, Chrome stable"
NODE_VERSION: "18.x"
NPM_SCRIPT: "test:amd"
BROWSERS: "ChromeHeadless"
- NAME: "Browser tests: full build, Firefox ESR"
NODE_VERSION: "18.x"
NPM_SCRIPT: "test:browser"
BROWSERS: "FirefoxHeadless"
steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-
- name: Use Node.js ${{ matrix.NODE_VERSION }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ matrix.NODE_VERSION }}
- name: Install firefox ESR
run: |
export FIREFOX_SOURCE_URL='https://download.mozilla.org/?product=firefox-esr-latest&lang=en-US&os=linux64'
wget --no-verbose $FIREFOX_SOURCE_URL -O - | tar -jx -C ${HOME}
if: "contains(matrix.NAME, 'Firefox ESR')"
- name: Install dependencies
run: |
npm install
- name: Install Playwright dependencies
run: npx playwright-webkit install-deps
if: "matrix.NPM_SCRIPT == 'test:browser' && contains(matrix.BROWSERS, 'WebkitHeadless')"
- name: Run tests
env:
BROWSERS: ${{ matrix.BROWSERS }}
run: |
export PATH=${HOME}/firefox:$PATH
npm run ${{ matrix.NPM_SCRIPT }}