name: Prod on: push: branches: - main - patch-release - next 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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Setup Node.js uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 with: cache: "yarn" - name: Install Dependencies run: yarn install --immutable - name: Download Artifact uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - 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@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.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@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 with: name: dist path: dist - name: Run Tests if: matrix.node != '14' run: yarn test:production - name: Run Tests (Node.js 14) if: matrix.node == '14' run: yarn test:production-node14 - name: Run Format Tests (standalone) if: matrix.node != '14' run: yarn test:production-standalone - name: Run Format Tests (standalone, Node.js 14) if: matrix.node == '14' run: yarn test:production-standalone-node14 cli: name: CLI runs-on: ubuntu-latest needs: [build] steps: - name: Checkout uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Setup Node.js uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 with: node-version: "0.10.48" package-manager-cache: false - name: Download Artifact uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 with: name: dist path: dist - name: Validate Node.js Version run: node -v | grep "v0.10.48" || exit 1 - name: Run CLI on Node.js v0.10.48 run: node dist/prettier/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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 # `pkg-pr-new` requires Node.js v20 - name: Setup Node.js uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 with: node-version: latest - name: Download Artifact uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 with: name: dist path: dist - name: Release # Use `--compact` after we publish `@prettier/plugin-oxc` # run: | # yarn dlx pkg-pr-new publish "./dist/*" --compact --packageManager=yarn run: | yarn dlx pkg-pr-new publish "./dist/*" --packageManager=yarn