Tests: migrate testing infrastructure to minimal dependencies
[jquery.git] / .github / workflows / node.js.yml
blob902f8cc600a8613e0c51335b9c5abaa49ec61f76
1 name: Node
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-and-test:
13     runs-on: ubuntu-latest
14     name: ${{ matrix.NPM_SCRIPT }} - ${{ matrix.NAME }} (${{ matrix.NODE_VERSION }})
15     strategy:
16       fail-fast: false
17       matrix:
18         NAME: ["Node"]
19         NODE_VERSION: [18.x, 20.x]
20         NPM_SCRIPT: ["test:browserless"]
21         include:
22           - NAME: "Node"
23             NODE_VERSION: "20.x"
24             NPM_SCRIPT: "lint"
25           - NAME: "Chrome/Firefox"
26             NODE_VERSION: "20.x"
27             NPM_SCRIPT: "test:browser"
28           - NAME: "Chrome"
29             NODE_VERSION: "20.x"
30             NPM_SCRIPT: "test:slim"
31           - NAME: "Chrome"
32             NODE_VERSION: "20.x"
33             NPM_SCRIPT: "test:no-deprecated"
34           - NAME: "Chrome"
35             NODE_VERSION: "20.x"
36             NPM_SCRIPT: "test:selector-native"
37           - NAME: "Chrome"
38             NODE_VERSION: "20.x"
39             NPM_SCRIPT: "test:esm"
40           - NAME: "Firefox ESR"
41             NODE_VERSION: "20.x"
42             NPM_SCRIPT: "test:firefox"
43           - NAME: "Node 10 Build"
44             NODE_VERSION: "10.x"
45             NPM_SCRIPT: "build:main"
46     steps:
47       - name: Checkout
48         uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
50       - name: Use Node.js ${{ matrix.NODE_VERSION }}
51         uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
52         with:
53           node-version: ${{ matrix.NODE_VERSION }}
55       - name: Cache
56         uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
57         with:
58           path: ~/.npm
59           key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
60           restore-keys: |
61             ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-
63       - name: Install firefox ESR
64         run: |
65           export FIREFOX_SOURCE_URL='https://download.mozilla.org/?product=firefox-esr-latest-ssl&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: Build All for Linting
73         run: npm run build:all
74         if: contains(matrix.NPM_SCRIPT, 'lint')
76       - name: Run tests
77         run: |
78           export PATH=${HOME}/firefox:$PATH
79           export FIREFOX_BIN=${HOME}/firefox/firefox
80           npm run ${{ matrix.NPM_SCRIPT }}
82   safari:
83     runs-on: macos-latest
84     env:
85       NODE_VERSION: 20.x
86     name: test:safari - Safari
87     steps:
88       - name: Checkout
89         uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
91       - name: Use Node.js ${{ env.NODE_VERSION }}
92         uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
93         with:
94           node-version: ${{ env.NODE_VERSION }}
96       - name: Cache
97         uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
98         with:
99           path: ~/.npm
100           key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
101           restore-keys: |
102             ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-
104       - name: Install dependencies
105         run: npm install
107       - name: Run tests
108         run: npm run test:safari