-
-
Notifications
You must be signed in to change notification settings - Fork 43
203 lines (193 loc) · 7.36 KB
/
Copy pathnode-test-package.yml
File metadata and controls
203 lines (193 loc) · 7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Node.js Test Package
on:
pull_request:
types:
# Types run for by default
- opened
- reopened
- synchronize
# Merged
- closed
push:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
path-filter:
permissions:
pull-requests: read # dorny/paths-filter
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- id: filter
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
with:
filters: |
changes:
- '.github/workflows/node-test-package.yml'
- 'packages/**'
- 'src/**'
- '*'
pkg-pr-new:
needs:
- path-filter
if: ${{ needs.path-filter.outputs.changes == 'true' }}
permissions:
contents: read # actions/checkout
runs-on: ubuntu-latest
outputs:
package_name: ${{ steps.pkg-pr-new.outputs.PACKAGE_NAME }}
package_url: ${{ steps.pkg-pr-new.outputs.PACKAGE_URL }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
submodules: 'recursive'
- uses: volta-cli/action@615a78f6c83e116339c53b94f3f82b4d6c0b7d18 # v5.0.0
- id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> "${GITHUB_OUTPUT}"
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
${{ runner.os }}-
- id: pkg-pr-new
run: |
set -x
npm ci
npx --yes pkg-pr-new publish --compact --json pkg.json --comment=off
cat pkg.json
echo "PACKAGE_NAME=$(jq --raw-output '.packages[0].name' pkg.json)" >> "${GITHUB_OUTPUT}"
echo "PACKAGE_URL=$(jq --raw-output '.packages[0].url' pkg.json)" >> "${GITHUB_OUTPUT}"
test-npx:
name: test-npx (${{ matrix.os }})
needs:
- pkg-pr-new
if: ${{ startsWith(github.event_name, 'pull_request') && github.event.action != 'closed' }}
permissions:
contents: read # actions/checkout
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
- macos-latest
- macos-15-intel
- windows-latest
- windows-11-arm
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: volta-cli/action@615a78f6c83e116339c53b94f3f82b4d6c0b7d18 # v5.0.0
- run: |
npm exec --yes --foreground-scripts "${{ needs.pkg-pr-new.outputs.package_url }}" -- --help
# TODO(cemmer): bunx testing, https://github.com/oven-sh/bun/issues/17946
test-npm-install-global:
name: test-npm-install-global (${{ matrix.os }})
needs:
- pkg-pr-new
if: ${{ startsWith(github.event_name, 'pull_request') && github.event.action != 'closed' }}
permissions:
contents: read # actions/checkout
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
- macos-latest
- macos-15-intel
- windows-latest
- windows-11-arm
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: volta-cli/action@615a78f6c83e116339c53b94f3f82b4d6c0b7d18 # v5.0.0
- shell: bash
run: |
set -x
npm install --global --foreground-scripts "${{ needs.pkg-pr-new.outputs.package_url }}"
PATH="$(npm get prefix --global)/bin:$PATH"
export PATH
igir --help
# !!! This check should be required by GitHub !!!
test-package-status-check:
needs:
- pkg-pr-new
- test-npx
- test-npm-install-global
if: always()
permissions: {}
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # release/v1
with:
jobs: ${{ toJSON(needs) }}
allowed-skips: pkg-pr-new, test-npx, test-npm-install-global
npm-exec-branch-comment:
needs:
- pkg-pr-new
- test-npx
- test-npm-install-global
# TODO(cemmer): need pull_request_target to comment
if: ${{ github.event.pull_request.user.login == 'emmercm' && startsWith(github.event_name, 'pull_request') && github.event.action != 'closed' }}
permissions:
pull-requests: write # thollander/actions-comment-pull-request
runs-on: ubuntu-latest
steps:
- uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
message: |
## :test_tube: Package testing instructions
This pull request can be tested locally with the following command:
```shell
npx --yes "${{ needs.pkg-pr-new.outputs.package_url }}" [commands..] [options]
```
_Comment generated by the [${{ github.workflow }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}) workflow._
comment-tag: npm-exec
npm-exec-merge-comment:
needs:
- path-filter
# TODO(cemmer): need pull_request_target to comment
if: ${{ github.event.pull_request.user.login == 'emmercm' && needs.path-filter.outputs.changes == 'true' && startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' && github.event.pull_request.merged && github.event.pull_request.base.ref == 'main' }}
permissions:
pull-requests: write # thollander/actions-comment-pull-request
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: volta-cli/action@615a78f6c83e116339c53b94f3f82b4d6c0b7d18 # v5.0.0
- id: package
run: |
echo "PACKAGE_NAME=$(jq --raw-output '.name' package.json)" >> "${GITHUB_OUTPUT}"
- run: |
npx --yes "https://pkg.pr.new/${PACKAGE_NAME}@${BASE_REF}" --help
env:
PACKAGE_NAME: ${{ steps.package.outputs.PACKAGE_NAME }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
- uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
message: |
## :test_tube: Package testing instructions
This pull request has been merged, its base branch can be tested locally with the following command:
```shell
npx --yes "https://pkg.pr.new/${{ steps.package.outputs.PACKAGE_NAME }}@${{ github.event.pull_request.base.ref }}" [commands..] [options]
```
_Comment generated by the [${{ github.workflow }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}) workflow._
comment-tag: npm-exec
mode: recreate