aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/node.js.yml
blob: 23a5d02b1bcce24f0df8425963b503d0db7ee898 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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, 14.x, 16.x, 18.x, 19.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@v3

    - name: Cache
      uses: actions/cache@v3
      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@v3.5.1
      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'"

    - name: Run tests
      env:
        BROWSERS: ${{ matrix.BROWSERS }}
      run: |
        export PATH=${HOME}/firefox:$PATH
        npm run ${{ matrix.NPM_SCRIPT }}