From 61f00e3c23211d37c7980ebd6d1cf8d1dac49f18 Mon Sep 17 00:00:00 2001 From: Reggi Date: Wed, 29 Jan 2025 11:18:49 -0500 Subject: [PATCH] chore: splits out smoke-tests from publish-dryrun tests (#8069) This removes the `publish.sh --smoke-publish` like from the current `smoke-publish-test.sh` (renaming it to `smoke-test.sh`) and runs both operations as seperete jobs within the `ci.yml` (on pr) and `ci-release.yml` (on merge) workflow. Why? To avoid changed files / git dirty issues from one operation to the next. With this PR we should have the same checks that merge has, on pr as well, preventing scenarios where a PR breaks a `smoke test` or `publish --smoke-publish` test. The only difference between merge / pr is that merge has more tested node versions, if PRs start to pass but fail in these version lets add the full matrix. ```sh npm i npm@latest -g && node scripts/git-dirty.js && node scripts/resetdeps.js && ./scripts/smoke-tests.sh ``` ```sh npm i npm@latest -g && node scripts/git-dirty.js && node scripts/resetdeps.js && node ./scripts/publish.js --pack-destination=${pwd} --smoke-publish=true ``` --- .github/workflows/ci-release.yml | 79 ++++++++++++++++--- .github/workflows/ci.yml | 72 ++++++++++++++++- scripts/smoke-tests.js | 0 .../{smoke-publish-test.sh => smoke-tests.sh} | 2 +- scripts/template-oss/ci-release-yml.hbs | 66 ++++++++++------ scripts/template-oss/ci-yml.hbs | 49 ++++++++++-- 6 files changed, 228 insertions(+), 40 deletions(-) create mode 100644 scripts/smoke-tests.js rename scripts/{smoke-publish-test.sh => smoke-tests.sh} (97%) diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index 087ce1b56c90f..edc25fcb4bd67 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -145,12 +145,12 @@ jobs: conclusion: ${{ job.status }} check_id: ${{ steps.create-check.outputs.check-id }} - smoke-publish: - # This cant be tested on Windows because our node_modules directory - # checks in symlinks which are not supported there. This should be - # fixed somehow, because this means some forms of local development - # are likely broken on Windows as well. - name: Smoke Publish - ${{ matrix.platform.name }} - ${{ matrix.node-version }} + smoke-tests: + # This cant be tested on Windows because our node_modules directory + # checks in symlinks which are not supported there. This should be + # fixed somehow, because this means some forms of local development + # are likely broken on Windows as well. + name: Smoke Tests - ${{ matrix.platform.name }} - ${{ matrix.node-version }} if: github.repository_owner == 'npm' strategy: fail-fast: false @@ -182,7 +182,7 @@ jobs: if: ${{ inputs.check-sha }} uses: ./.github/actions/create-check with: - name: "Smoke Publish - ${{ matrix.platform.name }} - ${{ matrix.node-version }}" + name: "Smoke Tests - ${{ matrix.platform.name }} - ${{ matrix.node-version }}" token: ${{ secrets.GITHUB_TOKEN }} sha: ${{ inputs.check-sha }} - name: Setup Node @@ -196,8 +196,69 @@ jobs: run: node scripts/git-dirty.js - name: Reset Deps run: node scripts/resetdeps.js - - name: Smoke Publish - run: ./scripts/smoke-publish-test.sh + - name: Smoke Tests + run: ./scripts/smoke-tests.sh + - name: Conclude Check + uses: LouisBrunner/checks-action@v1.6.0 + if: steps.create-check.outputs.check-id && always() + with: + token: ${{ secrets.GITHUB_TOKEN }} + conclusion: ${{ job.status }} + check_id: ${{ steps.create-check.outputs.check-id }} + + publish-dryrun: + # This cant be tested on Windows because our node_modules directory + # checks in symlinks which are not supported there. This should be + # fixed somehow, because this means some forms of local development + # are likely broken on Windows as well. + name: Publish Dry-Run - ${{ matrix.platform.name }} - ${{ matrix.node-version }} + if: github.repository_owner == 'npm' + strategy: + fail-fast: false + matrix: + platform: + - name: Linux + os: ubuntu-latest + shell: bash + node-version: + - 20.17.0 + - 20.x + - 22.9.0 + - 22.x + runs-on: ${{ matrix.platform.os }} + defaults: + run: + shell: ${{ matrix.platform.shell }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + - name: Setup Git User + run: | + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" + - name: Create Check + id: create-check + if: ${{ inputs.check-sha }} + uses: ./.github/actions/create-check + with: + name: "Publish Dry-Run - ${{ matrix.platform.name }} - ${{ matrix.node-version }}" + token: ${{ secrets.GITHUB_TOKEN }} + sha: ${{ inputs.check-sha }} + - name: Setup Node + uses: actions/setup-node@v4 + id: node + with: + node-version: ${{ matrix.node-version }} + check-latest: contains(matrix.node-version, '.x') + cache: npm + - name: Check Git Status + run: node scripts/git-dirty.js + - name: Reset Deps + run: node scripts/resetdeps.js + - name: Publish Dry-Run + run: node ./scripts/publish.js --pack-destination=$RUNNER_TEMP --smoke-publish=true - name: Conclude Check uses: LouisBrunner/checks-action@v1.6.0 if: steps.create-check.outputs.check-id && always() diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb754da8e6111..e53689d0ebedd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,6 +147,10 @@ jobs: run: node . run licenses smoke-tests: + # This cant be tested on Windows because our node_modules directory + # checks in symlinks which are not supported there. This should be + # fixed somehow, because this means some forms of local development + # are likely broken on Windows as well. name: Smoke Tests if: github.repository_owner == 'npm' runs-on: ubuntu-latest @@ -156,10 +160,20 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" + - name: Create Check + id: create-check + if: ${{ inputs.check-sha }} + uses: ./.github/actions/create-check + with: + name: "Smoke Tests" + token: ${{ secrets.GITHUB_TOKEN }} + sha: ${{ inputs.check-sha }} - name: Setup Node uses: actions/setup-node@v4 id: node @@ -171,10 +185,64 @@ jobs: run: node scripts/git-dirty.js - name: Reset Deps run: node scripts/resetdeps.js - - name: Run Smoke Tests - run: node . test -w smoke-tests --ignore-scripts + - name: Smoke Tests + run: ./scripts/smoke-tests.sh + - name: Conclude Check + uses: LouisBrunner/checks-action@v1.6.0 + if: steps.create-check.outputs.check-id && always() + with: + token: ${{ secrets.GITHUB_TOKEN }} + conclusion: ${{ job.status }} + check_id: ${{ steps.create-check.outputs.check-id }} + + publish-dryrun: + # This cant be tested on Windows because our node_modules directory + # checks in symlinks which are not supported there. This should be + # fixed somehow, because this means some forms of local development + # are likely broken on Windows as well. + name: Publish Dry-Run + if: github.repository_owner == 'npm' + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + - name: Setup Git User + run: | + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" + - name: Create Check + id: create-check + if: ${{ inputs.check-sha }} + uses: ./.github/actions/create-check + with: + name: "Publish Dry-Run" + token: ${{ secrets.GITHUB_TOKEN }} + sha: ${{ inputs.check-sha }} + - name: Setup Node + uses: actions/setup-node@v4 + id: node + with: + node-version: 22.x + check-latest: contains('22.x', '.x') + cache: npm - name: Check Git Status run: node scripts/git-dirty.js + - name: Reset Deps + run: node scripts/resetdeps.js + - name: Publish Dry-Run + run: node ./scripts/publish.js --pack-destination=$RUNNER_TEMP --smoke-publish=true + - name: Conclude Check + uses: LouisBrunner/checks-action@v1.6.0 + if: steps.create-check.outputs.check-id && always() + with: + token: ${{ secrets.GITHUB_TOKEN }} + conclusion: ${{ job.status }} + check_id: ${{ steps.create-check.outputs.check-id }} windows-shims: name: Windows Shims Tests diff --git a/scripts/smoke-tests.js b/scripts/smoke-tests.js new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/scripts/smoke-publish-test.sh b/scripts/smoke-tests.sh similarity index 97% rename from scripts/smoke-publish-test.sh rename to scripts/smoke-tests.sh index 5de4f32931cf7..0acda09c26b38 100755 --- a/scripts/smoke-publish-test.sh +++ b/scripts/smoke-tests.sh @@ -66,7 +66,7 @@ fi # were publishing it to the registry. The only difference is in the # publish.js script which will only pack and not publish node . version $NPM_VERSION --ignore-scripts --git-tag-version="$IS_CI" -node scripts/publish.js --pack-destination=$RUNNER_TEMP --smoke-publish=true +node . pack . --pack-destination "$RUNNER_TEMP" NPM_TARBALL="$RUNNER_TEMP/npm-$NPM_VERSION.tgz" node . install --global $NPM_TARBALL diff --git a/scripts/template-oss/ci-release-yml.hbs b/scripts/template-oss/ci-release-yml.hbs index 8ff869812a331..6ec27f1b2e9d2 100644 --- a/scripts/template-oss/ci-release-yml.hbs +++ b/scripts/template-oss/ci-release-yml.hbs @@ -1,23 +1,45 @@ -{{> ciReleaseYml }} +{{> ciReleaseYml }} - smoke-publish: - # This cant be tested on Windows because our node_modules directory - # checks in symlinks which are not supported there. This should be - # fixed somehow, because this means some forms of local development - # are likely broken on Windows as well. - {{> jobMatrixYml - jobName="Smoke Publish" - jobCheckout=(obj ref="${{ inputs.ref }}") - jobCreateCheck=(obj sha="${{ inputs.check-sha }}") - windowsCI=false - macCI=false - }} - - name: Smoke Publish - run: ./scripts/smoke-publish-test.sh - - name: Conclude Check - uses: LouisBrunner/checks-action@v1.6.0 - if: steps.create-check.outputs.check-id && always() - with: - token: $\{{ secrets.GITHUB_TOKEN }} - conclusion: $\{{ job.status }} - check_id: $\{{ steps.create-check.outputs.check-id }} + smoke-tests: + # This cant be tested on Windows because our node_modules directory + # checks in symlinks which are not supported there. This should be + # fixed somehow, because this means some forms of local development + # are likely broken on Windows as well. + {{> jobMatrixYml + jobName="Smoke Tests" + jobCheckout=(obj ref="${{ inputs.ref }}") + jobCreateCheck=(obj sha="${{ inputs.check-sha }}") + windowsCI=false + macCI=false + }} + - name: Smoke Tests + run: ./scripts/smoke-tests.sh + - name: Conclude Check + uses: LouisBrunner/checks-action@v1.6.0 + if: steps.create-check.outputs.check-id && always() + with: + token: $\{{ secrets.GITHUB_TOKEN }} + conclusion: $\{{ job.status }} + check_id: $\{{ steps.create-check.outputs.check-id }} + + publish-dryrun: + # This cant be tested on Windows because our node_modules directory + # checks in symlinks which are not supported there. This should be + # fixed somehow, because this means some forms of local development + # are likely broken on Windows as well. + {{> jobMatrixYml + jobName="Publish Dry-Run" + jobCheckout=(obj ref="${{ inputs.ref }}") + jobCreateCheck=(obj sha="${{ inputs.check-sha }}") + windowsCI=false + macCI=false + }} + - name: Publish Dry-Run + run: node ./scripts/publish.js --pack-destination=$RUNNER_TEMP --smoke-publish=true + - name: Conclude Check + uses: LouisBrunner/checks-action@v1.6.0 + if: steps.create-check.outputs.check-id && always() + with: + token: $\{{ secrets.GITHUB_TOKEN }} + conclusion: $\{{ job.status }} + check_id: $\{{ steps.create-check.outputs.check-id }} \ No newline at end of file diff --git a/scripts/template-oss/ci-yml.hbs b/scripts/template-oss/ci-yml.hbs index bdd4e3b5ccab5..386a3716deadd 100644 --- a/scripts/template-oss/ci-yml.hbs +++ b/scripts/template-oss/ci-yml.hbs @@ -5,12 +5,49 @@ - name: Check Licenses run: {{rootNpmPath}} run licenses - smoke-tests: - {{> jobYml jobName="Smoke Tests" }} - - name: Run Smoke Tests - run: {{rootNpmPath}} test -w smoke-tests --ignore-scripts - - name: Check Git Status - run: node scripts/git-dirty.js + smoke-tests: + # This cant be tested on Windows because our node_modules directory + # checks in symlinks which are not supported there. This should be + # fixed somehow, because this means some forms of local development + # are likely broken on Windows as well. + {{> jobYml + jobName="Smoke Tests" + jobCheckout=(obj ref="${{ inputs.ref }}") + jobCreateCheck=(obj sha="${{ inputs.check-sha }}") + windowsCI=false + macCI=false + }} + - name: Smoke Tests + run: ./scripts/smoke-tests.sh + - name: Conclude Check + uses: LouisBrunner/checks-action@v1.6.0 + if: steps.create-check.outputs.check-id && always() + with: + token: $\{{ secrets.GITHUB_TOKEN }} + conclusion: $\{{ job.status }} + check_id: $\{{ steps.create-check.outputs.check-id }} + + publish-dryrun: + # This cant be tested on Windows because our node_modules directory + # checks in symlinks which are not supported there. This should be + # fixed somehow, because this means some forms of local development + # are likely broken on Windows as well. + {{> jobYml + jobName="Publish Dry-Run" + jobCheckout=(obj ref="${{ inputs.ref }}") + jobCreateCheck=(obj sha="${{ inputs.check-sha }}") + windowsCI=false + macCI=false + }} + - name: Publish Dry-Run + run: node ./scripts/publish.js --pack-destination=$RUNNER_TEMP --smoke-publish=true + - name: Conclude Check + uses: LouisBrunner/checks-action@v1.6.0 + if: steps.create-check.outputs.check-id && always() + with: + token: $\{{ secrets.GITHUB_TOKEN }} + conclusion: $\{{ job.status }} + check_id: $\{{ steps.create-check.outputs.check-id }} windows-shims: name: Windows Shims Tests