chore(deps): update dev dependencies and refresh snapshots (#681) #833
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: minimizer-webpack-plugin | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - next | |
| pull_request: | |
| branches: | |
| - main | |
| - next | |
| permissions: | |
| contents: read | |
| jobs: | |
| lint: | |
| name: Lint - ${{ matrix.os }} - Node v${{ matrix.node-version }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| node-version: [lts/*] | |
| runs-on: ${{ matrix.os }} | |
| concurrency: | |
| group: lint-${{ matrix.os }}-v${{ matrix.node-version }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Lint | |
| run: npm run lint | |
| - name: Build types | |
| run: npm run build:types | |
| - name: Check types | |
| run: if [ -n "$(git status types --porcelain)" ]; then echo "Missing types. Update types by running 'npm run build:types'"; exit 1; else echo "All types are valid"; fi | |
| - name: Security audit | |
| run: npm run security | |
| test: | |
| name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| node-version: [10.x, 12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x] | |
| webpack-version: [latest] | |
| runs-on: ${{ matrix.os }} | |
| concurrency: | |
| group: test-${{ matrix.os }}-v${{ matrix.node-version }}-${{ matrix.webpack-version }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| steps: | |
| - name: Setup Git | |
| if: matrix.os == 'windows-latest' | |
| run: git config --global core.autocrlf input | |
| - name: Checkout Repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| id: calculate_architecture | |
| with: | |
| result-encoding: string | |
| script: | | |
| if ('${{ matrix.os }}' === 'macos-latest' && ('${{ matrix['node-version'] }}' === '10.x' || '${{ matrix['node-version'] }}' === '12.x' || '${{ matrix['node-version'] }}' === '14.x')) { | |
| return "x64" | |
| } else { | |
| return '' | |
| } | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| architecture: ${{ steps.calculate_architecture.outputs.result }} | |
| cache: "npm" | |
| - name: Pin older jest in package.json (Node 10/12) | |
| if: matrix.node-version == '10.x' || matrix.node-version == '12.x' | |
| shell: bash | |
| # Rewrite the jest devDependency before installing so npm resolves a | |
| # consistent @jest/* tree. jest@30 only supports Node >=18.14. | |
| run: | | |
| node -e "const fs=require('fs');const p=require('./package.json');p.devDependencies.jest='^27.5.1';fs.writeFileSync('./package.json',JSON.stringify(p,null,2)+'\n');" | |
| - name: Pin older jest in package.json (Node 14/16) | |
| if: matrix.node-version == '14.x' || matrix.node-version == '16.x' | |
| shell: bash | |
| run: | | |
| node -e "const fs=require('fs');const p=require('./package.json');p.devDependencies.jest='^29.7.0';fs.writeFileSync('./package.json',JSON.stringify(p,null,2)+'\n');" | |
| - name: Install dependencies (old) | |
| run: | | |
| npm install -D typescript@4 --force | |
| npm install --ignore-scripts --force | |
| if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '14.x' || matrix.node-version == '16.x' || matrix.node-version == '18.x' | |
| - name: Install dependencies | |
| run: npm ci | |
| if: matrix.node-version != '10.x' && matrix.node-version != '12.x' && matrix.node-version != '14.x' && matrix.node-version != '16.x' && matrix.node-version != '18.x' | |
| - name: Install older cssnano (Node 10/12) | |
| if: matrix.node-version == '10.x' || matrix.node-version == '12.x' | |
| run: npm install -D --no-save cssnano@^5 --force | |
| - name: Install older cssnano (Node 14/16) | |
| if: matrix.node-version == '14.x' || matrix.node-version == '16.x' | |
| run: npm install -D --no-save cssnano@^6 --force | |
| - name: Install older memfs (Node 10/12) | |
| # memfs@4 uses optional chaining / nullish coalescing and isn't | |
| # transpiled by babel-jest (node_modules is ignored), so it can't be | |
| # parsed on Node 10/12. v3 still supports legacy Node and produces the | |
| # same in-memory output, so it doesn't affect snapshots. | |
| if: matrix.node-version == '10.x' || matrix.node-version == '12.x' | |
| run: npm install -D --no-save memfs@^3.6.0 --force | |
| - name: Pin terser to the locked version (Node 10/12/14) | |
| # npm 6 (bundled with Node <= 14) can't read the lockfileVersion 3 | |
| # package-lock.json, so the install step re-resolves `terser` to the | |
| # latest match of its range instead of the locked version (and | |
| # rewrites package-lock.json to v1 in the process). A newer terser | |
| # changes the minified output, which breaks the snapshots. Read the | |
| # locked version from the pristine committed lockfile and reinstall | |
| # that exact version so these rows match the snapshots. | |
| if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '14.x' | |
| shell: bash | |
| run: | | |
| git show HEAD:package-lock.json > pristine-package-lock.json | |
| TERSER_VERSION="$(node -e "process.stdout.write(require('./pristine-package-lock.json').packages['node_modules/terser'].version)")" | |
| rm -f pristine-package-lock.json | |
| npm install -D --no-save --ignore-scripts --force "terser@${TERSER_VERSION}" | |
| - name: Install webpack ${{ matrix.webpack-version }} | |
| if: matrix.webpack-version != 'latest' | |
| run: npm i webpack@${{ matrix.webpack-version }} | |
| - name: Run tests for webpack version ${{ matrix.webpack-version }} | |
| # Skip tests whose minimizers can't run on the current Node version | |
| # (`-t` is a Jest test-name pattern with a negative lookahead). | |
| # `swcMinify`/`swcMinifyHtml`/`swcMinifyCss` need @swc/* binaries that | |
| # aren't available on Node 10/12; `htmlMinifierTerser` requires Node | |
| # 14.13+; `esbuildMinify`/`esbuildMinifyCss` require Node 18+. | |
| # | |
| # `-u` is passed alongside the filter so Jest doesn't fail the CI run | |
| # over the snapshots whose owning tests are skipped by `-t` (Jest | |
| # treats them as obsolete when stdin isn't a TTY). The change is local | |
| # to the runner and never committed, so strict snapshot validation | |
| # still happens on the Node 18+ rows that run the full suite. | |
| shell: bash | |
| run: | | |
| case "${{ matrix.node-version }}" in | |
| 10.x|12.x) | |
| npm run test:coverage -- --ci -u -t '^(?!.*(swcMinify|esbuildMinify|htmlMinifierTerser)).*$' | |
| ;; | |
| 14.x|16.x) | |
| npm run test:coverage -- --ci -u -t '^(?!.*esbuildMinify).*$' | |
| ;; | |
| *) | |
| npm run test:coverage -- --ci | |
| ;; | |
| esac | |
| - name: Submit coverage data to codecov | |
| uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} |