Skip to content

chore: splits out smoke-tests from publish-dryrun tests #8069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 68 additions & 7 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ 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.
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 Publish - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
Expand Down Expand Up @@ -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: Smoke Publish - ${{ 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: "Smoke Publish - ${{ 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: ./scripts/publish-dryrun.sh
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
if: steps.create-check.outputs.check-id && always()
Expand Down
106 changes: 99 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,34 +147,126 @@ jobs:
run: node . run licenses

smoke-tests:
name: 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 Publish - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
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: bash
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: "Smoke Publish - ${{ 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: 22.x
check-latest: contains('22.x', '.x')
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: 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: Smoke Publish - ${{ 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: "Smoke Publish - ${{ 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: ./scripts/publish-dryrun.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 }}

windows-shims:
name: Windows Shims Tests
Expand Down
82 changes: 82 additions & 0 deletions scripts/publish-dryrun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash

set -eo pipefail

IS_LOCAL="false"
IS_CI="true"

if [ -z "$CI" ]; then
echo "Running locally will overwrite your globally installed npm."
GITHUB_SHA=$(git rev-parse HEAD)
RUNNER_TEMP=$(mktemp -d)
IS_LOCAL="true"
IS_CI="false"
fi

if [ -z "$GITHUB_SHA" ]; then
echo "Error: GITHUB_SHA is required"
exit 1
fi

if [ -z "$RUNNER_TEMP" ]; then
echo "Error: RUNNER_TEMP is required"
exit 1
fi

ORIGINAL_GLOBAL_NPM_VERSION=$(npm --version)
if [ ${#ORIGINAL_GLOBAL_NPM_VERSION} -gt 40 ]; then
echo "Error: Global npm version already contains a git SHA ${ORIGINAL_GLOBAL_NPM_VERSION}"
exit 1
fi

ORIGINAL_LOCAL_NPM_VERSION=$(node . --version)
if [ ${#ORIGINAL_LOCAL_NPM_VERSION} -gt 40 ]; then
echo "Error: Local npm version already contains a git SHA ${ORIGINAL_LOCAL_NPM_VERSION}"
exit 1
fi
NPM_VERSION="$ORIGINAL_LOCAL_NPM_VERSION-$GITHUB_SHA.0"

# Only cleanup locally
if [ "$IS_LOCAL" == "true" ]; then
function cleanup {
npm pkg set version=$ORIGINAL_LOCAL_NPM_VERSION
node scripts/resetdeps.js
if [ "$(git rev-parse HEAD)" != "$GITHUB_SHA" ]; then
echo "==================================="
echo "==================================="
echo "HEAD is on a different commit."
echo "==================================="
echo "==================================="
fi
if [ "$(npm --version)" == "$NPM_VERSION" ]; then
echo "==================================="
echo "==================================="
echo "Global npm version has changed to $NPM_VERSION"
echo "Run the following to change it back"
echo "npm install npm@$ORIGINAL_GLOBAL_NPM_VERSION -g"
echo "==================================="
echo "==================================="
fi
}
trap cleanup EXIT
fi

# Version the local source of npm with the current git sha and
# and pack and install it globally the same way we would if we
# 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 . pack . --pack-destination "$RUNNER_TEMP"
NPM_TARBALL="$RUNNER_TEMP/npm-$NPM_VERSION.tgz"
node . install --global $NPM_TARBALL

# Only run the tests if we are sure we have the right version
# otherwise the tests being run are pointless
NPM_GLOBAL_VERSION="$(npm --version)"
if [ "$NPM_GLOBAL_VERSION" != "$NPM_VERSION" ]; then
echo "global npm is not the correct version for smoke-publish"
echo "found: $NPM_GLOBAL_VERSION, expected: $NPM_VERSION"
exit 1
fi

node scripts/publish.js --pack-destination=$RUNNER_TEMP --smoke-publish=true
2 changes: 1 addition & 1 deletion scripts/smoke-publish-test.sh → scripts/smoke-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
66 changes: 44 additions & 22 deletions scripts/template-oss/ci-release-yml.hbs
Original file line number Diff line number Diff line change
@@ -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 Publish"
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="Smoke Publish"
jobCheckout=(obj ref="${{ inputs.ref }}")
jobCreateCheck=(obj sha="${{ inputs.check-sha }}")
windowsCI=false
macCI=false
}}
- name: Publish Dry-Run
run: ./scripts/publish-dryrun.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 }}
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy