Skip to content

Commit e19dc3f

Browse files
committed
ci: add tests and update readme
1 parent 6558925 commit e19dc3f

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/build-lint-test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,35 @@ jobs:
253253
- name: Make sure the Git HEAD did not change
254254
if: ${{ env.NEW_SHA != env.INITIAL_SHA }}
255255
run: exit 1
256+
257+
test-custom-yarn-url:
258+
name: Test custom Yarn URL
259+
runs-on: ubuntu-latest
260+
steps:
261+
- uses: actions/checkout@v4
262+
- name: Checkout and setup environment with custom Yarn URL
263+
id: checkout-and-setup
264+
uses: ./
265+
with:
266+
is-high-risk-environment: false
267+
yarn-custom-url: 'https://example.com/yarn-4.9.1/yarn.js#sha224.dummyhash'
268+
continue-on-error: true # The URL is dummy, so this is just to exercise the code path
269+
- name: Ensure custom Yarn logic was attempted
270+
run: |
271+
grep 'Preparing and activating custom Yarn from URL' $GITHUB_STEP_SUMMARY || exit 1
272+
273+
test-yarn-install-max-retries:
274+
name: Test yarn-install-max-retries
275+
runs-on: ubuntu-latest
276+
steps:
277+
- uses: actions/checkout@v4
278+
- name: Checkout and setup environment with custom max retries
279+
id: checkout-and-setup
280+
uses: ./
281+
with:
282+
is-high-risk-environment: false
283+
yarn-install-max-retries: '2'
284+
continue-on-error: true # The install will fail if no yarn.lock, but we want to check retry logic
285+
- name: Check retry count in logs
286+
run: |
287+
grep -c 'yarn --immutable' $GITHUB_STEP_SUMMARY | grep 2 || exit 1

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ This TypeScript module is maintained in the style of the MetaMask team.
3434
fetch-depth: 1
3535
```
3636
37+
#### Custom Yarn URL and Install Retries
38+
39+
```yaml
40+
- name: Checkout and setup with custom Yarn
41+
uses: MetaMask/action-checkout-and-setup@v1
42+
with:
43+
is-high-risk-environment: false
44+
yarn-custom-url: 'https://your-cdn.com/yarn-4.9.1/yarn.js#sha224.abc123'
45+
yarn-install-max-retries: '7'
46+
```
47+
3748
### Options
3849
3950
#### `is-high-risk-environment`
@@ -77,6 +88,18 @@ If set to `true`, the action will skip the `yarn allow-scripts` step. This can s
7788

7889
Defaults to `false`.
7990

91+
#### `yarn-custom-url`
92+
93+
If set, provides a custom URL for a Yarn bundle to be prepared and activated by Corepack. This is useful for CI environments that need to use a self-hosted or alternative Yarn bundle (for example, to avoid rate-limiting from the public Yarn registry).
94+
95+
Defaults to `''` (not set).
96+
97+
#### `yarn-install-max-retries`
98+
99+
Sets the maximum number of retries for the `yarn --immutable` install command. This helps handle transient network errors more gracefully in CI environments.
100+
101+
Defaults to `5`.
102+
80103
## Contributing
81104

82105
### Setup

0 commit comments

Comments
 (0)