Build: Bump actions/cache & github/codeql-action (#5402)
[jquery.git] / .github / workflows / node.js.yml
blob443bd2b206152d39d1411bf10a48fcf53506013e
1 name: CI
3 on:
4   pull_request:
5   push:
6     branches-ignore: "dependabot/**"
8 permissions:
9   contents: read # to fetch code (actions/checkout)
11 jobs:
12   build:
13     runs-on: ubuntu-latest
14     strategy:
15       fail-fast: false
16       matrix:
17         # Node.js 10 is required by jQuery infra
18         # Do not remove 16.x until jsdom tests are re-enabled on newer Node.js versions.
19         NODE_VERSION: [10.x, 16.x, 18.x, 20.x]
20         NPM_SCRIPT: ["test:browserless"]
21         include:
22           - NAME: "Browser tests: full build, Chrome, Firefox & WebKit"
23             NODE_VERSION: "18.x"
24             NPM_SCRIPT: "test:browser"
25             BROWSERS: "ChromeHeadless,FirefoxHeadless,WebkitHeadless"
26           - NAME: "Browser tests: slim build, Chrome"
27             NODE_VERSION: "18.x"
28             NPM_SCRIPT: "test:slim"
29             BROWSERS: "ChromeHeadless"
30           - NAME: "Browser tests: no-deprecated build, Chrome"
31             NODE_VERSION: "18.x"
32             NPM_SCRIPT: "test:no-deprecated"
33             BROWSERS: "ChromeHeadless"
34           - NAME: "Browser tests: selector-native build, Chrome"
35             NODE_VERSION: "18.x"
36             NPM_SCRIPT: "test:selector-native"
37             BROWSERS: "ChromeHeadless"
38           - NAME: "Browser tests: ES modules build, Chrome"
39             NODE_VERSION: "18.x"
40             NPM_SCRIPT: "test:esmodules"
41             BROWSERS: "ChromeHeadless"
42           - NAME: "Browser tests: full build, Firefox ESR"
43             NODE_VERSION: "18.x"
44             NPM_SCRIPT: "test:browser"
45             BROWSERS: "FirefoxHeadless"
46     steps:
47       - name: Checkout
48         uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
50       - name: Cache
51         uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
52         with:
53           path: ~/.npm
54           key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
55           restore-keys: |
56             ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-
58       - name: Use Node.js ${{ matrix.NODE_VERSION }}
59         uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
60         with:
61           node-version: ${{ matrix.NODE_VERSION }}
63       - name: Install firefox ESR
64         run: |
65           export FIREFOX_SOURCE_URL='https://download.mozilla.org/?product=firefox-esr-latest&lang=en-US&os=linux64'
66           wget --no-verbose $FIREFOX_SOURCE_URL -O - | tar -jx -C ${HOME}
67         if: contains(matrix.NAME, 'Firefox ESR')
69       - name: Install dependencies
70         run: npm install
72       - name: Install Playwright dependencies
73         run: npx playwright-webkit install-deps
74         if: matrix.NPM_SCRIPT == 'test:browser' && contains(matrix.BROWSERS, 'WebkitHeadless')
76       - name: Lint code
77         run: npm run build:all && npm run lint
78         if: matrix.NODE_VERSION == '18.x'
80       - name: Run tests
81         env:
82           BROWSERS: ${{ matrix.BROWSERS }}
83         run: |
84           export PATH=${HOME}/firefox:$PATH
85           npm run ${{ matrix.NPM_SCRIPT }}