Switch to the new Prettier VSCode extension #2862
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: CI | |
| on: [push, pull_request] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| prepare-yarn-cache: | |
| name: Prepare Cache | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: 'Check or update Yarn cache (fix w/ "yarn install")' | |
| env: | |
| YARN_ENABLE_HARDENED_MODE: true # enable hardened mode as CI may run on untrusted repos | |
| YARN_ENABLE_SCRIPTS: false # disable post-install scripts | |
| YARN_NODE_LINKER: pnp # use pnp linker for better linking performance: it's meant to update yarn cache only | |
| run: | | |
| yarn install --mode=skip-build | |
| yarn-validate: | |
| name: Validate Yarn dependencies and constraints | |
| needs: prepare-yarn-cache | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: 'Check for unmet constraints (fix w/ "yarn constraints --fix")' | |
| run: | | |
| yarn constraints | |
| - name: 'Check for duplicate dependencies (fix w/ "yarn dedupe")' | |
| run: | | |
| yarn dedupe --check | |
| - name: Check for dependency cycles | |
| # todo: investigate why we need to install dependencies here to not get | |
| # the following error: | |
| # Internal Error: chalk@condition:BABEL_8_BREAKING ?[...]: This package | |
| # doesn't seem to be present in your lockfile; run "yarn install" to | |
| # update the lockfile | |
| run: | | |
| yarn | |
| yarn release-tool check-cycles | |
| build: | |
| name: Build Babel Artifacts | |
| needs: prepare-yarn-cache | |
| runs-on: ubuntu-latest | |
| # Yarn PnP does not support native ESM yet (https://github.com/yarnpkg/berry/issues/638) | |
| # env: | |
| # YARN_NODE_LINKER: pnp # use pnp linker for better linking performance and stricter checks | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Build babel artifacts | |
| run: | | |
| make -j build-standalone-ci | |
| env: | |
| BABEL_ENV: test-legacy | |
| BABEL_9_BREAKING: false | |
| STRIP_BABEL_VERSION_FLAG: true | |
| - name: Build Makefile.js | |
| run: | | |
| node ./scripts/pack-script.js | |
| - name: Generate readmes | |
| run: | | |
| make generate-readme | |
| - name: Generate .npmignore | |
| run: | | |
| node scripts/generators/npm-ignore.js | |
| - name: Cleanup fixtures | |
| run: | | |
| node scripts/cleanup-fixtures.js | |
| - name: Ensure cwd does not contain uncommitted changes | |
| run: | | |
| node ./scripts/assert-dir-git-clean.js "\`make build\` and \`node scripts/cleanup-fixtures.js\`" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: babel-artifact | |
| path: | | |
| codemods/*/lib/**/* | |
| eslint/*/lib/**/* | |
| packages/*/lib/**/* | |
| packages/babel-standalone/*.js | |
| packages/babel-runtime/**/*.js | |
| packages/babel-runtime-corejs2/**/*.js | |
| packages/babel-runtime-corejs3/**/*.js | |
| !**/node_modules/** | |
| retention-days: 5 | |
| build-windows: | |
| name: Build Babel Artifacts on Windows | |
| runs-on: windows-latest | |
| # Yarn PnP does not support native ESM yet (https://github.com/yarnpkg/berry/issues/638) | |
| # env: | |
| # YARN_NODE_LINKER: pnp # use pnp linker for better linking performance and stricter checks | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Build babel artifacts | |
| shell: bash | |
| run: | | |
| make -j build-standalone-ci | |
| env: | |
| BABEL_ENV: test-legacy | |
| BABEL_9_BREAKING: false | |
| STRIP_BABEL_VERSION_FLAG: true | |
| - name: Ensure cwd does not contain uncommitted changes | |
| run: | | |
| node ./scripts/assert-dir-git-clean.js build | |
| lint: | |
| name: Lint | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Install | |
| run: yarn install | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel-artifact | |
| - name: Lint | |
| run: make -j lint-ci check-compat-data | |
| - name: Ensure cwd does not contain uncommitted changes | |
| run: | | |
| node ./scripts/assert-dir-git-clean.js "lint-ci check-compat-data" | |
| test-coverage: | |
| name: Test on Node.js Latest (with coverage) | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Install | |
| run: | | |
| yarn install | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel-artifact | |
| - name: Run tests | |
| run: | | |
| yarn c8 jest --ci | |
| yarn test:esm | |
| env: | |
| BABEL_ENV: test | |
| BABEL_COVERAGE: true | |
| - name: Upload coverage report | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| name: babel-7 | |
| test: | |
| name: Test on Node.js ${{matrix.node-version}} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: [24, 22, 20] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest # Run yarn on latest node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Install | |
| run: | | |
| yarn install | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel-artifact | |
| - name: Use Node.js ${{ matrix.node-version }} # Checkout node version for test executor | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Ensure that @babel/node's list of node flags is up to date | |
| run: | | |
| node ./packages/babel-node/scripts/list-node-flags.js | |
| - name: Test on node.js ${{ matrix.node-version }} | |
| # Todo(Babel 8): Jest execution path is hardcoded because Yarn 2 does not support node 6 | |
| run: | | |
| node ./node_modules/.bin/jest --ci | |
| env: | |
| BABEL_ENV: test | |
| TEST_FUZZ: true | |
| test-windows-mac: | |
| name: Test on | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Install | |
| run: yarn install | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel-artifact | |
| - name: Test | |
| run: yarn jest --ci | |
| env: | |
| BABEL_ENV: test | |
| build-babel9: | |
| name: Build Babel 9 Artifacts | |
| needs: prepare-yarn-cache | |
| runs-on: ubuntu-latest | |
| # Yarn PnP does not support native ESM yet (https://github.com/yarnpkg/berry/issues/638) | |
| # env: | |
| # YARN_NODE_LINKER: pnp # use pnp linker for better linking performance and stricter checks | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Build babel artifacts | |
| run: | | |
| make -j build-standalone-ci | |
| env: | |
| BABEL_ENV: test-legacy | |
| BABEL_9_BREAKING: true | |
| STRIP_BABEL_VERSION_FLAG: true | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: babel9-artifact | |
| path: | | |
| codemods/*/lib/**/* | |
| eslint/*/lib/**/* | |
| packages/*/lib/**/* | |
| packages/babel-standalone/*.js | |
| packages/babel-runtime/**/*.js | |
| packages/babel-runtime-corejs2/**/*.js | |
| packages/babel-runtime-corejs3/**/*.js | |
| !**/node_modules/** | |
| retention-days: 5 | |
| lint-babel9: | |
| name: Lint (Babel 9) | |
| needs: build-babel9 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Install | |
| run: yarn install | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel9-artifact | |
| - name: Lint | |
| run: make -j lint-ci check-compat-data | |
| env: | |
| BABEL_ENV: test | |
| BABEL_9_BREAKING: true | |
| test-babel9-coverage: | |
| name: Test Babel 9 changes (with coverage) | |
| needs: build-babel9 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Install | |
| run: | | |
| yarn install | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel9-artifact | |
| - name: Run tests | |
| run: | | |
| yarn c8 jest --ci | |
| env: | |
| BABEL_ENV: test | |
| BABEL_COVERAGE: true | |
| BABEL_9_BREAKING: true | |
| - name: Upload coverage report | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| name: babel-9 | |
| test-babel9-windows-mac: | |
| name: Test Babel 9 changes | |
| needs: build-babel9 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Install | |
| run: yarn install | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel9-artifact | |
| - name: Test | |
| run: yarn jest --ci | |
| env: | |
| BABEL_ENV: test | |
| BABEL_9_BREAKING: true | |
| external-parser-tests: | |
| name: Third-party Parser Tests | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Install | |
| run: yarn install | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel-artifact | |
| - name: Download tests | |
| run: make -j bootstrap-flow bootstrap-typescript bootstrap-test262 | |
| - name: Run Test262 Tests | |
| run: make test-test262 | |
| - name: Run Flow Tests | |
| run: make test-flow | |
| - name: Run TypeScript Tests | |
| run: make test-typescript | |
| runtime-interop-prepare: | |
| name: Prepare runtime integration tests | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| # See https://github.com/babel/babel/pull/12906 | |
| - name: Support self-references on old Node.js | |
| run: | | |
| echo '{ | |
| "type": "commonjs", | |
| "private": true, | |
| "devDependencies": { | |
| "@babel/runtime": "workspace:^", | |
| "@babel/runtime-corejs3": "workspace:^" | |
| } | |
| }' > packages/package.json | |
| node -e " | |
| const pkg = require('./package.json'); | |
| pkg.workspaces.push('packages'); | |
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)) | |
| " | |
| - name: Install | |
| run: yarn install | |
| env: | |
| # The "Support self-references on old Node.js" step mutates the | |
| # package.json file, causing a yarn.lock update. | |
| YARN_ENABLE_IMMUTABLE_INSTALLS: false | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel-artifact | |
| - name: Generate absoluteRuntime tests | |
| run: yarn test:runtime:generate-absolute-runtime | |
| - name: Test bundlers | |
| run: yarn test:runtime:bundlers | |
| - name: Test Node.js latest | |
| run: node test/runtime-integration/node.cjs | |
| runtime-interop: | |
| name: Test @babel/runtime integrations on Node.js | |
| needs: [build, runtime-interop-prepare] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: | |
| [ | |
| 10, | |
| "12.0", | |
| 12.12, | |
| 12.13, | |
| 12.15, | |
| 12.16, | |
| 13.2, | |
| 13.6, | |
| 13.7, | |
| 14.2, | |
| 16.5, | |
| 16.6, | |
| 22.11, | |
| 22.12, | |
| "23.10", | |
| ] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| # See https://github.com/babel/babel/pull/12906 | |
| - name: Support self-references on old Node.js | |
| run: | | |
| echo '{ | |
| "type": "commonjs", | |
| "private": true, | |
| "devDependencies": { | |
| "@babel/runtime": "workspace:^", | |
| "@babel/runtime-corejs3": "workspace:^" | |
| } | |
| }' > packages/package.json | |
| node -e " | |
| const pkg = require('./package.json'); | |
| pkg.workspaces.push('packages'); | |
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)) | |
| " | |
| - name: Install | |
| run: yarn install | |
| env: | |
| # The "Support self-references on old Node.js" step mutates the | |
| # package.json file, causing a yarn.lock update. | |
| YARN_ENABLE_IMMUTABLE_INSTALLS: false | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel-artifact | |
| - name: Generate absoluteRuntime tests | |
| run: yarn test:runtime:generate-absolute-runtime | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Test Node.js ${{ matrix.node-version }} | |
| run: node test/runtime-integration/node.cjs | |
| eslint8-test: | |
| name: Test @babel/eslint-* with ESLint 8.0.0 | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| cache: "yarn" | |
| - name: Install | |
| run: yarn install | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel-artifact | |
| - name: Downgrade ESLint to 8.0.0 | |
| run: yarn up [email protected] | |
| - name: Run babel/eslint tests | |
| run: node ./node_modules/.bin/jest eslint | |
| test262-prepare: | |
| name: test262 - Prepare for running in parallel | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'babel/babel' | |
| steps: | |
| - name: Checkout Babel | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| - name: Checkout test runner | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: babel/babel-test262-runner | |
| path: babel-test262-runner | |
| ref: main | |
| - name: Download test262 | |
| run: make bootstrap-test262 | |
| - name: Prepare test262 chunks | |
| run: | | |
| cd babel-test262-runner | |
| npm ci | |
| node lib/prepare-chunks 8 > ~/test262-chunks.json | |
| env: | |
| TEST262_PATH: ../build/test262 | |
| - name: Upload chunks artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test262-chunks | |
| path: ~/test262-chunks.json | |
| retention-days: 30 | |
| test262: | |
| name: test262 | |
| strategy: | |
| matrix: | |
| chunk: [0, 1, 2, 3, 4, 5, 6, 7] | |
| runs-on: ubuntu-latest | |
| needs: [build, test262-prepare] | |
| steps: | |
| - name: Checkout Babel | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js latest | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: latest | |
| check-latest: true | |
| - name: Install | |
| run: yarn install | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: babel-artifact | |
| - name: Checkout test runner | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: babel/babel-test262-runner | |
| path: babel-test262-runner | |
| ref: main | |
| - name: Install test runner | |
| run: | | |
| cd babel-test262-runner | |
| npm ci | |
| node lib/download-node | |
| - name: Download test262 | |
| run: make bootstrap-test262 | |
| - name: Download chunks file | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: test262-chunks | |
| - name: Run test262 | |
| run: | | |
| cd babel-test262-runner | |
| node lib/run-tests I_AM_SURE | tee ~/test262-${{ matrix.chunk }}.tap | |
| # Specify bash to enable pipefail, so that "| tee" does not suppress the failure exit code. | |
| # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell | |
| shell: bash | |
| env: | |
| BABEL_PATH: ".." | |
| TEST262_PATH: ../build/test262 | |
| THREADS: 4 | |
| CHUNKS_FILE: ../test262-chunks.json | |
| CHUNK: ${{ matrix.chunk }} | |
| - name: Create artifact with report results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test262-result-${{ matrix.chunk }} | |
| path: ~/test262-${{ matrix.chunk }}.tap | |
| retention-days: 30 | |
| test262-finish: | |
| name: test262 - Analyze results | |
| runs-on: ubuntu-latest | |
| needs: test262 | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: { name: test262-result-0 } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: test262-result-1 } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: test262-result-2 } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: test262-result-3 } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: test262-result-4 } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: test262-result-5 } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: test262-result-6 } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: test262-result-7 } | |
| - name: Merge chunk results | |
| run: | | |
| cat test262-0.tap test262-1.tap test262-2.tap test262-3.tap \ | |
| test262-4.tap test262-5.tap test262-6.tap test262-7.tap \ | |
| | npx tap-merge > test262.tap | |
| - name: Create artifact with report results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test262-result | |
| path: test262.tap | |
| - name: Checkout test runner | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: babel/babel-test262-runner | |
| path: babel-test262-runner | |
| ref: main | |
| - name: Download previous results | |
| run: | | |
| cd babel-test262-runner | |
| npm ci | |
| node lib/download-main-artifact/index.mjs ~/test262-main.tap | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Compare previous main branch & current results | |
| run: | | |
| cd babel-test262-runner | |
| node lib/compare-results ~/test262-main.tap ../test262.tap | tee ~/diff.tap | |
| # Specify bash to enable pipefail, so that "| tee" does not suppress the failure exit code. | |
| # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell | |
| shell: bash |