-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
action.yml
78 lines (69 loc) · 2.87 KB
/
action.yml
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
# IMPORTANT NOTE TO MAINTAINERS
#
# Changes to this composite action should be carefully considered and reviewed because it is referenced
# and executed by multiple workflows in our private-automations repository.
#
# Ensure that a member of @typescript-eslint/core-team tests changes there before merging.
name: 'Prepare: Install'
description: 'Prepares the repo by installing dependencies'
inputs:
node-version:
description: 'The node version to setup'
required: true
registry-url:
description: 'Define registry-url'
required: false
# NOTE: This is required for our use-case of sharing this action across multiple repos
working-directory:
description: 'Override the working directory to run the installation in'
required: false
default: '.'
# outputs: - no outputs
runs:
using: 'composite'
steps:
- name: echo github.ref
shell: bash
working-directory: ${{ inputs.working-directory }}
run: echo ${{ github.ref }}
- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
registry-url: ${{ inputs.registry-url }}
# Yarn 3 caching strategy which follows taken from https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a
- name: Expose yarn config as "$GITHUB_OUTPUT"
id: yarn-config
shell: bash
run: |
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
# Yarn rotates the downloaded cache archives, @see https://github.com/actions/setup-node/issues/325
# Yarn cache is also reusable between arch and os.
- name: Restore yarn cache
uses: actions/cache@v4
id: yarn-download-cache
with:
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
key: yarn-download-cache-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-download-cache-
# Invalidated on yarn.lock changes
- name: Restore yarn install state
id: yarn-install-state-cache
uses: actions/cache@v4
with:
path: .yarn/ci-cache/
key: ${{ runner.os }}-yarn-install-state-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }}
- name: Install dependencies
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
yarn install --immutable --inline-builds
yarn check-clean-workspace-after-install
env:
# CI optimizations. Overrides yarnrc.yml options (or their defaults) in the CI action.
YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives
YARN_NM_MODE: 'hardlinks-local' # Hardlinks-(local|global) reduces io / node_modules size
YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz # Very small speedup when lock does not change
# Other environment variables
HUSKY: '0' # By default do not run HUSKY install