From fe006183b11f7e03cdf86e25e97c47a516c50e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Sun, 27 Mar 2022 06:46:08 -0400 Subject: [PATCH] Fix flaky @babel/cli test (#14385) --- .github/workflows/ci.yml | 160 ++++++------------ .github/workflows/e2e-tests-breaking.yml | 21 +-- .github/workflows/e2e-tests.yml | 22 +-- .github/workflows/release.yml | 10 +- .github/workflows/update-parser-tests.yml | 17 +- .github/workflows/update-windows-fixtures.yml | 14 +- .../executor.js | 4 +- .../executor.js | 4 +- .../executor.js | 4 +- 9 files changed, 90 insertions(+), 166 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1e17ef67840..ebc5b212691a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,21 +8,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js latest - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "*" - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} - restore-keys: | - yarn- + cache: "yarn" - name: 'Check or update Yarn cache (fix w/ "yarn install")' env: YARN_ENABLE_SCRIPTS: false # disable post-install scripts @@ -36,16 +27,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js latest - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "*" + cache: "yarn" - name: 'Check for unmet constraints (fix w/ "yarn constraints --fix")' run: | yarn constraints - name: 'Check for duplicate dependencies (fix w/ "yarn dedupe")' - if: steps.yarn-cache.outputs.cache-hit != 'true' run: | yarn dedupe --check - name: Check for dependency cycles @@ -58,18 +49,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js latest - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: 17 - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} + cache: "yarn" - name: Generate coverage report run: | make -j test-ci-coverage @@ -86,20 +71,12 @@ jobs: # YARN_NODE_LINKER: pnp # use pnp linker for better linking performance and stricter checks steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js latest - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "*" - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} - restore-keys: | - yarn- + cache: "yarn" - name: Build babel artifacts run: | BABEL_ENV=test-legacy make -j build-standalone-ci @@ -109,7 +86,7 @@ jobs: - name: Ensure cwd does not contain uncommitted changes run: | ./scripts/assert-dir-git-clean.sh - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: babel-artifact path: | @@ -125,19 +102,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js latest - uses: actions/setup-node@v2-beta - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 + uses: actions/setup-node@v3 with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} + node-version: "*" + cache: "yarn" - name: Install run: yarn install - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: babel-artifact - name: Lint @@ -152,18 +125,12 @@ jobs: node-version: [16, 14, 12, 10, 8, 6] steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js latest # Run yarn on latest node - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "*" # Build Babel on latest node LTS versions - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} + cache: "yarn" - name: Install run: | yarn install @@ -175,14 +142,14 @@ jobs: # 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@v2 + - uses: actions/download-artifact@v3 with: name: babel-artifact - name: Generate runtime helpers run: | make build-plugin-transform-runtime-dist - name: Use Node.js ${{ matrix.node-version }} # Checkout node version for test executor - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Test on node.js ${{ matrix.node-version }} @@ -194,6 +161,11 @@ jobs: BABEL_ENV=test node --max-old-space-size=4096 ./node_modules/.bin/jest --ci --color env: 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: "*" test-babel-8-breaking: name: Test Babel 8 breaking changes @@ -201,18 +173,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js 14.17 - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "14.17" # Node.js 14.17 is the first LTS supported by Babel 8 - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} + cache: "yarn" - name: Install and build run: make -j bootstrap env: @@ -242,19 +208,15 @@ jobs: runs-on: windows-latest steps: - name: Checkout code - uses: actions/checkout@v2 - - name: Use Node.js latest - uses: actions/setup-node@v2-beta - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 + uses: actions/checkout@v3 + - name: Use Node.js 16 + uses: actions/setup-node@v3 with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} + node-version: 16 + cache: "yarn" - name: Install run: yarn install - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: babel-artifact - name: Generate runtime helpers @@ -273,19 +235,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js latest - uses: actions/setup-node@v2-beta - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 + uses: actions/setup-node@v3 with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} + node-version: "*" + cache: "yarn" - name: Install run: yarn install - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: babel-artifact - name: Download tests @@ -303,18 +261,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js latest - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "*" - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} + cache: "yarn" # See https://github.com/babel/babel/pull/12906 - name: Support self-references on old Node.js run: | @@ -336,7 +288,7 @@ jobs: # 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@v2 + - uses: actions/download-artifact@v3 with: name: babel-artifact - name: Generate runtime helpers @@ -349,61 +301,61 @@ jobs: - name: Test Node.js run: yarn test:runtime:node - name: Use Node.js 10 - uses: actions/setup-node@v2-beta + 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@v2-beta + uses: actions/setup-node@v3 with: node-version: "12.0" # quoted, otherwise it's just 13 - name: Test Node.js 12.0 run: yarn test:runtime:node - name: Use Node.js 12.17 - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: 12.17 - name: Test Node.js 12.17 run: yarn test:runtime:node - name: Use Node.js 13.0 - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "13.0" # quoted, otherwise it's just 13 - name: Test Node.js 13.0 run: yarn test:runtime:node - name: Use Node.js 13.2 - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: 13.2 - name: Test Node.js 13.2 run: yarn test:runtime:node - name: Use Node.js 13.6 - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: 13.6 - name: Test Node.js 13.6 run: yarn test:runtime:node - name: Use Node.js 13.7 - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: 13.7 - name: Test Node.js 13.7 run: yarn test:runtime:node - name: Use Node.js 14.2 - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: 14.2 - name: Test Node.js 14.2 run: yarn test:runtime:node - name: Use Node.js 16.5 - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: 16.5 - name: Test Node.js 16.5 run: yarn test:runtime:node - name: Use Node.js 16.6 - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: 16.6 - name: Test Node.js 16.6 diff --git a/.github/workflows/e2e-tests-breaking.yml b/.github/workflows/e2e-tests-breaking.yml index 416e022d7985..76b370882e05 100644 --- a/.github/workflows/e2e-tests-breaking.yml +++ b/.github/workflows/e2e-tests-breaking.yml @@ -10,26 +10,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Use Node.js latest - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "*" - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - name: Setup Yarn cache - uses: actions/cache@v2 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} + cache: "yarn" - name: Publish run: ./scripts/integration-tests/publish-local.sh env: BABEL_8_BREAKING: true - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: verdaccio-workspace path: /tmp/verdaccio-workspace @@ -50,12 +43,12 @@ jobs: - prettier steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js latest - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "*" - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: verdaccio-workspace path: /tmp/verdaccio-workspace diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 9305906754d5..1f5549f46c43 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -10,24 +10,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Use Node.js latest - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "*" - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - name: Setup Yarn cache - uses: actions/cache@v2 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} + cache: "yarn" - name: Publish run: ./scripts/integration-tests/publish-local.sh - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: verdaccio-workspace path: /tmp/verdaccio-workspace @@ -49,12 +42,13 @@ jobs: - prettier steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js latest - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "*" - - uses: actions/download-artifact@v2 + cache: "yarn" + - uses: actions/download-artifact@v3 with: name: verdaccio-workspace path: /tmp/verdaccio-workspace diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d2b77d2b866a..b75e89724fe3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the new tag - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: This release will publish the following packages @@ -39,7 +39,7 @@ jobs: outputs: branch: ${{ steps.push.outputs.branch }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 @@ -72,7 +72,7 @@ jobs: always() && (needs.git-version.result == 'success' || needs.git-version.result == 'skipped') steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Checkout the temporary branch @@ -100,7 +100,7 @@ jobs: changelog: ${{ steps.changelog.outputs.changelog }} version: ${{ steps.tags.outputs.new }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 @@ -145,7 +145,7 @@ jobs: needs.github-release.result == 'success' && needs.github-release.outputs.is-main steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Checkout the temporary branch diff --git a/.github/workflows/update-parser-tests.yml b/.github/workflows/update-parser-tests.yml index e689281d0612..335a30c27c63 100644 --- a/.github/workflows/update-parser-tests.yml +++ b/.github/workflows/update-parser-tests.yml @@ -11,25 +11,16 @@ jobs: createPullRequest: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: actions/checkout@v3 with: repository: tc39/test262 path: build/test262 - name: Use Node.js latest - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v3 with: node-version: "*" - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} - restore-keys: | - yarn- + cache: "yarn" - name: Get latest test262 version id: test262 run: echo "::set-output name=sha1::$(sh ./scripts/parser-tests/get-test262-version.sh)" diff --git a/.github/workflows/update-windows-fixtures.yml b/.github/workflows/update-windows-fixtures.yml index 7ab525831bd9..c8345e560221 100644 --- a/.github/workflows/update-windows-fixtures.yml +++ b/.github/workflows/update-windows-fixtures.yml @@ -32,7 +32,7 @@ jobs: console.log(`::set-output name=repository::${repository}`); - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: ${{ steps.pr-meta.outputs.repository }} ref: ${{ steps.pr-meta.outputs.branch }} @@ -40,16 +40,10 @@ jobs: persist-credentials: false # So that we can push with BOT_TOKEN, otherwise it doesn't trigger CI - name: Use Node.js latest - uses: actions/setup-node@v2-beta - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v2 - id: cache + uses: actions/setup-node@v3 with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} + node-version: "*" + cache: "yarn" - name: Install and build # make bootstrap modifies some files (babel-runtime-*/package.json), so we reset them diff --git a/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch --verbose with external dependencies/executor.js b/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch --verbose with external dependencies/executor.js index fcf460a0347b..9485128ef5ce 100644 --- a/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch --verbose with external dependencies/executor.js +++ b/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch --verbose with external dependencies/executor.js @@ -12,8 +12,8 @@ const run = (async function* () { logFile("lib/index.js"); logFile("lib/main.js"); - // wait 200ms for watcher setup - await new Promise(resolve => setTimeout(resolve, 200)); + // wait 2s for watcher setup + await new Promise(resolve => setTimeout(resolve, 2000)); fs.writeFileSync("./file.txt", "Updated!"); files = [yield, yield].sort(); diff --git a/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/executor.js b/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/executor.js index 1d480afb2637..4bcaa0619e65 100644 --- a/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/executor.js +++ b/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/executor.js @@ -7,8 +7,8 @@ if (!assert.match) assert.match = (val, re) => assert(re.test(val)); const run = (async function* () { assert.match(yield, /Successfully compiled 4 files with Babel \(\d+ms\)\./); - // wait 200ms for watcher setup - await new Promise(resolve => setTimeout(resolve, 200)); + // wait 2s for watcher setup + await new Promise(resolve => setTimeout(resolve, 2000)); // update ./module1/src/index.js fs.writeFileSync( "./module1/src/index.js", diff --git a/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch with external dependencies/executor.js b/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch with external dependencies/executor.js index 29730dc333e3..5cb66c876b5f 100644 --- a/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch with external dependencies/executor.js +++ b/packages/babel-cli/test/fixtures/babel/dir --out-dir --watch with external dependencies/executor.js @@ -9,8 +9,8 @@ const run = (async function* () { logFile("lib/index.js"); logFile("lib/main.js"); - // wait 200ms for watcher setup - await new Promise(resolve => setTimeout(resolve, 200)); + // wait 2s for watcher setup + await new Promise(resolve => setTimeout(resolve, 2000)); fs.writeFileSync("./file.txt", "Updated!"); assert.match(yield, /Successfully compiled 2 files with Babel \(\d+ms\)\./);