From 5b655374771b62c572800dd56f44c102f863ba73 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 16 Sep 2022 12:46:48 -0700 Subject: [PATCH] feat: add names to all jobs and steps --- .github/workflows/audit.yml | 20 +- .github/workflows/ci-release.yml | 104 ++ .github/workflows/ci.yml | 66 +- .github/workflows/codeql-analysis.yml | 5 +- .github/workflows/post-dependabot.yml | 44 +- .github/workflows/pull-request.yml | 35 +- .github/workflows/release-please.yml | 102 -- .github/workflows/release.yml | 159 +- lib/config.js | 2 + lib/content/_run-lint.yml | 4 + lib/content/_run-test.yml | 4 + lib/content/_setup-ci-on.yml | 16 +- lib/content/_setup-deps.yml | 2 +- lib/content/_setup-git.yml | 8 +- lib/content/_setup-job-matrix.yml | 23 +- lib/content/_setup-job.yml | 8 +- lib/content/_setup-node.yml | 17 +- lib/content/audit.yml | 6 +- lib/content/ci-release.yml | 20 + lib/content/ci.yml | 16 +- lib/content/codeql-analysis.yml | 6 +- lib/content/commitlintrc.js | 2 +- lib/content/dependabot.yml | 4 +- lib/content/eslintrc.js | 2 +- lib/content/gitignore | 2 +- lib/content/index.js | 19 +- lib/content/npmrc | 2 +- lib/content/pkg.json | 38 +- ...t-template-oss.yml => post-dependabot.yml} | 29 +- lib/content/pull-request.yml | 21 +- lib/content/release-please-config.json | 8 +- lib/content/release-please-manifest.json | 2 +- lib/content/release-please.yml | 37 +- lib/content/release.yml | 80 +- lib/util/parser.js | 4 +- .../test/apply/files-snapshots.js.test.cjs | 12 +- .../test/apply/source-snapshots.js.test.cjs | 1467 ++++++++++------- .../test/check/diff-snapshots.js.test.cjs | 44 +- .../test/check/snapshots.js.test.cjs | 8 +- test/apply/index.js | 12 +- 40 files changed, 1440 insertions(+), 1020 deletions(-) create mode 100644 .github/workflows/ci-release.yml delete mode 100644 .github/workflows/release-please.yml create mode 100644 lib/content/_run-lint.yml create mode 100644 lib/content/_run-test.yml create mode 100644 lib/content/ci-release.yml rename lib/content/{post-template-oss.yml => post-dependabot.yml} (64%) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index ad5724cb..3075dcd2 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -10,19 +10,25 @@ on: jobs: audit: + name: Audit if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund --package-lock - - run: npm audit + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund --package-lock + - name: Run Audit + run: npm audit diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml new file mode 100644 index 00000000..06ad6832 --- /dev/null +++ b/.github/workflows/ci-release.yml @@ -0,0 +1,104 @@ +# This file is automatically added by @npmcli/template-oss. Do not edit. + +name: CI - Release + +on: + workflow_call: + inputs: + ref: + required: true + type: string + +jobs: + lint-all: + name: Lint All + if: github.repository_owner == 'npm' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + 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: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.x + - name: Install npm@latest + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts + + test-all: + name: Test All - ${{ matrix.platform.name }} - Node ${{ 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: + - 14.17.0 + - 14.x + - 16.13.0 + - 16.x + - 18.0.0 + - 18.x + runs-on: ${{ matrix.platform.os }} + defaults: + run: + shell: ${{ matrix.platform.shell }} + steps: + - name: Checkout + uses: actions/checkout@v3 + 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: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - name: Update Windows npm + # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) + run: | + curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz + tar xf npm-7.5.4.tgz + cd package + node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz + cd .. + rmdir /s /q package + - name: Install npm@7 + if: startsWith(matrix.node-version, '10.') + run: npm i --prefer-online --no-fund --no-audit -g npm@7 + - name: Install npm@latest + if: ${{ !startsWith(matrix.node-version, '10.') }} + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher + run: echo "::add-matcher::.github/matchers/tap.json" + - name: Test + run: npm test --ignore-scripts -ws -iwr --if-present diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a408379..72313a12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,28 +15,47 @@ on: jobs: lint: + name: Lint if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts test: + name: Test - ${{ matrix.platform.name }} - Node ${{ 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: - 14.17.0 - 14.x @@ -44,27 +63,22 @@ jobs: - 16.x - 18.0.0 - 18.x - platform: - - os: ubuntu-latest - shell: bash - - os: macos-latest - shell: bash - - os: windows-latest - shell: cmd runs-on: ${{ matrix.platform.os }} defaults: run: shell: ${{ matrix.platform.shell }} steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - name: Update to workable npm (windows) + - name: Update Windows npm # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) run: | @@ -74,15 +88,17 @@ jobs: node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz cd .. rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 + - name: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest + - name: Install npm@latest if: ${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm test --ignore-scripts + - name: Test + run: npm test --ignore-scripts -iwr diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 9ee98746..66b9498a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -24,8 +24,9 @@ jobs: contents: read security-events: write steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" diff --git a/.github/workflows/post-dependabot.yml b/.github/workflows/post-dependabot.yml index 7250c499..e2a7834c 100644 --- a/.github/workflows/post-dependabot.yml +++ b/.github/workflows/post-dependabot.yml @@ -1,6 +1,6 @@ # This file is automatically added by @npmcli/template-oss. Do not edit. -name: Post Dependabot Actions +name: Post Dependabot on: pull_request @@ -8,50 +8,60 @@ permissions: contents: write jobs: - template-oss-apply: + template-oss: + name: "@npmcli/template-oss" if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head_ref }} - - name: Setup git user + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Dependabot metadata + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Fetch Dependabot Metadata id: metadata uses: dependabot/fetch-metadata@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Get command flags + # Dependabot can update multiple directories so we output which directory + # it is acting on so we can run the command for the correct root or workspace + - name: Get Dependabot Directory if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss') id: flags run: | - if [[ "${{steps.metadata.outputs.directory}}" == "/" ]]; then + if [[ "${{ steps.metadata.outputs.directory }}" == "/" ]]; then echo "::set-output name=workspace::-iwr" else echo "::set-output name=workspace::-w ${{ steps.metadata.outputs.directory }}" fi - - name: Apply changes + - name: Apply Changes if: steps.flags.outputs.workspace id: apply run: | - npm run template-oss-apply ${{steps.flags.outputs.workspace}} + npm run template-oss-apply ${{ steps.flags.outputs.workspace }} if [[ `git status --porcelain` ]]; then echo "::set-output name=changes::true" fi - - name: Push all changes + # This step will fail if template-oss has made any workflow updates. It is impossible + # for a workflow to update other workflows. In the case it does fail, we continue + # and then try to apply only a portion of the changes in the next step + - name: Push All Changes if: steps.apply.outputs.changes id: push continue-on-error: true @@ -61,7 +71,7 @@ jobs: git commit -am "chore: postinstall for dependabot template-oss PR" git push - - name: Push all except workflows + - name: Push All Changes Except Workflows if: steps.push.outcome == 'failure' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -72,7 +82,7 @@ jobs: git commit -am "chore: postinstall for dependabot template-oss PR" git push - - name: Verify changes + - name: Check Changes if: steps.apply.outputs.changes run: | - npm exec --offline ${{steps.flags.outputs.workspace}} -- template-oss-check + npm exec --offline ${{ steps.flags.outputs.workspace }} -- template-oss-check diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index cb11e7a2..cf0390a6 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,6 +1,6 @@ # This file is automatically added by @npmcli/template-oss. Do not edit. -name: Pull Request Linting +name: Pull Request on: pull_request: @@ -11,28 +11,35 @@ on: - synchronize jobs: - check: - name: Check PR Title or Commits + commitlint: + name: Lint Commits if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Setup git user + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Check commits or PR title - env: - PR_TITLE: ${{ github.event.pull_request.title }} + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Commitlint on Commits + id: commit + continue-on-error: true run: | - npx --offline commitlint -V --from origin/main --to ${{ github.event.pull_request.head.sha }} \ - || echo $PR_TITLE | npx --offline commitlint -V + npx --offline commitlint -V --from origin/${{ github.base_ref }} --to ${{ github.event.pull_request.head.sha }} + - name: Run Commitlint on PR Title + if: steps.commit.outcome == 'failure' + run: | + echo ${{ github.event.pull_request.title }} | npx --offline commitlint -V diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml deleted file mode 100644 index ae8dc424..00000000 --- a/.github/workflows/release-please.yml +++ /dev/null @@ -1,102 +0,0 @@ -# This file is automatically added by @npmcli/template-oss. Do not edit. - -name: Release Please - -on: - push: - branches: - - main - - latest - -permissions: - contents: write - pull-requests: write - -jobs: - release-please: - outputs: - pr: ${{ steps.release.outputs.pr }} - release: ${{ steps.release.outputs.release }} - if: github.repository_owner == 'npm' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup git user - run: | - git config --global user.email "npm-cli+bot@github.com" - git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Update npm to latest - run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Release Please - id: release - run: npx --offline template-oss-release-please ${{ github.ref_name }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - post-pr: - needs: release-please - if: needs.release-please.outputs.pr - runs-on: ubuntu-latest - outputs: - ref: ${{ steps.ref.outputs.branch }} - steps: - - name: Output ref - id: ref - run: echo "::set-output name=branch::${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}" - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ steps.ref.outputs.branch }} - - name: Setup git user - run: | - git config --global user.email "npm-cli+bot@github.com" - git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Update npm to latest - run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Post pull request actions - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - npm run rp-pull-request --ignore-scripts --if-present -ws -iwr - git commit -am "chore: post pull request" || true - git push - - release-test: - needs: post-pr - if: needs.post-pr.outputs.ref - uses: ./.github/workflows/release.yml - with: - ref: ${{ needs.post-pr.outputs.ref }} - - post-release: - needs: release-please - if: github.repository_owner == 'npm' && needs.release-please.outputs.release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup git user - run: | - git config --global user.email "npm-cli+bot@github.com" - git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Update npm to latest - run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Post release actions - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - npm run rp-release --ignore-scripts --if-present -ws -iwr diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3bc79b94..34420f6f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,86 +3,119 @@ name: Release on: - workflow_call: - inputs: - ref: - required: true - type: string + push: + branches: + - main + - latest + +permissions: + contents: write + pull-requests: write jobs: - lint-all: + release-please: + name: Release Please + outputs: + pr: ${{ steps.release.outputs.pr }} + release: ${{ steps.release.outputs.release }} if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - ref: ${{ inputs.ref }} - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint -ws -iwr --if-present + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: npx template-oss-release-please ${{ github.ref_name }} + id: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npx --offline template-oss-release-please ${{ github.ref_name }} - test-all: - if: github.repository_owner == 'npm' - strategy: - fail-fast: false - matrix: - node-version: - - 14.17.0 - - 14.x - - 16.13.0 - - 16.x - - 18.0.0 - - 18.x - platform: - - os: ubuntu-latest - shell: bash - - os: macos-latest - shell: bash - - os: windows-latest - shell: cmd - runs-on: ${{ matrix.platform.os }} - defaults: - run: - shell: ${{ matrix.platform.shell }} + post-pr: + name: Post Pull Request + needs: release-please + if: needs.release-please.outputs.pr + runs-on: ubuntu-latest + outputs: + ref: ${{ steps.ref.outputs.branch }} + sha: ${{ steps.commit.outputs.sha }} steps: - - uses: actions/checkout@v3 + - name: Output PR Head Branch + id: ref + run: echo "::set-output name=branch::${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}" + - name: Checkout + uses: actions/checkout@v3 with: - ref: ${{ inputs.ref }} - - name: Setup git user + fetch-depth: 0 + ref: ${{ steps.ref.outputs.branch }} + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - - name: Update to workable npm (windows) - # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows - if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) + node-version: 18.x + - name: Install npm@latest + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Post Pull Request Actions + run: npm run rp-pull-request --ignore-scripts -ws -iwr --if-present + - name: Commit and Push + id: commit + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git commit -am "chore: post pull request" || true + echo "::set-output sha=$(git rev-parse HEAD)" + git push + + release-test: + name: Test + needs: post-pr + if: needs.post-pr.outputs.ref + uses: ./.github/workflows/ci-release.yml + with: + ref: ${{ needs.post-pr.outputs.ref }} + sha: ${{ needs.post-pr.outputs.sha }} + + post-release: + name: Post Release + needs: release-please + if: github.repository_owner == 'npm' && needs.release-please.outputs.release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | - curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz - tar xf npm-7.5.4.tgz - cd package - node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz - cd .. - rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 - if: startsWith(matrix.node-version, '10.') - run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest - if: ${{ !startsWith(matrix.node-version, '10.') }} + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.x + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher - run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm run test -ws -iwr --if-present + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Post Release Actions + run: | + npm run rp-release --ignore-scripts -ws -iwr --if-present diff --git a/lib/config.js b/lib/config.js index 35f56499..e5871f49 100644 --- a/lib/config.js +++ b/lib/config.js @@ -176,6 +176,8 @@ const getFullConfig = async ({ pkgPath, pkgDir: posixDir(pkgPath), pkgGlob: posixGlob(pkgPath), + pkgFlags: isRoot ? '-iwr' : `-w ${pkgJson.name}`, + allFlags: '-ws -iwr --if-present', workspacePaths, workspaceGlobs: workspacePaths.map(posixGlob), // booleans to control application of updates diff --git a/lib/content/_run-lint.yml b/lib/content/_run-lint.yml new file mode 100644 index 00000000..7070daee --- /dev/null +++ b/lib/content/_run-lint.yml @@ -0,0 +1,4 @@ +- name: Lint + run: {{ rootNpmPath }} run lint --ignore-scripts +- name: Post Lint + run: {{ rootNpmPath }} run postlint --ignore-scripts diff --git a/lib/content/_run-test.yml b/lib/content/_run-test.yml new file mode 100644 index 00000000..2a869cd9 --- /dev/null +++ b/lib/content/_run-test.yml @@ -0,0 +1,4 @@ +- name: Add Problem Matcher + run: echo "::add-matcher::.github/matchers/tap.json" +- name: Test + run: {{ rootNpmPath }} test --ignore-scripts {{~#if jobRunFlags}} {{ jobRunFlags }}{{/if}} diff --git a/lib/content/_setup-ci-on.yml b/lib/content/_setup-ci-on.yml index 29010620..1352a8b1 100644 --- a/lib/content/_setup-ci-on.yml +++ b/lib/content/_setup-ci-on.yml @@ -2,27 +2,27 @@ workflow_dispatch: pull_request: {{#if isWorkspace}} paths: - - {{pkgGlob}} + - {{ pkgGlob }} {{/if}} {{#if isRootMono}} paths-ignore: - {{#each workspaceGlobs}} - - {{.}} + {{#each workspaceGlob}} + - {{ . }} {{/each}} {{/if}} push: branches: {{#each branches}} - - {{.}} + - {{ . }} {{/each}} {{#if isWorkspace}} paths: - - {{pkgGlob}} + - {{ pkgGlob }} {{/if}} - {{# if isRootMono}} + {{#if isRootMono}} paths-ignore: - {{#each workspaceGlobs}} - - {{.}} + {{#each workspaceGlob}} + - {{ . }} {{/each}} {{/if}} schedule: diff --git a/lib/content/_setup-deps.yml b/lib/content/_setup-deps.yml index 0b011fc1..de65db92 100644 --- a/lib/content/_setup-deps.yml +++ b/lib/content/_setup-deps.yml @@ -1,2 +1,2 @@ - name: Install Dependencies - run: {{rootNpmPath}} i --ignore-scripts --no-audit --no-fund {{~#if flags}} {{flags}}{{/if}} + run: {{ rootNpmPath }} i --ignore-scripts --no-audit --no-fund {{~#if jobDepFlags}} {{ jobDepFlags }}{{/if}} diff --git a/lib/content/_setup-git.yml b/lib/content/_setup-git.yml index b0c4c805..3878fef4 100644 --- a/lib/content/_setup-git.yml +++ b/lib/content/_setup-git.yml @@ -1,12 +1,12 @@ - name: Checkout uses: actions/checkout@v3 -{{#if checkout}} +{{#if jobCheckout}} with: - {{#each checkout}} - {{@key}}: {{this}} + {{#each jobCheckout}} + {{ @key }}: {{ this }} {{/each}} {{/if}} -- name: Setup git user +- name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" diff --git a/lib/content/_setup-job-matrix.yml b/lib/content/_setup-job-matrix.yml index 5a614cc1..8898fcb7 100644 --- a/lib/content/_setup-job-matrix.yml +++ b/lib/content/_setup-job-matrix.yml @@ -2,26 +2,29 @@ if: github.repository_owner == 'npm' strategy: fail-fast: false matrix: - node-version: - {{#each ciVersions}} - - {{.}} - {{/each}} platform: - - os: ubuntu-latest + - name: Linux + os: ubuntu-latest shell: bash {{#if macCI}} - - os: macos-latest + - name: macOS + os: macos-latest shell: bash {{/if}} {{#if windowsCI}} - - os: windows-latest + - name: Windows + os: windows-latest shell: cmd {{/if}} + node-version: + {{#each ciVersions}} + - {{ . }} + {{/each}} runs-on: $\{{ matrix.platform.os }} defaults: run: shell: $\{{ matrix.platform.shell }} steps: - {{> setupGit}} - {{> setupNode useMatrix=true}} - {{> setupDeps}} + {{> setupGit }} + {{> setupNode jobUseMatrix=true }} + {{> setupDeps }} diff --git a/lib/content/_setup-job.yml b/lib/content/_setup-job.yml index a9cec5b8..60684704 100644 --- a/lib/content/_setup-job.yml +++ b/lib/content/_setup-job.yml @@ -1,6 +1,6 @@ -if: github.repository_owner == 'npm' {{~#if jobIf}} && {{{jobIf}}}{{/if}} +if: github.repository_owner == 'npm' {{~#if jobIf}} && {{{ jobIf }}}{{/if}} runs-on: ubuntu-latest steps: - {{> setupGit}} - {{> setupNode}} - {{> setupDeps}} + {{> setupGit }} + {{> setupNode }} + {{> setupDeps }} diff --git a/lib/content/_setup-node.yml b/lib/content/_setup-node.yml index 93e05329..97cd88d7 100644 --- a/lib/content/_setup-node.yml +++ b/lib/content/_setup-node.yml @@ -1,13 +1,13 @@ -- name: Setup Node {{#if useMatrix}}$\{{ matrix.node-version }}{{else}}{{last ciVersions}}{{/if}} -- uses: actions/setup-node@v3 +- name: Setup Node + uses: actions/setup-node@v3 with: - node-version: {{#if useMatrix}}$\{{ matrix.node-version }}{{else}}{{last ciVersions}}{{/if}} + node-version: {{#if jobUseMatrix}}$\{{ matrix.node-version }}{{else}}{{ last ciVersions }}{{/if}} {{#if lockfile}} cache: npm {{/if}} {{#if updateNpm}} -{{#if useMatrix}} -- name: Update to workable npm (windows) +{{#if jobUseMatrix}} +- name: Update Windows npm # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) run: | @@ -17,14 +17,13 @@ node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz cd .. rmdir /s /q package -- name: npm@7 - # If we do test on npm 10 it needs npm7 +- name: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 -- name: npm@latest +- name: Install npm@latest if: $\{{ !startsWith(matrix.node-version, '10.') }} {{else}} -- name: npm@latest +- name: Install npm@latest {{/if}} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version diff --git a/lib/content/audit.yml b/lib/content/audit.yml index 3a60183b..99fd5560 100644 --- a/lib/content/audit.yml +++ b/lib/content/audit.yml @@ -9,6 +9,6 @@ on: jobs: audit: name: Audit - {{> setupJob flags="--package-lock"}} - - name: npm audit - run: {{rootNpmPath}} audit + {{> setupJob jobDepFlags="--package-lock" }} + - name: Run Audit + run: {{ rootNpmPath }} audit diff --git a/lib/content/ci-release.yml b/lib/content/ci-release.yml new file mode 100644 index 00000000..9b646936 --- /dev/null +++ b/lib/content/ci-release.yml @@ -0,0 +1,20 @@ + +name: CI - Release + +on: + workflow_call: + inputs: + ref: + required: true + type: string + +jobs: + lint-all: + name: Lint All + {{> setupJob jobCheckout=(obj ref="${{ inputs.ref }}") }} + {{> runLint jobRunFlags=allFlags }} + + test-all: + name: Test All - $\{{ matrix.platform.name }} - Node $\{{ matrix.node-version }} + {{> setupJobMatrix jobCheckout=(obj ref="${{ inputs.ref }}") }} + {{> runTest jobRunFlags=allFlags }} diff --git a/lib/content/ci.yml b/lib/content/ci.yml index a9c93b1e..c1771cad 100644 --- a/lib/content/ci.yml +++ b/lib/content/ci.yml @@ -1,21 +1,15 @@ -name: CI {{~#if isWorkspace}} - {{pkgName}}{{/if}} +name: CI {{~#if isWorkspace}} - {{ pkgName }}{{/if}} on: - {{> setupCiOn}} + {{> setupCiOn }} jobs: lint: name: Lint {{> setupJob }} - - name: npm run lint {{~#if isWorkspace}} -w {{pkgName}}{{/if}} - run: {{rootNpmPath}} run lint --ignore-scripts {{~#if isWorkspace}} -w {{pkgName}}{{/if}} - - name: npm run postlint {{~#if isWorkspace}} -w {{pkgName}}{{/if}} - run: {{rootNpmPath}} run postlint --ignore-scripts {{~#if isWorkspace}} -w {{pkgName}}{{/if}} + {{> runLint jobRunFlags=pkgFlags }} test: - name: Test + name: Test - $\{{ matrix.platform.name }} - Node $\{{ matrix.node-version }} {{> setupJobMatrix }} - - name: Add tap Problem Matcher - run: echo "::add-matcher::.github/matchers/tap.json" - - name: npm test {{~#if isWorkspace}} -w {{pkgName}}{{/if}} - run: {{rootNpmPath}} test --ignore-scripts {{~#if isWorkspace}} -w {{pkgName}}{{/if}} + {{> runTest jobRunFlags=pkgFlags }} diff --git a/lib/content/codeql-analysis.yml b/lib/content/codeql-analysis.yml index cb60ef15..eee7d102 100644 --- a/lib/content/codeql-analysis.yml +++ b/lib/content/codeql-analysis.yml @@ -4,12 +4,12 @@ on: push: branches: {{#each branches}} - - {{.}} + - {{ . }} {{/each}} pull_request: branches: {{#each branches}} - - {{.}} + - {{ . }} {{/each}} schedule: # "At 10:00 UTC (03:00 PT) on Monday" https://crontab.guru/#0_10_*_*_1 @@ -24,7 +24,7 @@ jobs: contents: read security-events: write steps: - {{> setupGit}} + {{> setupGit }} - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: diff --git a/lib/content/commitlintrc.js b/lib/content/commitlintrc.js index c32df00f..26966878 100644 --- a/lib/content/commitlintrc.js +++ b/lib/content/commitlintrc.js @@ -1,7 +1,7 @@ module.exports = { extends: ['@commitlint/config-conventional'], rules: { - 'type-enum': [2, 'always', [{{{join (quote (pluck changelogTypes "type"))}}}]], + 'type-enum': [2, 'always', [{{{ join (quote (pluck changelogTypes "type")) }}}]], 'header-max-length': [2, 'always', 80], 'subject-case': [0, 'always', ['lower-case', 'sentence-case', 'start-case']], }, diff --git a/lib/content/dependabot.yml b/lib/content/dependabot.yml index b5b79ef4..0f747f9d 100644 --- a/lib/content/dependabot.yml +++ b/lib/content/dependabot.yml @@ -2,12 +2,12 @@ version: 2 updates: - package-ecosystem: npm - directory: {{pkgDir}} + directory: {{ pkgDir }} schedule: interval: daily allow: - dependency-type: direct - versioning-strategy: {{dependabot}} + versioning-strategy: {{ dependabot }} commit-message: prefix: deps prefix-development: chore diff --git a/lib/content/eslintrc.js b/lib/content/eslintrc.js index d16f942e..8ee511c7 100644 --- a/lib/content/eslintrc.js +++ b/lib/content/eslintrc.js @@ -11,7 +11,7 @@ module.exports = { {{#if workspaceGlobs}} ignorePatterns: [ {{#each workspaceGlobs}} - '{{.}}', + '{{ . }}', {{/each}} ], {{/if}} diff --git a/lib/content/gitignore b/lib/content/gitignore index d85a1774..d9d4b23e 100644 --- a/lib/content/gitignore +++ b/lib/content/gitignore @@ -3,5 +3,5 @@ # keep these {{#each ignorePaths}} -{{.}} +{{ . }} {{/each}} diff --git a/lib/content/index.js b/lib/content/index.js index 8a5fe127..fa03a3c5 100644 --- a/lib/content/index.js +++ b/lib/content/index.js @@ -4,14 +4,14 @@ const isPublic = (p) => !p.pkg.private const sharedRoot = (name) => ({ // release - '.github/workflows/release-please.yml': { - file: 'release-please.yml', - filter: isPublic, - }, '.github/workflows/release.yml': { file: 'release.yml', filter: isPublic, }, + '.github/workflows/ci-release.yml': { + file: 'ci-release.yml', + filter: isPublic, + }, '.release-please-manifest.json': { file: 'release-please-manifest.json', filter: isPublic, @@ -43,11 +43,6 @@ const sharedRoot = (name) => ({ }, '.github/workflows/post-dependabot.yml': { file: 'post-dependabot.yml', - clean: (p) => p.config.isRoot, - parser: (p) => class extends p.YmlMerge { - key = ['jobs', 'template-oss-apply', 'steps'] - id = 'name' - }, }, }) @@ -65,6 +60,7 @@ const rootRepo = { }, rm: [ '.github/workflows/release-test.yml', + '.github/workflows/release-please.yml', ], } @@ -90,11 +86,11 @@ const rootModule = { // Changes for each workspace but applied to the root of the repo const workspaceRepo = { add: { - ...sharedRoot('{{pkgNameFs}}'), + ...sharedRoot('{{ pkgNameFs }}'), }, rm: [ // These are the old release please files that should be removed now - '.github/workflows/release-please-{{pkgNameFs}}.yml', + '.github/workflows/release-please-{{ pkgNameFs }}.yml', ], } @@ -121,7 +117,6 @@ module.exports = { macCI: true, branches: ['main', 'latest'], releaseBranches: [], - defaultBranch: 'main', distPaths: [ 'bin/', 'lib/', diff --git a/lib/content/npmrc b/lib/content/npmrc index 239fb98e..ebcd656b 100644 --- a/lib/content/npmrc +++ b/lib/content/npmrc @@ -1 +1 @@ -package-lock={{lockfile}} +package-lock={{ lockfile }} diff --git a/lib/content/pkg.json b/lib/content/pkg.json index c697ab83..d93cbd80 100644 --- a/lib/content/pkg.json +++ b/lib/content/pkg.json @@ -1,44 +1,44 @@ { "author": "GitHub Inc.", - "files": {{{json distPaths}}}, + "files": {{{ json distPaths }}}, "scripts": { "lint": "eslint \"**/*.js\"", "postlint": "template-oss-check", "template-oss-apply": "template-oss-apply --force", - "lintfix": "{{localNpmPath}} run lint -- --fix", - "preversion": {{{del}}}, - "postversion": {{{del}}}, - "prepublishOnly": {{{del}}}, - "postpublish": {{{del}}}, + "lintfix": "{{ localNpmPath }} run lint -- --fix", "snap": "tap", "test": "tap", - "posttest": "{{localNpmPath}} run lint", + "posttest": "{{ localNpmPath }} run lint", {{#if isRootMono}} - "test-all": "{{localNpmPath}} run test -ws -iwr --if-present", - "lint-all": "{{localNpmPath}} run lint -ws -iwr --if-present", + "test-all": "{{ localNpmPath }} run test {{ allFlags }}", + "lint-all": "{{ localNpmPath }} run lint {{ allFlags }}", {{/if}} - "template-copy": {{{del}}}, - "lint:fix": {{{del}}} + "template-copy": {{{ del }}}, + "lint:fix": {{{ del }}}, + "preversion": {{{ del }}}, + "postversion": {{{ del }}}, + "prepublishOnly": {{{ del }}}, + "postpublish": {{{ del }}} }, - "repository": {{#if repository}}{{{json repository}}}{{else}}{{{del}}}{{/if}}, + "repository": {{#if repository}}{{{ json repository }}}{{else}}{{{ del }}}{{/if}}, "engines": { {{#if engines}} - "node": {{{json engines}}} + "node": {{{ json engines }}} {{/if}} }, - {{{json __CONFIG_KEY__}}}: { - "version": {{#if isDogFood}}{{{del}}}{{else}}{{{json __VERSION__}}}{{/if}} + {{{ json __CONFIG_KEY__ }}}: { + "version": {{#if isDogFood}}{{{ del }}}{{else}}{{{ json __VERSION__ }}}{{/if}} }, - "templateVersion": {{{del}}}, - "standard": {{{del}}}, + "templateVersion": {{{ del }}}, + "standard": {{{ del }}}, "tap": { {{#if workspacePaths}} - "test-ignore": "^({{join workspacePaths "|"}})/**", + "test-ignore": "^({{ join workspacePaths "|" }})/**", {{/if}} "nyc-arg": [ {{#each workspaceGlobs}} "--exclude", - "{{this}}", + "{{ . }}", {{/each}} "--exclude", "tap-snapshots/**" diff --git a/lib/content/post-template-oss.yml b/lib/content/post-dependabot.yml similarity index 64% rename from lib/content/post-template-oss.yml rename to lib/content/post-dependabot.yml index e2c90d64..8c8a2511 100644 --- a/lib/content/post-template-oss.yml +++ b/lib/content/post-dependabot.yml @@ -1,4 +1,4 @@ -name: Post Dependabot Actions +name: Post Dependabot on: pull_request @@ -7,29 +7,32 @@ permissions: contents: write jobs: - template-oss-apply: - {{> setupJob jobIf="github.actor == 'dependabot[bot]'" checkout=(obj ref="${{ github.event.pull_request.head_ref }}")}} - - name: Dependabot metadata + template-oss: + name: "{{ __NAME__ }}" + {{> setupJob jobIf="github.actor == 'dependabot[bot]'" jobCheckout=(obj ref="${{ github.event.pull_request.head_ref }}") }} + - name: Fetch Dependabot Metadata id: metadata uses: dependabot/fetch-metadata@v1 with: github-token: $\{{ secrets.GITHUB_TOKEN }} - - name: Get command flags - if: contains(steps.metadata.outputs.dependency-names, '{{__NAME__}}') + # Dependabot can update multiple directories so we output which directory + # it is acting on so we can run the command for the correct root or workspace + - name: Get Dependabot Directory + if: contains(steps.metadata.outputs.dependency-names, '{{ __NAME__ }}') id: flags run: | - if [[ "$\{{steps.metadata.outputs.directory}}" == "/" ]]; then + if [[ "$\{{ steps.metadata.outputs.directory }}" == "/" ]]; then echo "::set-output name=workspace::-iwr" else echo "::set-output name=workspace::-w $\{{ steps.metadata.outputs.directory }}" fi - - name: Apply changes + - name: Apply Changes if: steps.flags.outputs.workspace id: apply run: | - {{rootNpmPath}} run template-oss-apply $\{{steps.flags.outputs.workspace}} + {{ rootNpmPath }} run template-oss-apply $\{{ steps.flags.outputs.workspace }} if [[ `git status --porcelain` ]]; then echo "::set-output name=changes::true" fi @@ -37,7 +40,7 @@ jobs: # This step will fail if template-oss has made any workflow updates. It is impossible # for a workflow to update other workflows. In the case it does fail, we continue # and then try to apply only a portion of the changes in the next step - - name: Push all changes + - name: Push All Changes if: steps.apply.outputs.changes id: push continue-on-error: true @@ -47,7 +50,7 @@ jobs: git commit -am "chore: postinstall for dependabot template-oss PR" git push - - name: Push all except workflows + - name: Push All Changes Except Workflows if: steps.push.outcome == 'failure' env: GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }} @@ -58,7 +61,7 @@ jobs: git commit -am "chore: postinstall for dependabot template-oss PR" git push - - name: Verify changes + - name: Check Changes if: steps.apply.outputs.changes run: | - {{rootNpmPath}} exec --offline $\{{steps.flags.outputs.workspace}} -- template-oss-check + {{ rootNpmPath }} exec --offline $\{{ steps.flags.outputs.workspace }} -- template-oss-check diff --git a/lib/content/pull-request.yml b/lib/content/pull-request.yml index 3bbc04e9..afa30a50 100644 --- a/lib/content/pull-request.yml +++ b/lib/content/pull-request.yml @@ -1,4 +1,4 @@ -name: Pull Request Linting +name: Pull Request on: pull_request: @@ -9,12 +9,15 @@ on: - synchronize jobs: - check: - name: Check PR Title or Commits - {{> setupJob checkout=(obj fetch-depth=0)}} - - name: Check commits or PR title - env: - PR_TITLE: $\{{ github.event.pull_request.title }} + commitlint: + name: Lint Commits + {{> setupJob jobCheckout=(obj fetch-depth=0) }} + - name: Run Commitlint on Commits + id: commit + continue-on-error: true run: | - {{rootNpxPath}} --offline commitlint -V --from origin/{{defaultBranch}} --to $\{{ github.event.pull_request.head.sha }} \ - || echo $PR_TITLE | npx --offline commitlint -V + {{ rootNpxPath }} --offline commitlint -V --from origin/$\{{ github.base_ref }} --to $\{{ github.event.pull_request.head.sha }} + - name: Run Commitlint on PR Title + if: steps.commit.outcome == 'failure' + run: | + echo $\{{ github.event.pull_request.title }} | {{ rootNpxPath }} --offline commitlint -V diff --git a/lib/content/release-please-config.json b/lib/content/release-please-config.json index 3efac321..3562cee3 100644 --- a/lib/content/release-please-config.json +++ b/lib/content/release-please-config.json @@ -1,12 +1,12 @@ { - "separate-pull-requests": {{{del}}}, - "plugins": {{#if isMono}}["node-workspace"]{{else}}{{{del}}}{{/if}}, + "separate-pull-requests": {{{ del }}}, + "plugins": {{#if isMono }}["node-workspace"]{{ else }}{{{ del }}}{{/if}}, "exclude-packages-from-root": true, "group-pull-request-title-pattern": "chore: release ${version}", "pull-request-title-pattern": "chore: release${component} ${version}", - "changelog-sections": {{{json changelogTypes}}}, + "changelog-sections": {{{ json changelogTypes }}}, "packages": { - "{{pkgPath}}": { + "{{ pkgPath }}": { {{#if isRoot}}"package-name": ""{{/if}} } } diff --git a/lib/content/release-please-manifest.json b/lib/content/release-please-manifest.json index 4644904b..a67fb196 100644 --- a/lib/content/release-please-manifest.json +++ b/lib/content/release-please-manifest.json @@ -1,3 +1,3 @@ { - "{{pkgPath}}": "{{pkg.version}}" + "{{ pkgPath }}": "{{ pkg.version }}" } diff --git a/lib/content/release-please.yml b/lib/content/release-please.yml index 908531cc..ecd65c9e 100644 --- a/lib/content/release-please.yml +++ b/lib/content/release-please.yml @@ -1,13 +1,13 @@ -name: Release Please +name: Release on: push: branches: {{#each branches}} - - {{.}} + - {{ . }} {{/each}} - {{#each releaseBranches}} - - {{.}} + {{#each releaseBranches }} + - {{ . }} {{/each}} permissions: @@ -16,49 +16,52 @@ permissions: jobs: release-please: + name: Release Please outputs: pr: $\{{ steps.release.outputs.pr }} release: $\{{ steps.release.outputs.release }} {{> setupJob }} - - name: Release Please + - name: npx template-oss-release-please $\{{ github.ref_name }} id: release - run: npx --offline template-oss-release-please $\{{ github.ref_name }} env: GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }} + run: {{ rootNpxPath }} --offline template-oss-release-please $\{{ github.ref_name }} post-pr: + name: Post Pull Request needs: release-please if: needs.release-please.outputs.pr runs-on: ubuntu-latest outputs: ref: $\{{ steps.ref.outputs.branch }} steps: - - name: Output ref + - name: Output PR Head Branch id: ref run: echo "::set-output name=branch::$\{{ fromJSON(needs.release-please.outputs.pr).headBranchName }}" - {{> setupGit checkout=(obj ref="${{ steps.ref.outputs.branch }}" fetch-depth=0)}} - {{> setupNode}} - {{> setupDeps}} - - name: Post pull request actions + {{> setupGit jobCheckout=(obj ref="${{ steps.ref.outputs.branch }}" fetch-depth=0) }} + {{> setupNode }} + {{> setupDeps }} + - name: Run Post Pull Request Actions + run: {{ rootNpmPath }} run rp-pull-request --ignore-scripts {{ allFlags }} + - name: Commit and Push env: GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }} run: | - {{rootNpmPath}} run rp-pull-request --ignore-scripts --if-present -ws -iwr git commit -am "chore: post pull request" || true git push release-test: + name: Test needs: post-pr if: needs.post-pr.outputs.ref - uses: ./.github/workflows/release.yml + uses: ./.github/workflows/ci-release.yml with: ref: $\{{ needs.post-pr.outputs.ref }} post-release: + name: Post Release needs: release-please {{> setupJob jobIf="needs.release-please.outputs.release" }} - - name: Post release actions - env: - GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }} + - name: Run Post Release Actions run: | - {{rootNpmPath}} run rp-release --ignore-scripts --if-present -ws -iwr + {{ rootNpmPath }} run rp-release --ignore-scripts {{ allFlags }} diff --git a/lib/content/release.yml b/lib/content/release.yml index e336fb4f..f5feb367 100644 --- a/lib/content/release.yml +++ b/lib/content/release.yml @@ -1,20 +1,72 @@ - name: Release on: - workflow_call: - inputs: - ref: - required: true - type: string + push: + branches: + {{#each branches}} + - {{ . }} + {{/each}} + {{#each releaseBranches }} + - {{ . }} + {{/each}} + +permissions: + contents: write + pull-requests: write jobs: - lint-all: - {{> setupJob checkout=(obj ref="${{ inputs.ref }}")}} - - run: {{rootNpmPath}} run lint -ws -iwr --if-present + release-please: + name: Release Please + outputs: + pr: $\{{ steps.release.outputs.pr }} + release: $\{{ steps.release.outputs.release }} + {{> setupJob }} + - name: npx template-oss-release-please $\{{ github.ref_name }} + id: release + env: + GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }} + run: {{ rootNpxPath }} --offline template-oss-release-please $\{{ github.ref_name }} + + post-pr: + name: Post Pull Request + needs: release-please + if: needs.release-please.outputs.pr + runs-on: ubuntu-latest + outputs: + ref: $\{{ steps.ref.outputs.branch }} + sha: $\{{ steps.commit.outputs.sha }} + steps: + - name: Output PR Head Branch + id: ref + run: echo "::set-output name=branch::$\{{ fromJSON(needs.release-please.outputs.pr).headBranchName }}" + {{> setupGit jobCheckout=(obj ref="${{ steps.ref.outputs.branch }}" fetch-depth=0) }} + {{> setupNode }} + {{> setupDeps }} + - name: Run Post Pull Request Actions + run: {{ rootNpmPath }} run rp-pull-request --ignore-scripts {{ allFlags }} + - name: Commit and Push + id: commit + env: + GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }} + run: | + git commit -am "chore: post pull request" || true + echo "::set-output sha=$(git rev-parse HEAD)" + git push + + + release-test: + name: Test + needs: post-pr + if: needs.post-pr.outputs.ref + uses: ./.github/workflows/ci-release.yml + with: + ref: $\{{ needs.post-pr.outputs.ref }} + sha: $\{{ needs.post-pr.outputs.sha }} - test-all: - {{> setupJobMatrix checkout=(obj ref="${{ inputs.ref }}")}} - - name: add tap problem matcher - run: echo "::add-matcher::.github/matchers/tap.json" - - run: {{rootNpmPath}} run test -ws -iwr --if-present + post-release: + name: Post Release + needs: release-please + {{> setupJob jobIf="needs.release-please.outputs.release" }} + - name: Run Post Release Actions + run: | + {{ rootNpmPath }} run rp-release --ignore-scripts {{ allFlags }} diff --git a/lib/util/parser.js b/lib/util/parser.js index 8cb94e26..f9be506c 100644 --- a/lib/util/parser.js +++ b/lib/util/parser.js @@ -34,7 +34,7 @@ const fsOk = (code) => (error) => { class Base { static types = [] - static header = 'This file is automatically added by {{__NAME__}}. Do not edit.' + static header = 'This file is automatically added by {{ __NAME__ }}. Do not edit.' comment = (v) => v merge = false // supply a merge function which runs on prepare for certain types DELETE = template.DELETE @@ -268,7 +268,7 @@ class Json extends Base { } class JsonMerge extends Json { - static header = 'This file is partially managed by {{__NAME__}}. Edits may be overwritten.' + static header = 'This file is partially managed by {{ __NAME__ }}. Edits may be overwritten.' merge = (t, s) => merge(t, s) } diff --git a/tap-snapshots/test/apply/files-snapshots.js.test.cjs b/tap-snapshots/test/apply/files-snapshots.js.test.cjs index 6c8ffbd0..b59a4af3 100644 --- a/tap-snapshots/test/apply/files-snapshots.js.test.cjs +++ b/tap-snapshots/test/apply/files-snapshots.js.test.cjs @@ -16,11 +16,11 @@ exports[`test/apply/files-snapshots.js TAP private workspace > expect resolving .github/workflows/audit.yml .github/workflows/ci-a.yml .github/workflows/ci-b.yml +.github/workflows/ci-release.yml .github/workflows/ci.yml .github/workflows/codeql-analysis.yml .github/workflows/post-dependabot.yml .github/workflows/pull-request.yml -.github/workflows/release-please.yml .github/workflows/release.yml .gitignore .npmrc @@ -45,11 +45,11 @@ exports[`test/apply/files-snapshots.js TAP turn off add/rm types > expect resolv .github/ISSUE_TEMPLATE/config.yml .github/matchers/tap.json .github/workflows/audit.yml +.github/workflows/ci-release.yml .github/workflows/ci.yml .github/workflows/codeql-analysis.yml .github/workflows/post-dependabot.yml .github/workflows/pull-request.yml -.github/workflows/release-please.yml .github/workflows/release.yml .release-please-manifest.json package.json @@ -64,11 +64,11 @@ exports[`test/apply/files-snapshots.js TAP turn off module > expect resolving Pr .github/ISSUE_TEMPLATE/config.yml .github/matchers/tap.json .github/workflows/audit.yml +.github/workflows/ci-release.yml .github/workflows/ci.yml .github/workflows/codeql-analysis.yml .github/workflows/post-dependabot.yml .github/workflows/pull-request.yml -.github/workflows/release-please.yml .github/workflows/release.yml .release-please-manifest.json package.json @@ -96,11 +96,11 @@ exports[`test/apply/files-snapshots.js TAP turn off specific files > expect reso .github/ISSUE_TEMPLATE/config.yml .github/matchers/tap.json .github/workflows/audit.yml +.github/workflows/ci-release.yml .github/workflows/ci.yml .github/workflows/codeql-analysis.yml .github/workflows/post-dependabot.yml .github/workflows/pull-request.yml -.github/workflows/release-please.yml .github/workflows/release-test.yml .github/workflows/release.yml .gitignore @@ -116,8 +116,8 @@ exports[`test/apply/files-snapshots.js TAP workspaces > expect resolving Promise .github/dependabot.yml .github/matchers/tap.json .github/workflows/ci-d.yml +.github/workflows/ci-release.yml .github/workflows/post-dependabot.yml -.github/workflows/release-please.yml .github/workflows/release.yml .release-please-manifest.json package.json @@ -139,8 +139,8 @@ exports[`test/apply/files-snapshots.js TAP workspaces only (like npm/cli) > expe .github/matchers/tap.json .github/workflows/ci-a.yml .github/workflows/ci-b.yml +.github/workflows/ci-release.yml .github/workflows/post-dependabot.yml -.github/workflows/release-please.yml .github/workflows/release.yml .release-please-manifest.json package.json diff --git a/tap-snapshots/test/apply/source-snapshots.js.test.cjs b/tap-snapshots/test/apply/source-snapshots.js.test.cjs index 13aa9fbe..75b2ac1e 100644 --- a/tap-snapshots/test/apply/source-snapshots.js.test.cjs +++ b/tap-snapshots/test/apply/source-snapshots.js.test.cjs @@ -177,22 +177,135 @@ on: jobs: audit: + name: Audit if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund --package-lock - - run: npm audit + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund --package-lock + - name: Run Audit + run: npm audit + +.github/workflows/ci-release.yml +======================================== +# This file is automatically added by @npmcli/template-oss. Do not edit. + +name: CI - Release + +on: + workflow_call: + inputs: + ref: + required: true + type: string + +jobs: + lint-all: + name: Lint All + if: github.repository_owner == 'npm' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + 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: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.x + - name: Install npm@latest + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts + + test-all: + name: Test All - \${{ matrix.platform.name }} - Node \${{ 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: + - 14.17.0 + - 14.x + - 16.13.0 + - 16.x + - 18.0.0 + - 18.x + runs-on: \${{ matrix.platform.os }} + defaults: + run: + shell: \${{ matrix.platform.shell }} + steps: + - name: Checkout + uses: actions/checkout@v3 + 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: Setup Node + uses: actions/setup-node@v3 + with: + node-version: \${{ matrix.node-version }} + - name: Update Windows npm + # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) + run: | + curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz + tar xf npm-7.5.4.tgz + cd package + node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz + cd .. + rmdir /s /q package + - name: Install npm@7 + if: startsWith(matrix.node-version, '10.') + run: npm i --prefer-online --no-fund --no-audit -g npm@7 + - name: Install npm@latest + if: \${{ !startsWith(matrix.node-version, '10.') }} + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher + run: echo "::add-matcher::.github/matchers/tap.json" + - name: Test + run: npm test --ignore-scripts -ws -iwr --if-present .github/workflows/ci.yml ======================================== @@ -213,28 +326,47 @@ on: jobs: lint: + name: Lint if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts test: + name: Test - \${{ matrix.platform.name }} - Node \${{ 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: - 14.17.0 - 14.x @@ -242,27 +374,22 @@ jobs: - 16.x - 18.0.0 - 18.x - platform: - - os: ubuntu-latest - shell: bash - - os: macos-latest - shell: bash - - os: windows-latest - shell: cmd runs-on: \${{ matrix.platform.os }} defaults: run: shell: \${{ matrix.platform.shell }} steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: \${{ matrix.node-version }} - - name: Update to workable npm (windows) + - name: Update Windows npm # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) run: | @@ -272,18 +399,20 @@ jobs: node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz cd .. rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 + - name: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest + - name: Install npm@latest if: \${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm test --ignore-scripts + - name: Test + run: npm test --ignore-scripts -iwr .github/workflows/codeql-analysis.yml ======================================== @@ -313,8 +442,9 @@ jobs: contents: read security-events: write steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" @@ -329,7 +459,7 @@ jobs: ======================================== # This file is automatically added by @npmcli/template-oss. Do not edit. -name: Post Dependabot Actions +name: Post Dependabot on: pull_request @@ -337,50 +467,60 @@ permissions: contents: write jobs: - template-oss-apply: + template-oss: + name: "@npmcli/template-oss" if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: ref: \${{ github.event.pull_request.head_ref }} - - name: Setup git user + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Dependabot metadata + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Fetch Dependabot Metadata id: metadata uses: dependabot/fetch-metadata@v1 with: github-token: \${{ secrets.GITHUB_TOKEN }} - - name: Get command flags + # Dependabot can update multiple directories so we output which directory + # it is acting on so we can run the command for the correct root or workspace + - name: Get Dependabot Directory if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss') id: flags run: | - if [[ "\${{steps.metadata.outputs.directory}}" == "/" ]]; then + if [[ "\${{ steps.metadata.outputs.directory }}" == "/" ]]; then echo "::set-output name=workspace::-iwr" else echo "::set-output name=workspace::-w \${{ steps.metadata.outputs.directory }}" fi - - name: Apply changes + - name: Apply Changes if: steps.flags.outputs.workspace id: apply run: | - npm run template-oss-apply \${{steps.flags.outputs.workspace}} + npm run template-oss-apply \${{ steps.flags.outputs.workspace }} if [[ \`git status --porcelain\` ]]; then echo "::set-output name=changes::true" fi - - name: Push all changes + # This step will fail if template-oss has made any workflow updates. It is impossible + # for a workflow to update other workflows. In the case it does fail, we continue + # and then try to apply only a portion of the changes in the next step + - name: Push All Changes if: steps.apply.outputs.changes id: push continue-on-error: true @@ -390,7 +530,7 @@ jobs: git commit -am "chore: postinstall for dependabot template-oss PR" git push - - name: Push all except workflows + - name: Push All Changes Except Workflows if: steps.push.outcome == 'failure' env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} @@ -401,16 +541,16 @@ jobs: git commit -am "chore: postinstall for dependabot template-oss PR" git push - - name: Verify changes + - name: Check Changes if: steps.apply.outputs.changes run: | - npm exec --offline \${{steps.flags.outputs.workspace}} -- template-oss-check + npm exec --offline \${{ steps.flags.outputs.workspace }} -- template-oss-check .github/workflows/pull-request.yml ======================================== # This file is automatically added by @npmcli/template-oss. Do not edit. -name: Pull Request Linting +name: Pull Request on: pull_request: @@ -421,37 +561,44 @@ on: - synchronize jobs: - check: - name: Check PR Title or Commits + commitlint: + name: Lint Commits if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Setup git user + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Check commits or PR title - env: - PR_TITLE: \${{ github.event.pull_request.title }} + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Commitlint on Commits + id: commit + continue-on-error: true + run: | + npx --offline commitlint -V --from origin/\${{ github.base_ref }} --to \${{ github.event.pull_request.head.sha }} + - name: Run Commitlint on PR Title + if: steps.commit.outcome == 'failure' run: | - npx --offline commitlint -V --from origin/main --to \${{ github.event.pull_request.head.sha }} / - || echo $PR_TITLE | npx --offline commitlint -V + echo \${{ github.event.pull_request.title }} | npx --offline commitlint -V -.github/workflows/release-please.yml +.github/workflows/release.yml ======================================== # This file is automatically added by @npmcli/template-oss. Do not edit. -name: Release Please +name: Release on: push: @@ -465,183 +612,111 @@ permissions: jobs: release-please: + name: Release Please outputs: pr: \${{ steps.release.outputs.pr }} release: \${{ steps.release.outputs.release }} if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Release Please + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: npx template-oss-release-please \${{ github.ref_name }} id: release - run: npx --offline template-oss-release-please \${{ github.ref_name }} env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} + run: npx --offline template-oss-release-please \${{ github.ref_name }} post-pr: + name: Post Pull Request needs: release-please if: needs.release-please.outputs.pr runs-on: ubuntu-latest outputs: ref: \${{ steps.ref.outputs.branch }} + sha: \${{ steps.commit.outputs.sha }} steps: - - name: Output ref + - name: Output PR Head Branch id: ref run: echo "::set-output name=branch::\${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}" - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: fetch-depth: 0 ref: \${{ steps.ref.outputs.branch }} - - name: Setup git user + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Post pull request actions + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Post Pull Request Actions + run: npm run rp-pull-request --ignore-scripts -ws -iwr --if-present + - name: Commit and Push + id: commit env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} run: | - npm run rp-pull-request --ignore-scripts --if-present -ws -iwr git commit -am "chore: post pull request" || true + echo "::set-output sha=$(git rev-parse HEAD)" git push release-test: + name: Test needs: post-pr if: needs.post-pr.outputs.ref - uses: ./.github/workflows/release.yml + uses: ./.github/workflows/ci-release.yml with: ref: \${{ needs.post-pr.outputs.ref }} + sha: \${{ needs.post-pr.outputs.sha }} post-release: + name: Post Release needs: release-please if: github.repository_owner == 'npm' && needs.release-please.outputs.release runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Post release actions - env: - GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Post Release Actions run: | - npm run rp-release --ignore-scripts --if-present -ws -iwr - -.github/workflows/release.yml -======================================== -# This file is automatically added by @npmcli/template-oss. Do not edit. - -name: Release - -on: - workflow_call: - inputs: - ref: - required: true - type: string - -jobs: - lint-all: - if: github.repository_owner == 'npm' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - 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" - - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Update npm to latest - run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint -ws -iwr --if-present - - test-all: - if: github.repository_owner == 'npm' - strategy: - fail-fast: false - matrix: - node-version: - - 14.17.0 - - 14.x - - 16.13.0 - - 16.x - - 18.0.0 - - 18.x - platform: - - os: ubuntu-latest - shell: bash - - os: macos-latest - shell: bash - - os: windows-latest - shell: cmd - runs-on: \${{ matrix.platform.os }} - defaults: - run: - shell: \${{ matrix.platform.shell }} - steps: - - uses: actions/checkout@v3 - 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" - - uses: actions/setup-node@v3 - with: - node-version: \${{ matrix.node-version }} - - name: Update to workable npm (windows) - # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows - if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) - run: | - curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz - tar xf npm-7.5.4.tgz - cd package - node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz - cd .. - rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 - if: startsWith(matrix.node-version, '10.') - run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest - if: \${{ !startsWith(matrix.node-version, '10.') }} - run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher - run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm run test -ws -iwr --if-present + npm run rp-release --ignore-scripts -ws -iwr --if-present .gitignore ======================================== @@ -994,22 +1069,28 @@ on: jobs: audit: + name: Audit if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund --package-lock - - run: npm audit + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund --package-lock + - name: Run Audit + run: npm audit .github/workflows/ci-a.yml ======================================== @@ -1034,28 +1115,47 @@ on: jobs: lint: + name: Lint if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint -w a + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts test: + name: Test - \${{ matrix.platform.name }} - Node \${{ 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: - 14.17.0 - 14.x @@ -1063,27 +1163,22 @@ jobs: - 16.x - 18.0.0 - 18.x - platform: - - os: ubuntu-latest - shell: bash - - os: macos-latest - shell: bash - - os: windows-latest - shell: cmd runs-on: \${{ matrix.platform.os }} defaults: run: shell: \${{ matrix.platform.shell }} steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: \${{ matrix.node-version }} - - name: Update to workable npm (windows) + - name: Update Windows npm # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) run: | @@ -1093,18 +1188,20 @@ jobs: node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz cd .. rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 + - name: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest + - name: Install npm@latest if: \${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm test --ignore-scripts -w a + - name: Test + run: npm test --ignore-scripts -w a .github/workflows/ci-b.yml ======================================== @@ -1129,28 +1226,47 @@ on: jobs: lint: + name: Lint if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint -w b + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts test: + name: Test - \${{ matrix.platform.name }} - Node \${{ 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: - 14.17.0 - 14.x @@ -1158,27 +1274,129 @@ jobs: - 16.x - 18.0.0 - 18.x + runs-on: \${{ matrix.platform.os }} + defaults: + run: + shell: \${{ matrix.platform.shell }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User + run: | + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: \${{ matrix.node-version }} + - name: Update Windows npm + # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) + run: | + curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz + tar xf npm-7.5.4.tgz + cd package + node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz + cd .. + rmdir /s /q package + - name: Install npm@7 + if: startsWith(matrix.node-version, '10.') + run: npm i --prefer-online --no-fund --no-audit -g npm@7 + - name: Install npm@latest + if: \${{ !startsWith(matrix.node-version, '10.') }} + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher + run: echo "::add-matcher::.github/matchers/tap.json" + - name: Test + run: npm test --ignore-scripts -w b + +.github/workflows/ci-release.yml +======================================== +# This file is automatically added by @npmcli/template-oss. Do not edit. + +name: CI - Release + +on: + workflow_call: + inputs: + ref: + required: true + type: string + +jobs: + lint-all: + name: Lint All + if: github.repository_owner == 'npm' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + 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: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.x + - name: Install npm@latest + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts + + test-all: + name: Test All - \${{ matrix.platform.name }} - Node \${{ matrix.node-version }} + if: github.repository_owner == 'npm' + strategy: + fail-fast: false + matrix: platform: - - os: ubuntu-latest + - name: Linux + os: ubuntu-latest shell: bash - - os: macos-latest + - name: macOS + os: macos-latest shell: bash - - os: windows-latest + - name: Windows + os: windows-latest shell: cmd + node-version: + - 14.17.0 + - 14.x + - 16.13.0 + - 16.x + - 18.0.0 + - 18.x runs-on: \${{ matrix.platform.os }} defaults: run: shell: \${{ matrix.platform.shell }} steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + 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" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: \${{ matrix.node-version }} - - name: Update to workable npm (windows) + - name: Update Windows npm # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) run: | @@ -1188,18 +1406,20 @@ jobs: node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz cd .. rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 + - name: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest + - name: Install npm@latest if: \${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm test --ignore-scripts -w b + - name: Test + run: npm test --ignore-scripts -ws -iwr --if-present .github/workflows/ci.yml ======================================== @@ -1211,43 +1431,58 @@ on: workflow_dispatch: pull_request: paths-ignore: - - workspaces/a/** - - workspaces/b/** push: branches: - main - latest paths-ignore: - - workspaces/a/** - - workspaces/b/** schedule: # "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1 - cron: "0 9 * * 1" jobs: lint: + name: Lint if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts test: + name: Test - \${{ matrix.platform.name }} - Node \${{ 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: - 14.17.0 - 14.x @@ -1255,27 +1490,22 @@ jobs: - 16.x - 18.0.0 - 18.x - platform: - - os: ubuntu-latest - shell: bash - - os: macos-latest - shell: bash - - os: windows-latest - shell: cmd runs-on: \${{ matrix.platform.os }} defaults: run: shell: \${{ matrix.platform.shell }} steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: \${{ matrix.node-version }} - - name: Update to workable npm (windows) + - name: Update Windows npm # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) run: | @@ -1285,18 +1515,20 @@ jobs: node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz cd .. rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 + - name: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest + - name: Install npm@latest if: \${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm test --ignore-scripts + - name: Test + run: npm test --ignore-scripts -iwr .github/workflows/codeql-analysis.yml ======================================== @@ -1326,8 +1558,9 @@ jobs: contents: read security-events: write steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" @@ -1342,7 +1575,7 @@ jobs: ======================================== # This file is automatically added by @npmcli/template-oss. Do not edit. -name: Post Dependabot Actions +name: Post Dependabot on: pull_request @@ -1350,50 +1583,60 @@ permissions: contents: write jobs: - template-oss-apply: + template-oss: + name: "@npmcli/template-oss" if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: ref: \${{ github.event.pull_request.head_ref }} - - name: Setup git user + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Dependabot metadata + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Fetch Dependabot Metadata id: metadata uses: dependabot/fetch-metadata@v1 with: github-token: \${{ secrets.GITHUB_TOKEN }} - - name: Get command flags + # Dependabot can update multiple directories so we output which directory + # it is acting on so we can run the command for the correct root or workspace + - name: Get Dependabot Directory if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss') id: flags run: | - if [[ "\${{steps.metadata.outputs.directory}}" == "/" ]]; then + if [[ "\${{ steps.metadata.outputs.directory }}" == "/" ]]; then echo "::set-output name=workspace::-iwr" else echo "::set-output name=workspace::-w \${{ steps.metadata.outputs.directory }}" fi - - name: Apply changes + - name: Apply Changes if: steps.flags.outputs.workspace id: apply run: | - npm run template-oss-apply \${{steps.flags.outputs.workspace}} + npm run template-oss-apply \${{ steps.flags.outputs.workspace }} if [[ \`git status --porcelain\` ]]; then echo "::set-output name=changes::true" fi - - name: Push all changes + # This step will fail if template-oss has made any workflow updates. It is impossible + # for a workflow to update other workflows. In the case it does fail, we continue + # and then try to apply only a portion of the changes in the next step + - name: Push All Changes if: steps.apply.outputs.changes id: push continue-on-error: true @@ -1403,7 +1646,7 @@ jobs: git commit -am "chore: postinstall for dependabot template-oss PR" git push - - name: Push all except workflows + - name: Push All Changes Except Workflows if: steps.push.outcome == 'failure' env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} @@ -1414,16 +1657,16 @@ jobs: git commit -am "chore: postinstall for dependabot template-oss PR" git push - - name: Verify changes + - name: Check Changes if: steps.apply.outputs.changes run: | - npm exec --offline \${{steps.flags.outputs.workspace}} -- template-oss-check + npm exec --offline \${{ steps.flags.outputs.workspace }} -- template-oss-check .github/workflows/pull-request.yml ======================================== # This file is automatically added by @npmcli/template-oss. Do not edit. -name: Pull Request Linting +name: Pull Request on: pull_request: @@ -1434,37 +1677,44 @@ on: - synchronize jobs: - check: - name: Check PR Title or Commits + commitlint: + name: Lint Commits if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Setup git user + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Check commits or PR title - env: - PR_TITLE: \${{ github.event.pull_request.title }} + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Commitlint on Commits + id: commit + continue-on-error: true run: | - npx --offline commitlint -V --from origin/main --to \${{ github.event.pull_request.head.sha }} / - || echo $PR_TITLE | npx --offline commitlint -V + npx --offline commitlint -V --from origin/\${{ github.base_ref }} --to \${{ github.event.pull_request.head.sha }} + - name: Run Commitlint on PR Title + if: steps.commit.outcome == 'failure' + run: | + echo \${{ github.event.pull_request.title }} | npx --offline commitlint -V -.github/workflows/release-please.yml +.github/workflows/release.yml ======================================== # This file is automatically added by @npmcli/template-oss. Do not edit. -name: Release Please +name: Release on: push: @@ -1478,183 +1728,111 @@ permissions: jobs: release-please: + name: Release Please outputs: pr: \${{ steps.release.outputs.pr }} release: \${{ steps.release.outputs.release }} if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Release Please + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: npx template-oss-release-please \${{ github.ref_name }} id: release - run: npx --offline template-oss-release-please \${{ github.ref_name }} env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} + run: npx --offline template-oss-release-please \${{ github.ref_name }} post-pr: + name: Post Pull Request needs: release-please if: needs.release-please.outputs.pr runs-on: ubuntu-latest outputs: ref: \${{ steps.ref.outputs.branch }} + sha: \${{ steps.commit.outputs.sha }} steps: - - name: Output ref + - name: Output PR Head Branch id: ref run: echo "::set-output name=branch::\${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}" - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: fetch-depth: 0 ref: \${{ steps.ref.outputs.branch }} - - name: Setup git user + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Post pull request actions + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Post Pull Request Actions + run: npm run rp-pull-request --ignore-scripts -ws -iwr --if-present + - name: Commit and Push + id: commit env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} run: | - npm run rp-pull-request --ignore-scripts --if-present -ws -iwr git commit -am "chore: post pull request" || true + echo "::set-output sha=$(git rev-parse HEAD)" git push release-test: + name: Test needs: post-pr if: needs.post-pr.outputs.ref - uses: ./.github/workflows/release.yml + uses: ./.github/workflows/ci-release.yml with: ref: \${{ needs.post-pr.outputs.ref }} + sha: \${{ needs.post-pr.outputs.sha }} post-release: + name: Post Release needs: release-please if: github.repository_owner == 'npm' && needs.release-please.outputs.release runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Post release actions - env: - GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} - run: | - npm run rp-release --ignore-scripts --if-present -ws -iwr - -.github/workflows/release.yml -======================================== -# This file is automatically added by @npmcli/template-oss. Do not edit. - -name: Release - -on: - workflow_call: - inputs: - ref: - required: true - type: string - -jobs: - lint-all: - if: github.repository_owner == 'npm' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: \${{ inputs.ref }} - - name: Setup git user + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Post Release Actions run: | - git config --global user.email "npm-cli+bot@github.com" - git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Update npm to latest - run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint -ws -iwr --if-present - - test-all: - if: github.repository_owner == 'npm' - strategy: - fail-fast: false - matrix: - node-version: - - 14.17.0 - - 14.x - - 16.13.0 - - 16.x - - 18.0.0 - - 18.x - platform: - - os: ubuntu-latest - shell: bash - - os: macos-latest - shell: bash - - os: windows-latest - shell: cmd - runs-on: \${{ matrix.platform.os }} - defaults: - run: - shell: \${{ matrix.platform.shell }} - steps: - - uses: actions/checkout@v3 - 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" - - uses: actions/setup-node@v3 - with: - node-version: \${{ matrix.node-version }} - - name: Update to workable npm (windows) - # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows - if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) - run: | - curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz - tar xf npm-7.5.4.tgz - cd package - node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz - cd .. - rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 - if: startsWith(matrix.node-version, '10.') - run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest - if: \${{ !startsWith(matrix.node-version, '10.') }} - run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher - run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm run test -ws -iwr --if-present + npm run rp-release --ignore-scripts -ws -iwr --if-present .gitignore ======================================== @@ -2058,28 +2236,47 @@ on: jobs: lint: + name: Lint if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint -w a + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts test: + name: Test - \${{ matrix.platform.name }} - Node \${{ 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: - 14.17.0 - 14.x @@ -2087,27 +2284,22 @@ jobs: - 16.x - 18.0.0 - 18.x - platform: - - os: ubuntu-latest - shell: bash - - os: macos-latest - shell: bash - - os: windows-latest - shell: cmd runs-on: \${{ matrix.platform.os }} defaults: run: shell: \${{ matrix.platform.shell }} steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: \${{ matrix.node-version }} - - name: Update to workable npm (windows) + - name: Update Windows npm # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) run: | @@ -2117,18 +2309,20 @@ jobs: node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz cd .. rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 + - name: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest + - name: Install npm@latest if: \${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm test --ignore-scripts -w a + - name: Test + run: npm test --ignore-scripts -w a .github/workflows/ci-b.yml ======================================== @@ -2153,28 +2347,47 @@ on: jobs: lint: + name: Lint if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint -w b + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts test: + name: Test - \${{ matrix.platform.name }} - Node \${{ 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: - 14.17.0 - 14.x @@ -2182,27 +2395,129 @@ jobs: - 16.x - 18.0.0 - 18.x + runs-on: \${{ matrix.platform.os }} + defaults: + run: + shell: \${{ matrix.platform.shell }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User + run: | + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: \${{ matrix.node-version }} + - name: Update Windows npm + # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) + run: | + curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz + tar xf npm-7.5.4.tgz + cd package + node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz + cd .. + rmdir /s /q package + - name: Install npm@7 + if: startsWith(matrix.node-version, '10.') + run: npm i --prefer-online --no-fund --no-audit -g npm@7 + - name: Install npm@latest + if: \${{ !startsWith(matrix.node-version, '10.') }} + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher + run: echo "::add-matcher::.github/matchers/tap.json" + - name: Test + run: npm test --ignore-scripts -w b + +.github/workflows/ci-release.yml +======================================== +# This file is automatically added by @npmcli/template-oss. Do not edit. + +name: CI - Release + +on: + workflow_call: + inputs: + ref: + required: true + type: string + +jobs: + lint-all: + name: Lint All + if: github.repository_owner == 'npm' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + 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: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.x + - name: Install npm@latest + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Lint + run: npm run lint --ignore-scripts + - name: Post Lint + run: npm run postlint --ignore-scripts + + test-all: + name: Test All - \${{ matrix.platform.name }} - Node \${{ matrix.node-version }} + if: github.repository_owner == 'npm' + strategy: + fail-fast: false + matrix: platform: - - os: ubuntu-latest + - name: Linux + os: ubuntu-latest shell: bash - - os: macos-latest + - name: macOS + os: macos-latest shell: bash - - os: windows-latest + - name: Windows + os: windows-latest shell: cmd + node-version: + - 14.17.0 + - 14.x + - 16.13.0 + - 16.x + - 18.0.0 + - 18.x runs-on: \${{ matrix.platform.os }} defaults: run: shell: \${{ matrix.platform.shell }} steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + 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" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: \${{ matrix.node-version }} - - name: Update to workable npm (windows) + - name: Update Windows npm # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) run: | @@ -2212,24 +2527,26 @@ jobs: node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz cd .. rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 + - name: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest + - name: Install npm@latest if: \${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Add Problem Matcher run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm test --ignore-scripts -w b + - name: Test + run: npm test --ignore-scripts -ws -iwr --if-present .github/workflows/post-dependabot.yml ======================================== # This file is automatically added by @npmcli/template-oss. Do not edit. -name: Post Dependabot Actions +name: Post Dependabot on: pull_request @@ -2237,50 +2554,60 @@ permissions: contents: write jobs: - template-oss-apply: + template-oss: + name: "@npmcli/template-oss" if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: ref: \${{ github.event.pull_request.head_ref }} - - name: Setup git user + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Dependabot metadata + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Fetch Dependabot Metadata id: metadata uses: dependabot/fetch-metadata@v1 with: github-token: \${{ secrets.GITHUB_TOKEN }} - - name: Get command flags + # Dependabot can update multiple directories so we output which directory + # it is acting on so we can run the command for the correct root or workspace + - name: Get Dependabot Directory if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss') id: flags run: | - if [[ "\${{steps.metadata.outputs.directory}}" == "/" ]]; then + if [[ "\${{ steps.metadata.outputs.directory }}" == "/" ]]; then echo "::set-output name=workspace::-iwr" else echo "::set-output name=workspace::-w \${{ steps.metadata.outputs.directory }}" fi - - name: Apply changes + - name: Apply Changes if: steps.flags.outputs.workspace id: apply run: | - npm run template-oss-apply \${{steps.flags.outputs.workspace}} + npm run template-oss-apply \${{ steps.flags.outputs.workspace }} if [[ \`git status --porcelain\` ]]; then echo "::set-output name=changes::true" fi - - name: Push all changes + # This step will fail if template-oss has made any workflow updates. It is impossible + # for a workflow to update other workflows. In the case it does fail, we continue + # and then try to apply only a portion of the changes in the next step + - name: Push All Changes if: steps.apply.outputs.changes id: push continue-on-error: true @@ -2290,7 +2617,7 @@ jobs: git commit -am "chore: postinstall for dependabot template-oss PR" git push - - name: Push all except workflows + - name: Push All Changes Except Workflows if: steps.push.outcome == 'failure' env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} @@ -2301,16 +2628,16 @@ jobs: git commit -am "chore: postinstall for dependabot template-oss PR" git push - - name: Verify changes + - name: Check Changes if: steps.apply.outputs.changes run: | - npm exec --offline \${{steps.flags.outputs.workspace}} -- template-oss-check + npm exec --offline \${{ steps.flags.outputs.workspace }} -- template-oss-check -.github/workflows/release-please.yml +.github/workflows/release.yml ======================================== # This file is automatically added by @npmcli/template-oss. Do not edit. -name: Release Please +name: Release on: push: @@ -2324,183 +2651,111 @@ permissions: jobs: release-please: + name: Release Please outputs: pr: \${{ steps.release.outputs.pr }} release: \${{ steps.release.outputs.release }} if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Release Please + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: npx template-oss-release-please \${{ github.ref_name }} id: release - run: npx --offline template-oss-release-please \${{ github.ref_name }} env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} + run: npx --offline template-oss-release-please \${{ github.ref_name }} post-pr: + name: Post Pull Request needs: release-please if: needs.release-please.outputs.pr runs-on: ubuntu-latest outputs: ref: \${{ steps.ref.outputs.branch }} + sha: \${{ steps.commit.outputs.sha }} steps: - - name: Output ref + - name: Output PR Head Branch id: ref run: echo "::set-output name=branch::\${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}" - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: fetch-depth: 0 ref: \${{ steps.ref.outputs.branch }} - - name: Setup git user + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Post pull request actions + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Post Pull Request Actions + run: npm run rp-pull-request --ignore-scripts -ws -iwr --if-present + - name: Commit and Push + id: commit env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} run: | - npm run rp-pull-request --ignore-scripts --if-present -ws -iwr git commit -am "chore: post pull request" || true + echo "::set-output sha=$(git rev-parse HEAD)" git push release-test: + name: Test needs: post-pr if: needs.post-pr.outputs.ref - uses: ./.github/workflows/release.yml + uses: ./.github/workflows/ci-release.yml with: ref: \${{ needs.post-pr.outputs.ref }} + sha: \${{ needs.post-pr.outputs.sha }} post-release: + name: Post Release needs: release-please if: github.repository_owner == 'npm' && needs.release-please.outputs.release runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user - run: | - git config --global user.email "npm-cli+bot@github.com" - git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Update npm to latest - run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: Post release actions - env: - GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} - run: | - npm run rp-release --ignore-scripts --if-present -ws -iwr - -.github/workflows/release.yml -======================================== -# This file is automatically added by @npmcli/template-oss. Do not edit. - -name: Release - -on: - workflow_call: - inputs: - ref: - required: true - type: string - -jobs: - lint-all: - if: github.repository_owner == 'npm' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: \${{ inputs.ref }} - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - run: npm run lint -ws -iwr --if-present - - test-all: - if: github.repository_owner == 'npm' - strategy: - fail-fast: false - matrix: - node-version: - - 14.17.0 - - 14.x - - 16.13.0 - - 16.x - - 18.0.0 - - 18.x - platform: - - os: ubuntu-latest - shell: bash - - os: macos-latest - shell: bash - - os: windows-latest - shell: cmd - runs-on: \${{ matrix.platform.os }} - defaults: - run: - shell: \${{ matrix.platform.shell }} - steps: - - uses: actions/checkout@v3 - with: - ref: \${{ inputs.ref }} - - name: Setup git user + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Run Post Release Actions run: | - git config --global user.email "npm-cli+bot@github.com" - git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 - with: - node-version: \${{ matrix.node-version }} - - name: Update to workable npm (windows) - # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows - if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) - run: | - curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz - tar xf npm-7.5.4.tgz - cd package - node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz - cd .. - rmdir /s /q package - - name: Update npm to 7 - # If we do test on npm 10 it needs npm7 - if: startsWith(matrix.node-version, '10.') - run: npm i --prefer-online --no-fund --no-audit -g npm@7 - - name: Update npm to latest - if: \${{ !startsWith(matrix.node-version, '10.') }} - run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund - - name: add tap problem matcher - run: echo "::add-matcher::.github/matchers/tap.json" - - run: npm run test -ws -iwr --if-present + npm run rp-release --ignore-scripts -ws -iwr --if-present .release-please-manifest.json ======================================== diff --git a/tap-snapshots/test/check/diff-snapshots.js.test.cjs b/tap-snapshots/test/check/diff-snapshots.js.test.cjs index 34e5bfd6..0dcb3c81 100644 --- a/tap-snapshots/test/check/diff-snapshots.js.test.cjs +++ b/tap-snapshots/test/check/diff-snapshots.js.test.cjs @@ -112,22 +112,28 @@ The repo file audit.yml needs to be updated: jobs: audit: + name: Audit if: github.repository_owner == 'npm' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup git user + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 18.x - - name: Update npm to latest + - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - - run: npm -v - - run: npm i --ignore-scripts --no-audit --no-fund --package-lock - - run: npm audit + - name: npm Version + run: npm -v + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund --package-lock + - name: Run Audit + run: npm audit To correct it: npx template-oss-apply --force @@ -138,12 +144,12 @@ The repo file ci.yml needs to be updated: .github/workflows/ci.yml ======================================== - @@ -65,4 +65,24 @@ - with: + @@ -80,5 +80,25 @@ node-version: \${{ matrix.node-version }} - - name: Update to workable npm (windows) + - name: Update Windows npm # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows - + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) + - run: "" + run: | + curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz + tar xf npm-7.5.4.tgz @@ -151,18 +157,20 @@ The repo file ci.yml needs to be updated: + node lib/npm.js install --no-fund --no-audit -g ../npm-7.5.4.tgz + cd .. + rmdir /s /q package - + - name: Update npm to 7 - + # If we do test on npm 10 it needs npm7 + + - name: Install npm@7 + if: startsWith(matrix.node-version, '10.') + run: npm i --prefer-online --no-fund --no-audit -g npm@7 - + - name: Update npm to latest + + - name: Install npm@latest + if: \${{ !startsWith(matrix.node-version, '10.') }} + run: npm i --prefer-online --no-fund --no-audit -g npm@latest - + - run: npm -v - + - run: npm i --ignore-scripts --no-audit --no-fund - + - name: add tap problem matcher + + - name: npm Version + + run: npm -v + + - name: Install Dependencies + + run: npm i --ignore-scripts --no-audit --no-fund + + - name: Add Problem Matcher + run: echo "::add-matcher::.github/matchers/tap.json" - + - run: npm test --ignore-scripts + + - name: Test + + run: npm test --ignore-scripts -iwr To correct it: npx template-oss-apply --force diff --git a/tap-snapshots/test/check/snapshots.js.test.cjs b/tap-snapshots/test/check/snapshots.js.test.cjs index 9f1df8c2..961d7173 100644 --- a/tap-snapshots/test/check/snapshots.js.test.cjs +++ b/tap-snapshots/test/check/snapshots.js.test.cjs @@ -36,11 +36,11 @@ The following repo files need to be added: .github/ISSUE_TEMPLATE/config.yml .github/matchers/tap.json .github/workflows/audit.yml + .github/workflows/ci-release.yml .github/workflows/ci.yml .github/workflows/codeql-analysis.yml .github/workflows/post-dependabot.yml .github/workflows/pull-request.yml - .github/workflows/release-please.yml .github/workflows/release.yml .release-please-manifest.json release-please-config.json @@ -283,11 +283,11 @@ The following repo files need to be added: .github/ISSUE_TEMPLATE/config.yml .github/matchers/tap.json .github/workflows/audit.yml + .github/workflows/ci-release.yml .github/workflows/ci.yml .github/workflows/codeql-analysis.yml .github/workflows/post-dependabot.yml .github/workflows/pull-request.yml - .github/workflows/release-please.yml .github/workflows/release.yml .release-please-manifest.json release-please-config.json @@ -366,8 +366,8 @@ The following repo files need to be added: .github/dependabot.yml .github/matchers/tap.json .github/workflows/ci-name-aaaa.yml + .github/workflows/ci-release.yml .github/workflows/post-dependabot.yml - .github/workflows/release-please.yml .github/workflows/release.yml .release-please-manifest.json release-please-config.json @@ -436,8 +436,8 @@ The following repo files need to be added: .github/dependabot.yml .github/matchers/tap.json .github/workflows/ci-bbb.yml + .github/workflows/ci-release.yml .github/workflows/post-dependabot.yml - .github/workflows/release-please.yml .github/workflows/release.yml .release-please-manifest.json release-please-config.json diff --git a/test/apply/index.js b/test/apply/index.js index 77cbf2f1..43e9daf6 100644 --- a/test/apply/index.js +++ b/test/apply/index.js @@ -240,7 +240,7 @@ t.test('content can extend files', async (t) => { content_dir: { // eslint-disable-next-line max-len 'index.js': 'module.exports={rootRepo:{add:{".github/workflows/release.yml": "release.yml"}}}', - 'release.yml': '{{> release}}\n smoke-publish:\n runs-on: ubuntu-latest', + 'release.yml': '{{> ciRelease}}\n smoke-publish:\n runs-on: ubuntu-latest', }, }, }) @@ -269,13 +269,13 @@ t.test('config via multiple locations', async (t) => { }, testdir: { 'root-content': { - root: '{{defaultBranch}}-{{a}}-{{b}}-{{c}}', + root: '{{rootNpmPath}}-{{a}}-{{b}}-{{c}}', 'index.js': 'module.exports={rootRepo:{add:{"root.txt":"root"}},c:"root-c"}', }, workspaces: { a: { 'ws-content': { - ws: '{{defaultBranch}}-{{a}}-{{b}}-{{c}}', + ws: '{{rootNpmPath}}-{{a}}-{{b}}-{{c}}', 'index.js': 'module.exports={workspaceRepo:{add:{"ws.txt":"ws"}},c:"ws-c"}', }, }, @@ -287,8 +287,8 @@ t.test('config via multiple locations', async (t) => { const root = await s.readFile('root.txt') const ws = await s.readFile(join('ws.txt')) - t.equal(root.split('\n').slice(-1)[0], 'main-root-a-root-b-root-c') - t.equal(ws.split('\n').slice(-1)[0], 'main-ws-a-ws-b-ws-c') + t.equal(root.split('\n').slice(-1)[0], 'npm-root-a-root-b-root-c') + t.equal(ws.split('\n').slice(-1)[0], 'npm-ws-a-ws-b-ws-c') }) t.test('private workspace', async (t) => { @@ -329,7 +329,7 @@ t.test('private workspace', async (t) => { t.notOk(rpConfig.packages['workspaces/a']) const rp = s.join('.github', 'workflows') - t.ok(fs.existsSync(join(rp, 'release-please.yml'))) + t.ok(fs.existsSync(join(rp, 'release.yml'))) t.notOk(fs.existsSync(join(rp, 'release-please-b.yml'))) t.notOk(fs.existsSync(join(rp, 'release-please-a.yml'))) })