CI - Release #33
Workflow file for this run
This file contains 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
# This file is automatically added by @npmcli/template-oss. Do not edit. | |
name: CI - Release | |
on: | |
workflow_dispatch: | |
inputs: | |
ref: | |
required: true | |
type: string | |
default: latest | |
workflow_call: | |
inputs: | |
ref: | |
required: true | |
type: string | |
check-sha: | |
required: true | |
type: string | |
jobs: | |
lint-all: | |
name: Lint All | |
if: github.repository_owner == 'npm' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Get Workflow Job | |
uses: actions/github-script@v6 | |
if: inputs.check-sha | |
id: check-output | |
env: | |
JOB_NAME: "Lint All" | |
MATRIX_NAME: "" | |
with: | |
script: | | |
const { owner, repo } = context.repo | |
const { data } = await github.rest.actions.listJobsForWorkflowRun({ | |
owner, | |
repo, | |
run_id: context.runId, | |
per_page: 100 | |
}) | |
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME | |
const job = data.jobs.find(j => j.name.endsWith(jobName)) | |
const jobUrl = job?.html_url | |
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}` | |
let summary = `This check is assosciated with ${shaUrl}\n\n` | |
if (jobUrl) { | |
summary += `For run logs, click here: ${jobUrl}` | |
} else { | |
summary += `Run logs could not be found for a job with name: "${jobName}"` | |
} | |
return { summary } | |
- name: Create Check | |
uses: LouisBrunner/[email protected] | |
id: check | |
if: inputs.check-sha | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: in_progress | |
name: Lint All | |
sha: ${{ inputs.check-sha }} | |
output: ${{ steps.check-output.outputs.result }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ inputs.ref }} | |
- name: Setup Git User | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "npm CLI robot" | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
id: node | |
with: | |
node-version: 20.x | |
check-latest: contains('20.x', '.x') | |
cache: npm | |
- name: Check Git Status | |
run: node scripts/git-dirty.js | |
- name: Reset Deps | |
run: node scripts/resetdeps.js | |
- name: Lint | |
run: node . run lint --ignore-scripts -ws -iwr --if-present | |
- name: Post Lint | |
run: node . run postlint --ignore-scripts -ws -iwr --if-present | |
- name: Conclude Check | |
uses: LouisBrunner/[email protected] | |
if: steps.check.outputs.check_id && always() | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
conclusion: ${{ job.status }} | |
check_id: ${{ steps.check.outputs.check_id }} | |
test-all: | |
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }} | |
if: github.repository_owner == 'npm' | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- name: Linux | |
os: ubuntu-latest | |
shell: bash | |
- name: macOS | |
os: macos-latest | |
shell: bash | |
- name: Windows | |
os: windows-latest | |
shell: cmd | |
node-version: | |
- 18.17.0 | |
- 18.x | |
- 20.5.0 | |
- 20.x | |
runs-on: ${{ matrix.platform.os }} | |
defaults: | |
run: | |
shell: ${{ matrix.platform.shell }} | |
steps: | |
- name: Get Workflow Job | |
uses: actions/github-script@v6 | |
if: inputs.check-sha | |
id: check-output | |
env: | |
JOB_NAME: "Test All" | |
MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}" | |
with: | |
script: | | |
const { owner, repo } = context.repo | |
const { data } = await github.rest.actions.listJobsForWorkflowRun({ | |
owner, | |
repo, | |
run_id: context.runId, | |
per_page: 100 | |
}) | |
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME | |
const job = data.jobs.find(j => j.name.endsWith(jobName)) | |
const jobUrl = job?.html_url | |
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}` | |
let summary = `This check is assosciated with ${shaUrl}\n\n` | |
if (jobUrl) { | |
summary += `For run logs, click here: ${jobUrl}` | |
} else { | |
summary += `Run logs could not be found for a job with name: "${jobName}"` | |
} | |
return { summary } | |
- name: Create Check | |
uses: LouisBrunner/[email protected] | |
id: check | |
if: inputs.check-sha | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: in_progress | |
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }} | |
sha: ${{ inputs.check-sha }} | |
output: ${{ steps.check-output.outputs.result }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ inputs.ref }} | |
- name: Setup Git User | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "npm CLI robot" | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
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: Add Problem Matcher | |
run: echo "::add-matcher::.github/matchers/tap.json" | |
- name: Test | |
run: node . test --ignore-scripts -ws -iwr --if-present | |
- name: Check Git Status | |
run: node scripts/git-dirty.js | |
- name: Conclude Check | |
uses: LouisBrunner/[email protected] | |
if: steps.check.outputs.check_id && always() | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
conclusion: ${{ job.status }} | |
check_id: ${{ steps.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 }} | |
if: github.repository_owner == 'npm' | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- name: Linux | |
os: ubuntu-latest | |
shell: bash | |
- name: macOS | |
os: macos-latest | |
shell: bash | |
node-version: | |
- 18.17.0 | |
- 18.x | |
- 20.5.0 | |
- 20.x | |
runs-on: ${{ matrix.platform.os }} | |
defaults: | |
run: | |
shell: ${{ matrix.platform.shell }} | |
steps: | |
- name: Get Workflow Job | |
uses: actions/github-script@v6 | |
if: inputs.check-sha | |
id: check-output | |
env: | |
JOB_NAME: "Smoke Publish" | |
MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}" | |
with: | |
script: | | |
const { owner, repo } = context.repo | |
const { data } = await github.rest.actions.listJobsForWorkflowRun({ | |
owner, | |
repo, | |
run_id: context.runId, | |
per_page: 100 | |
}) | |
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME | |
const job = data.jobs.find(j => j.name.endsWith(jobName)) | |
const jobUrl = job?.html_url | |
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}` | |
let summary = `This check is assosciated with ${shaUrl}\n\n` | |
if (jobUrl) { | |
summary += `For run logs, click here: ${jobUrl}` | |
} else { | |
summary += `Run logs could not be found for a job with name: "${jobName}"` | |
} | |
return { summary } | |
- name: Create Check | |
uses: LouisBrunner/[email protected] | |
id: check | |
if: inputs.check-sha | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: in_progress | |
name: Smoke Publish - ${{ matrix.platform.name }} - ${{ matrix.node-version }} | |
sha: ${{ inputs.check-sha }} | |
output: ${{ steps.check-output.outputs.result }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ inputs.ref }} | |
- name: Setup Git User | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "npm CLI robot" | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
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: Pack | |
env: | |
SMOKE_PUBLISH_NPM: 1 | |
run: | | |
NPM_VERSION="$(node . --version)-$GITHUB_SHA.0" | |
node . version $NPM_VERSION --ignore-scripts | |
node scripts/publish.js --pack-destination=$RUNNER_TEMP | |
export SMOKE_PUBLISH_TARBALL="$RUNNER_TEMP/npm-$NPM_VERSION.tgz" | |
node . install --global $SMOKE_PUBLISH_TARBALL | |
node . install -w smoke-tests --ignore-scripts --no-audit --no-fund | |
# call installed npm instead of local source since we are testing | |
# the packed tarball that we just installed globally | |
NPM_GLOBAL_VERSION="$(npm --version)" | |
npm help | |
if [ "$NPM_GLOBAL_VERSION" == "$NPM_VERSION" ]; then | |
npm test -w smoke-tests --ignore-scripts | |
else | |
echo "global npm is not the correct version for smoke-publish" | |
echo "found: $NPM_GLOBAL_VERSION, expected: $NPM_VERSION" | |
exit 1 | |
fi | |
- name: Conclude Check | |
uses: LouisBrunner/[email protected] | |
if: steps.check.outputs.check_id && always() | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
conclusion: ${{ job.status }} | |
check_id: ${{ steps.check.outputs.check_id }} |