Skip to content

fix: create build dir for types update workflow #1981

fix: create build dir for types update workflow

fix: create build dir for types update workflow #1981

Workflow file for this run

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@v3
with:
node-version: latest
check-latest: true
cache: "yarn"
- name: 'Check or update Yarn cache (fix w/ "yarn install")'
env:
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@v3
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
test-coverage:
name: Test on Node.js Latest
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@v3
with:
node-version: latest
check-latest: true
cache: "yarn"
- name: Generate coverage report
run: |
make -j test-ci-coverage
yarn test:esm
env:
BABEL_CLI_FLAKY_TESTS: true
- name: Upload coverage report
uses: codecov/codecov-action@v3
test-esm:
name: Test ESM version
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@v3
with:
node-version: latest
check-latest: true
cache: "yarn"
- name: Use ESM and build
run: make use-esm
env:
USE_ESM: true
- name: Test
run: yarn jest --ci
env:
BABEL_ENV: test
USE_ESM: true
BABEL_CLI_FLAKY_TESTS: trues
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@v3
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_8_BREAKING: false
STRIP_BABEL_8_FLAG: true
- name: Build Makefile.js
run: |
node ./scripts/pack-script.js
- name: Generate readmes
run: |
make generate-readme
- name: Ensure cwd does not contain uncommitted changes
run: |
node ./scripts/assert-dir-git-clean.js build
- name: Prepare artifacts
run: |
./scripts/get-artifact-files.sh | tar --null -cvf babel-artifact.tar --files-from=-
- uses: actions/upload-artifact@v3
with:
name: babel-artifact
path: babel-artifact.tar
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@v3
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_8_BREAKING: false
STRIP_BABEL_8_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@v3
with:
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
run: yarn install
- uses: actions/download-artifact@v3
with:
name: babel-artifact
- name: Extract artifacts
run: tar -xf babel-artifact.tar; rm babel-artifact.tar
- name: Lint
run: make -j prepublish-prepare-dts lint-ci
- name: Ensure cwd does not contain uncommitted changes
run: |
node ./scripts/assert-dir-git-clean.js "prepublish-prepare-dts lint-ci"
test:
name: Test on Node.js # GitHub will add ${{ matrix.node-version }} to this title
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18, 16, 14, 12, 10, 8, 6]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js latest # Run yarn on latest node
uses: actions/setup-node@v3
with:
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
run: |
yarn install
- name: Downgrade Jest and Babel for node <= 10
if: matrix.node-version == '6' || matrix.node-version == '8' || matrix.node-version == '10'
run: |
# It's a bit sarcastic that in this scenario bump-babel-dependencies.js
# actually downgrades the root `@babel/*` deps from 8.0 alpha to 7
node ./scripts/integration-tests/utils/bump-babel-dependencies.js
yarn up jest@24
cd packages/babel-helper-transform-fixture-test-runner && yarn up jest-diff@24 && cd ../..
# Deduplicate dependencies, because duplicate copies of graceful-fs cause
# problems with the "path" module: https://github.com/facebook/jest/issues/9656
yarn dedupe
- name: Downgrade Jest and jest-light-runner for node == 12
if: matrix.node-version == '12'
run: |
yarn up jest@28
cd packages/babel-helper-transform-fixture-test-runner && yarn up jest-diff@28 && cd ../..
yarn up [email protected]
# Deduplicate dependencies, because duplicate copies of graceful-fs cause
# problems with the "path" module: https://github.com/facebook/jest/issues/9656
yarn dedupe
- uses: actions/download-artifact@v3
with:
name: babel-artifact
- name: Extract artifacts
run: tar -xf babel-artifact.tar; rm babel-artifact.tar
- name: Use Node.js ${{ matrix.node-version }} # Checkout node version for test executor
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- 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: |
BABEL_ENV=test node --max-old-space-size=4096 ./node_modules/.bin/jest --ci
env:
BABEL_CLI_FLAKY_TESTS: true
TEST_FUZZ: "${{ (matrix.node-version == '6' || matrix.node-version == '8' || matrix.node-version == '10') && 'false' || 'true' }}"
- name: Use Node.js latest # For `yarn version` in post actions of the first actions/setup-node
if: matrix.node-version == '6' || matrix.node-version == '8' || matrix.node-version == '10'
uses: actions/setup-node@v3
with:
node-version: latest
build-babel8:
name: Build Babel 8 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@v3
with:
node-version: latest
check-latest: true
cache: "yarn"
- name: Use ESM
run: node scripts/set-module-type.js module
- name: Build babel artifacts
run: |
make -j build-standalone-ci
env:
BABEL_ENV: test-legacy
BABEL_8_BREAKING: true
STRIP_BABEL_8_FLAG: true
- name: Lint
run: make -j tscheck lint-ci
env:
BABEL_ENV: test
BABEL_8_BREAKING: true
BABEL_TYPES_8_BREAKING: true
- name: Prepare artifacts
run: |
./scripts/get-artifact-files.sh | tar --null -cvf babel-artifact.tar --files-from=-
- uses: actions/upload-artifact@v3
with:
name: babel8-artifact
path: babel-artifact.tar
retention-days: 5
test-babel-8-breaking:
name: Test Babel 8 breaking changes on
needs: build-babel8
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js 16.20
uses: actions/setup-node@v3
with:
node-version: "16.20" # Node.js 16.20 is the first LTS supported by Babel 8
cache: "yarn"
- name: Install
run: |
yarn install
- uses: actions/download-artifact@v3
with:
name: babel8-artifact
- name: Extract artifacts
run: tar -xf babel-artifact.tar; rm babel-artifact.tar
- name: Use ESM
run: node scripts/set-module-type.js module
- name: Test
run: |
yarn jest --ci
yarn test:esm
env:
BABEL_ENV: test
BABEL_8_BREAKING: true
BABEL_TYPES_8_BREAKING: true
BABEL_CLI_FLAKY_TESTS: true
test-windows:
name: Test on Windows
needs: build
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
run: yarn install
- uses: actions/download-artifact@v3
with:
name: babel-artifact
- name: Extract artifacts
run: tar -xf babel-artifact.tar; rm babel-artifact.tar
- name: Test on Windows
run: yarn jest --ci
env:
BABEL_ENV: test
BABEL_CLI_FLAKY_TESTS: 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@v3
with:
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
run: yarn install
- uses: actions/download-artifact@v3
with:
name: babel-artifact
- name: Extract artifacts
run: tar -xf babel-artifact.tar; rm babel-artifact.tar
- 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:
name: Test @babel/runtime integrations
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js latest
uses: actions/setup-node@v3
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 '{
"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@v3
with:
name: babel-artifact
- name: Extract artifacts
run: tar -xf babel-artifact.tar; rm babel-artifact.tar
- 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
- name: Use Node.js 10
uses: actions/setup-node@v3
with:
node-version: 10
- name: Test Node.js 10
run: node test/runtime-integration/node.cjs
- name: Use Node.js 12.0
uses: actions/setup-node@v3
with:
node-version: "12.0" # quoted, otherwise it's just 13
- name: Test Node.js 12.0
run: node test/runtime-integration/node.cjs
- name: Use Node.js 12.17
uses: actions/setup-node@v3
with:
node-version: 12.17
- name: Test Node.js 12.17
run: node test/runtime-integration/node.cjs
- name: Use Node.js 13.0
uses: actions/setup-node@v3
with:
node-version: "13.0" # quoted, otherwise it's just 13
- name: Test Node.js 13.0
run: node test/runtime-integration/node.cjs
- name: Use Node.js 13.2
uses: actions/setup-node@v3
with:
node-version: 13.2
- name: Test Node.js 13.2
run: node test/runtime-integration/node.cjs
- name: Use Node.js 13.6
uses: actions/setup-node@v3
with:
node-version: 13.6
- name: Test Node.js 13.6
run: node test/runtime-integration/node.cjs
- name: Use Node.js 13.7
uses: actions/setup-node@v3
with:
node-version: 13.7
- name: Test Node.js 13.7
run: node test/runtime-integration/node.cjs
- name: Use Node.js 14.2
uses: actions/setup-node@v3
with:
node-version: 14.2
- name: Test Node.js 14.2
run: node test/runtime-integration/node.cjs
- name: Use Node.js 16.5
uses: actions/setup-node@v3
with:
node-version: 16.5
- name: Test Node.js 16.5
run: node test/runtime-integration/node.cjs
- name: Use Node.js 16.6
uses: actions/setup-node@v3
with:
node-version: 16.6
- name: Test Node.js 16.6
run: node test/runtime-integration/node.cjs
eslint7-test:
name: Test @babel/eslint-* with ESLint 7.5.0
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js latest
uses: actions/setup-node@v3
with:
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
run: yarn install
- uses: actions/download-artifact@v3
with:
name: babel-artifact
- name: Extract artifacts
run: tar -xf babel-artifact.tar; rm babel-artifact.tar
- name: Downgrade ESLint to 7.5.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@v3
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@v3
with:
name: test262-chunks
path: ~/test262-chunks.json
retention-days: 3
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@v3
with:
node-version: latest
check-latest: true
- name: Install
run: yarn install
- uses: actions/download-artifact@v3
with:
name: babel-artifact
- name: Extract artifacts
run: tar -xf babel-artifact.tar; rm babel-artifact.tar
- 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@v3
with:
name: test262-chunks
- name: Run test262
run: |
cd babel-test262-runner
node lib/run-tests I_AM_SURE | tee ~/test262-${{ matrix.chunk }}.tap
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@v3
with:
name: test262-result-${{ matrix.chunk }}
path: ~/test262-${{ matrix.chunk }}.tap
retention-days: 3
test262-finish:
name: test262 - Analyze results
runs-on: ubuntu-latest
needs: test262
steps:
- uses: actions/download-artifact@v3
with: { name: test262-result-0 }
- uses: actions/download-artifact@v3
with: { name: test262-result-1 }
- uses: actions/download-artifact@v3
with: { name: test262-result-2 }
- uses: actions/download-artifact@v3
with: { name: test262-result-3 }
- uses: actions/download-artifact@v3
with: { name: test262-result-4 }
- uses: actions/download-artifact@v3
with: { name: test262-result-5 }
- uses: actions/download-artifact@v3
with: { name: test262-result-6 }
- uses: actions/download-artifact@v3
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@v3
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