Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: fisker Cheung <lionkay@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
266 lines
8.0 KiB
YAML
266 lines
8.0 KiB
YAML
name: Prod
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- next
|
|
- v*
|
|
- patch-release
|
|
- "!renovate/**"
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
uses: ./.github/workflows/_build.yml
|
|
|
|
lint:
|
|
name: Lint
|
|
runs-on: ubuntu-latest
|
|
needs: [build]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
|
with:
|
|
cache: "yarn"
|
|
|
|
- name: Install Dependencies
|
|
run: yarn install --immutable
|
|
|
|
- name: Download Artifact
|
|
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
|
|
- name: Lint Code
|
|
run: yarn test:production-lint
|
|
|
|
test:
|
|
timeout-minutes: 15
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- "ubuntu-latest"
|
|
- "macos-latest"
|
|
- "windows-latest"
|
|
node:
|
|
# Latest even version
|
|
- "24"
|
|
# Minimal version for production
|
|
- "14"
|
|
include:
|
|
- os: "ubuntu-latest"
|
|
# Pick a version that is fast (normally highest LTS version)
|
|
node: "24"
|
|
FULL_TEST: true
|
|
# Versions not tested on linux, normally only even versions
|
|
# If latest version is an odd number, it can be listed below too
|
|
- os: "ubuntu-latest"
|
|
node: "25"
|
|
- os: "ubuntu-latest"
|
|
node: "22"
|
|
- os: "ubuntu-latest"
|
|
node: "20"
|
|
- os: "ubuntu-latest"
|
|
node: "18"
|
|
- os: "ubuntu-latest"
|
|
node: "16"
|
|
# Tests on Intel Mac x Node.js 14 ( https://github.com/prettier/prettier/issues/16248 )
|
|
- os: "macos-15-intel"
|
|
node: "14"
|
|
# setup-node does not support Node.js 14 x M1 Mac
|
|
exclude:
|
|
- os: "macos-latest"
|
|
node: "14"
|
|
env:
|
|
FULL_TEST: ${{ matrix.FULL_TEST }}
|
|
name: ${{ matrix.FULL_TEST && '[Full Test] ' || '' }} Node.js ${{ matrix.node }} on ${{ startsWith(matrix.os, 'macos') && 'MacOS' || startsWith(matrix.os, 'windows') && 'Windows' || 'Linux' }}
|
|
runs-on: ${{ matrix.os }}
|
|
needs: [build]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
|
|
- name: Install yarn@3
|
|
if: ${{ matrix.node == '14' || matrix.node == '16' }}
|
|
run: |
|
|
yarn set version 3
|
|
yarn config set httpRetry 10
|
|
cat .yarnrc.yml
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
|
with:
|
|
node-version: ${{ matrix.node }}
|
|
cache: "yarn"
|
|
|
|
- name: Downgrade Jest
|
|
if: ${{ matrix.node == '14' || matrix.node == '16' }}
|
|
run: node ./scripts/prepare-test-for-legacy-nodejs.js --node-version ${{ matrix.node }}
|
|
|
|
- name: Install Dependencies(yarn@3,mutable)
|
|
if: ${{ matrix.node == '14' || matrix.node == '16' }}
|
|
env:
|
|
YARN_ENABLE_IMMUTABLE_INSTALLS: false
|
|
run: yarn install
|
|
|
|
- name: Install Dependencies
|
|
run: yarn install --immutable
|
|
|
|
- name: Download Artifact
|
|
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
|
|
- name: Run Tests
|
|
run: yarn test:production
|
|
|
|
- name: Run Format Tests (standalone)
|
|
run: yarn test:production-standalone
|
|
|
|
- name: "`--debug-benchmark` flag"
|
|
if: ${{ matrix.node != '14' && matrix.os != 'windows-latest' }}
|
|
working-directory: dist/prettier
|
|
run: node bin/prettier.cjs --debug-benchmark package.json 2>&1 >/dev/null | grep "Latency avg" || exit 1
|
|
|
|
browser:
|
|
timeout-minutes: 15
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- "ubuntu-latest"
|
|
# - "macos-latest"
|
|
- "windows-latest"
|
|
browser:
|
|
- "chrome"
|
|
- "firefox"
|
|
include:
|
|
# It's slow on firefox
|
|
- os: "ubuntu-latest"
|
|
browser: "chrome"
|
|
FULL_TEST: true
|
|
exclude:
|
|
# Hangs https://github.com/prettier/prettier/pull/18716
|
|
- os: "windows-latest"
|
|
browser: "chrome"
|
|
env:
|
|
FULL_TEST: ${{ matrix.FULL_TEST }}
|
|
TEST_RUNTIME_BROWSER: ${{ matrix.browser }}
|
|
name: ${{ matrix.FULL_TEST && '[Full Test] ' || '' }} Browser(${{ matrix.browser }}) on ${{ startsWith(matrix.os, 'macos') && 'MacOS' || startsWith(matrix.os, 'windows') && 'Windows' || 'Linux' }}
|
|
runs-on: ${{ matrix.os }}
|
|
needs: [build]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
|
with:
|
|
cache: "yarn"
|
|
|
|
- name: Puppeteer cache
|
|
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
|
with:
|
|
path: .tmp/puppeteer/
|
|
key: v1
|
|
|
|
# https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
|
|
- run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
|
|
if: matrix.os == 'ubuntu-latest'
|
|
|
|
- name: Install Dependencies
|
|
run: yarn install --immutable
|
|
|
|
- name: Download Artifact
|
|
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
|
|
- name: Run Tests (ESM)
|
|
env:
|
|
TEST_BUNDLE_FORMAT: esm
|
|
run: yarn test:production:browser
|
|
|
|
- name: Run Tests (UMD)
|
|
env:
|
|
TEST_BUNDLE_FORMAT: umd
|
|
run: yarn test:production:browser
|
|
|
|
cli:
|
|
name: CLI
|
|
runs-on: ubuntu-latest
|
|
needs: [build]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
|
|
- name: Download Artifact
|
|
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
|
with:
|
|
package-manager-cache: false
|
|
|
|
- name: "`--debug-benchmark` flag"
|
|
working-directory: dist/prettier
|
|
run: node bin/prettier.cjs --debug-benchmark package.json 2>&1 >/dev/null | grep "'--debug-benchmark' requires the 'tinybench' package to be installed." || exit 1
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
|
with:
|
|
node-version: "0.10.48"
|
|
package-manager-cache: false
|
|
|
|
- name: Validate Node.js Version
|
|
run: node -v | grep "v0.10.48" || exit 1
|
|
|
|
- name: Run CLI on Node.js v0.10.48
|
|
working-directory: dist/prettier
|
|
run: node bin/prettier.cjs --version 2>&1 >/dev/null | grep "prettier requires at least version 14 of Node, please upgrade" || exit 1
|
|
|
|
preview:
|
|
if: github.repository == 'prettier/prettier'
|
|
name: Preview release
|
|
runs-on: ubuntu-latest
|
|
needs: [build]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
|
with:
|
|
# `pkg-pr-new` requires Node.js v20
|
|
node-version: latest
|
|
|
|
- name: Download Artifact
|
|
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
|
|
- name: Release
|
|
working-directory: dist
|
|
run: |
|
|
yarn dlx pkg-pr-new publish "./*" --compact --packageManager=yarn
|