|
| 1 | +# This file is automatically added by @npmcli/template-oss. Do not edit. |
| 2 | + |
| 3 | +name: CI - Release |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_call: |
| 7 | + inputs: |
| 8 | + ref: |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + check-sha: |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + |
| 15 | +jobs: |
| 16 | + lint-all: |
| 17 | + name: Lint All |
| 18 | + if: github.repository_owner == 'npm' |
| 19 | + runs-on: ubuntu-latest |
| 20 | + defaults: |
| 21 | + run: |
| 22 | + shell: bash |
| 23 | + steps: |
| 24 | + - name: Create Check |
| 25 | + uses: LouisBrunner/[email protected] |
| 26 | + id: check |
| 27 | + |
| 28 | + with: |
| 29 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + status: in_progress |
| 31 | + name: Lint All |
| 32 | + sha: ${{ inputs.check-sha }} |
| 33 | + # XXX: this does not work when using the default GITHUB_TOKEN. |
| 34 | + # Instead we post the main job url to the PR as a comment which |
| 35 | + # will link to all the other checks. To work around this we would |
| 36 | + # need to create a GitHub that would create on-demand tokens. |
| 37 | + # https://github.com/LouisBrunner/checks-action/issues/18 |
| 38 | + # details_url: |
| 39 | + - name: Checkout |
| 40 | + uses: actions/checkout@v3 |
| 41 | + with: |
| 42 | + ref: ${{ inputs.ref }} |
| 43 | + - name: Setup Git User |
| 44 | + run: | |
| 45 | + git config --global user.email "[email protected]" |
| 46 | + git config --global user.name "npm CLI robot" |
| 47 | + - name: Setup Node |
| 48 | + uses: actions/setup-node@v3 |
| 49 | + with: |
| 50 | + node-version: 18.x |
| 51 | + - name: Install npm@latest |
| 52 | + run: npm i --prefer-online --no-fund --no-audit -g npm@latest |
| 53 | + - name: npm Version |
| 54 | + run: npm -v |
| 55 | + - name: Install Dependencies |
| 56 | + run: npm i --ignore-scripts --no-audit --no-fund |
| 57 | + - name: Lint |
| 58 | + run: npm run lint --ignore-scripts |
| 59 | + - name: Post Lint |
| 60 | + run: npm run postlint --ignore-scripts |
| 61 | + - name: Conclude Check |
| 62 | + uses: LouisBrunner/[email protected] |
| 63 | + if: always() |
| 64 | + with: |
| 65 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + conclusion: ${{ job.status }} |
| 67 | + check_id: ${{ steps.check.outputs.check_id }} |
| 68 | + |
| 69 | + test-all: |
| 70 | + name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }} |
| 71 | + if: github.repository_owner == 'npm' |
| 72 | + strategy: |
| 73 | + fail-fast: false |
| 74 | + matrix: |
| 75 | + platform: |
| 76 | + - name: Linux |
| 77 | + os: ubuntu-latest |
| 78 | + shell: bash |
| 79 | + - name: macOS |
| 80 | + os: macos-latest |
| 81 | + shell: bash |
| 82 | + - name: Windows |
| 83 | + os: windows-latest |
| 84 | + shell: cmd |
| 85 | + node-version: |
| 86 | + - 14.17.0 |
| 87 | + - 14.x |
| 88 | + - 16.13.0 |
| 89 | + - 16.x |
| 90 | + - 18.0.0 |
| 91 | + - 18.x |
| 92 | + runs-on: ${{ matrix.platform.os }} |
| 93 | + defaults: |
| 94 | + run: |
| 95 | + shell: ${{ matrix.platform.shell }} |
| 96 | + steps: |
| 97 | + - name: Create Check |
| 98 | + uses: LouisBrunner/[email protected] |
| 99 | + id: check |
| 100 | + |
| 101 | + with: |
| 102 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + status: in_progress |
| 104 | + name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }} |
| 105 | + sha: ${{ inputs.check-sha }} |
| 106 | + # XXX: this does not work when using the default GITHUB_TOKEN. |
| 107 | + # Instead we post the main job url to the PR as a comment which |
| 108 | + # will link to all the other checks. To work around this we would |
| 109 | + # need to create a GitHub that would create on-demand tokens. |
| 110 | + # https://github.com/LouisBrunner/checks-action/issues/18 |
| 111 | + # details_url: |
| 112 | + - name: Checkout |
| 113 | + uses: actions/checkout@v3 |
| 114 | + with: |
| 115 | + ref: ${{ inputs.ref }} |
| 116 | + - name: Setup Git User |
| 117 | + run: | |
| 118 | + git config --global user.email "[email protected]" |
| 119 | + git config --global user.name "npm CLI robot" |
| 120 | + - name: Setup Node |
| 121 | + uses: actions/setup-node@v3 |
| 122 | + with: |
| 123 | + node-version: ${{ matrix.node-version }} |
| 124 | + - name: Update Windows npm |
| 125 | + # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows |
| 126 | + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) |
| 127 | + run: | |
| 128 | + curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz |
| 129 | + tar xf npm-7.5.4.tgz |
| 130 | + cd package |
| 131 | + node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz |
| 132 | + cd .. |
| 133 | + rmdir /s /q package |
| 134 | + - name: Install npm@7 |
| 135 | + if: startsWith(matrix.node-version, '10.') |
| 136 | + run: npm i --prefer-online --no-fund --no-audit -g npm@7 |
| 137 | + - name: Install npm@latest |
| 138 | + if: ${{ !startsWith(matrix.node-version, '10.') }} |
| 139 | + run: npm i --prefer-online --no-fund --no-audit -g npm@latest |
| 140 | + - name: npm Version |
| 141 | + run: npm -v |
| 142 | + - name: Install Dependencies |
| 143 | + run: npm i --ignore-scripts --no-audit --no-fund |
| 144 | + - name: Add Problem Matcher |
| 145 | + run: echo "::add-matcher::.github/matchers/tap.json" |
| 146 | + - name: Test |
| 147 | + run: npm test --ignore-scripts -ws -iwr --if-present |
| 148 | + - name: Conclude Check |
| 149 | + uses: LouisBrunner/[email protected] |
| 150 | + if: always() |
| 151 | + with: |
| 152 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 153 | + conclusion: ${{ job.status }} |
| 154 | + check_id: ${{ steps.check.outputs.check_id }} |
0 commit comments