|
| 1 | +# This file is automatically added by @npmcli/template-oss. Do not edit. |
| 2 | + |
| 3 | +name: CI - Release |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + ref: |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + default: main |
| 12 | + workflow_call: |
| 13 | + inputs: |
| 14 | + ref: |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + check-sha: |
| 18 | + required: true |
| 19 | + type: string |
| 20 | + |
| 21 | +jobs: |
| 22 | + lint-all: |
| 23 | + name: Lint All |
| 24 | + if: github.repository_owner == 'npm' |
| 25 | + runs-on: ubuntu-latest |
| 26 | + defaults: |
| 27 | + run: |
| 28 | + shell: bash |
| 29 | + steps: |
| 30 | + - name: Get Workflow Job |
| 31 | + uses: actions/github-script@v6 |
| 32 | + if: inputs.check-sha |
| 33 | + id: check-output |
| 34 | + env: |
| 35 | + JOB_NAME: "Lint All" |
| 36 | + MATRIX_NAME: "" |
| 37 | + with: |
| 38 | + script: | |
| 39 | + const { owner, repo } = context.repo |
| 40 | +
|
| 41 | + const { data } = await github.rest.actions.listJobsForWorkflowRun({ |
| 42 | + owner, |
| 43 | + repo, |
| 44 | + run_id: context.runId, |
| 45 | + per_page: 100 |
| 46 | + }) |
| 47 | +
|
| 48 | + const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME |
| 49 | + const job = data.jobs.find(j => j.name.endsWith(jobName)) |
| 50 | + const jobUrl = job?.html_url |
| 51 | +
|
| 52 | + const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}` |
| 53 | +
|
| 54 | + let summary = `This check is assosciated with ${shaUrl}\n\n` |
| 55 | +
|
| 56 | + if (jobUrl) { |
| 57 | + summary += `For run logs, click here: ${jobUrl}` |
| 58 | + } else { |
| 59 | + summary += `Run logs could not be found for a job with name: "${jobName}"` |
| 60 | + } |
| 61 | +
|
| 62 | + return { summary } |
| 63 | + - name: Create Check |
| 64 | + uses: LouisBrunner/[email protected] |
| 65 | + id: check |
| 66 | + if: inputs.check-sha |
| 67 | + with: |
| 68 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + status: in_progress |
| 70 | + name: Lint All |
| 71 | + sha: ${{ inputs.check-sha }} |
| 72 | + output: ${{ steps.check-output.outputs.result }} |
| 73 | + - name: Checkout |
| 74 | + uses: actions/checkout@v3 |
| 75 | + with: |
| 76 | + ref: ${{ inputs.ref }} |
| 77 | + - name: Setup Git User |
| 78 | + run: | |
| 79 | + git config --global user.email "[email protected]" |
| 80 | + git config --global user.name "npm CLI robot" |
| 81 | + - name: Setup Node |
| 82 | + uses: actions/setup-node@v3 |
| 83 | + with: |
| 84 | + node-version: 16.x |
| 85 | + - name: Install npm@latest |
| 86 | + run: npm i --prefer-online --no-fund --no-audit -g npm@latest |
| 87 | + - name: npm Version |
| 88 | + run: npm -v |
| 89 | + - name: Install Dependencies |
| 90 | + run: npm i --ignore-scripts --no-audit --no-fund |
| 91 | + - name: Lint |
| 92 | + run: npm run lint --ignore-scripts |
| 93 | + - name: Post Lint |
| 94 | + run: npm run postlint --ignore-scripts |
| 95 | + - name: Conclude Check |
| 96 | + uses: LouisBrunner/[email protected] |
| 97 | + if: steps.check.outputs.check_id && always() |
| 98 | + with: |
| 99 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + conclusion: ${{ job.status }} |
| 101 | + check_id: ${{ steps.check.outputs.check_id }} |
| 102 | + |
| 103 | + test-all: |
| 104 | + name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }} |
| 105 | + if: github.repository_owner == 'npm' |
| 106 | + strategy: |
| 107 | + fail-fast: false |
| 108 | + matrix: |
| 109 | + platform: |
| 110 | + - name: Linux |
| 111 | + os: ubuntu-latest |
| 112 | + shell: bash |
| 113 | + - name: macOS |
| 114 | + os: macos-latest |
| 115 | + shell: bash |
| 116 | + - name: Windows |
| 117 | + os: windows-latest |
| 118 | + shell: cmd |
| 119 | + node-version: |
| 120 | + - 12.13.0 |
| 121 | + - 12.x |
| 122 | + - 14.15.0 |
| 123 | + - 14.x |
| 124 | + - 16.0.0 |
| 125 | + - 16.x |
| 126 | + runs-on: ${{ matrix.platform.os }} |
| 127 | + defaults: |
| 128 | + run: |
| 129 | + shell: ${{ matrix.platform.shell }} |
| 130 | + steps: |
| 131 | + - name: Get Workflow Job |
| 132 | + uses: actions/github-script@v6 |
| 133 | + if: inputs.check-sha |
| 134 | + id: check-output |
| 135 | + env: |
| 136 | + JOB_NAME: "Test All" |
| 137 | + MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}" |
| 138 | + with: |
| 139 | + script: | |
| 140 | + const { owner, repo } = context.repo |
| 141 | +
|
| 142 | + const { data } = await github.rest.actions.listJobsForWorkflowRun({ |
| 143 | + owner, |
| 144 | + repo, |
| 145 | + run_id: context.runId, |
| 146 | + per_page: 100 |
| 147 | + }) |
| 148 | +
|
| 149 | + const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME |
| 150 | + const job = data.jobs.find(j => j.name.endsWith(jobName)) |
| 151 | + const jobUrl = job?.html_url |
| 152 | +
|
| 153 | + const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}` |
| 154 | +
|
| 155 | + let summary = `This check is assosciated with ${shaUrl}\n\n` |
| 156 | +
|
| 157 | + if (jobUrl) { |
| 158 | + summary += `For run logs, click here: ${jobUrl}` |
| 159 | + } else { |
| 160 | + summary += `Run logs could not be found for a job with name: "${jobName}"` |
| 161 | + } |
| 162 | +
|
| 163 | + return { summary } |
| 164 | + - name: Create Check |
| 165 | + uses: LouisBrunner/[email protected] |
| 166 | + id: check |
| 167 | + if: inputs.check-sha |
| 168 | + with: |
| 169 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 170 | + status: in_progress |
| 171 | + name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }} |
| 172 | + sha: ${{ inputs.check-sha }} |
| 173 | + output: ${{ steps.check-output.outputs.result }} |
| 174 | + - name: Checkout |
| 175 | + uses: actions/checkout@v3 |
| 176 | + with: |
| 177 | + ref: ${{ inputs.ref }} |
| 178 | + - name: Setup Git User |
| 179 | + run: | |
| 180 | + git config --global user.email "[email protected]" |
| 181 | + git config --global user.name "npm CLI robot" |
| 182 | + - name: Setup Node |
| 183 | + uses: actions/setup-node@v3 |
| 184 | + with: |
| 185 | + node-version: ${{ matrix.node-version }} |
| 186 | + - name: Update Windows npm |
| 187 | + # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows |
| 188 | + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) |
| 189 | + run: | |
| 190 | + curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz |
| 191 | + tar xf npm-7.5.4.tgz |
| 192 | + cd package |
| 193 | + node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz |
| 194 | + cd .. |
| 195 | + rmdir /s /q package |
| 196 | + - name: Install npm@7 |
| 197 | + if: startsWith(matrix.node-version, '10.') |
| 198 | + run: npm i --prefer-online --no-fund --no-audit -g npm@7 |
| 199 | + - name: Install npm@latest |
| 200 | + if: ${{ !startsWith(matrix.node-version, '10.') }} |
| 201 | + run: npm i --prefer-online --no-fund --no-audit -g npm@latest |
| 202 | + - name: npm Version |
| 203 | + run: npm -v |
| 204 | + - name: Install Dependencies |
| 205 | + run: npm i --ignore-scripts --no-audit --no-fund |
| 206 | + - name: Add Problem Matcher |
| 207 | + run: echo "::add-matcher::.github/matchers/tap.json" |
| 208 | + - name: Test |
| 209 | + run: npm test --ignore-scripts |
| 210 | + - name: Conclude Check |
| 211 | + uses: LouisBrunner/[email protected] |
| 212 | + if: steps.check.outputs.check_id && always() |
| 213 | + with: |
| 214 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 215 | + conclusion: ${{ job.status }} |
| 216 | + check_id: ${{ steps.check.outputs.check_id }} |
0 commit comments