-
Notifications
You must be signed in to change notification settings - Fork 460
Expand file tree
/
Copy pathaction.yml
More file actions
152 lines (135 loc) · 4.98 KB
/
Copy pathaction.yml
File metadata and controls
152 lines (135 loc) · 4.98 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
name: Setup Action
description: Checkout, setup node and dependencies
inputs:
node-version:
description: 'The node version to use'
required: false
default: '24.15.0'
playwright-enabled:
description: 'Enable Playwright?'
required: false
default: 'false'
turbo-summarize:
description: 'The token to use for Turbo task summaries'
required: false
default: 'false'
turbo-enabled:
description: 'Enable Turbo?'
required: false
default: 'true'
turbo-cache:
description: 'Cache usage settings'
required: false
default: 'remote:rw'
turbo-signature:
description: 'The signature to use for Turbo'
required: false
turbo-team:
description: 'The team to use for Turbo remote auth'
required: false
turbo-token:
description: 'The token to use for Turbo remote auth'
required: false
registry-url:
description: 'The registry the packages will be published to'
required: false
default: ''
verbose:
description: 'Enable verbose output'
required: false
default: 'false'
cache-enabled:
description: 'Enable setup-node pnpm cache and Playwright cache restore. Defaults to false so privileged jobs that hold id-token: write cannot accidentally restore poisonable cache state. Callers that want cache (ordinary CI) must opt in with cache-enabled: true.'
required: false
default: 'false'
runs:
using: 'composite'
steps:
- name: Configure Turborepo
id: turbo
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
env:
# envs are required to pass inputs to the script
CACHE: ${{ inputs.turbo-cache }}
ENABLED: ${{ inputs.turbo-enabled }}
SIGNATURE: ${{ inputs.turbo-signature }}
SUMMARIZE: ${{ inputs.turbo-summarize }}
TEAM: ${{ inputs.turbo-team }}
TOKEN: ${{ inputs.turbo-token }}
VERBOSE: ${{ inputs.verbose }}
with:
script: |
const os = require('os')
const cpus =
typeof os.availableParallelism === "function"
? os.availableParallelism()
: os.cpus().length;
const { ENABLED, CACHE = 'remote:rw', SIGNATURE, SUMMARIZE, TEAM, TOKEN, VERBOSE } = process.env
const ARGS = [
`--concurrency=${cpus}`,
`--summarize=${SUMMARIZE}`,
]
if (VERBOSE === 'true') {
ARGS.push('--verbosity=2')
ARGS.push('--log-order=stream')
ARGS.push('--output-logs=full')
} else {
ARGS.push('--output-logs=new-only')
}
core.exportVariable('TURBO_ARGS',
ARGS.join(' ')
)
if (ENABLED === 'true') {
const missing = []
if (!TEAM) missing.push('turbo-team')
if (!TOKEN) missing.push('turbo-token')
if (missing.length > 0) {
core.warning(`Missing Turbo remote cache credentials: ${missing.join(', ')}. Turbo remote caching will be disabled.`)
} else {
core.exportVariable('TURBO_CACHE', CACHE)
core.exportVariable('TURBO_TEAM', TEAM)
core.exportVariable('TURBO_TOKEN', TOKEN)
}
}
if (SIGNATURE && SIGNATURE !== '') {
core.exportVariable('TURBO_REMOTE_CACHE_SIGNATURE_KEY', SIGNATURE)
}
core.exportVariable('FORCE_COLOR', '1')
- name: Turborepo CLI Args
shell: bash
run: echo $TURBO_ARGS
- name: Install PNPM
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
- name: Setup NodeJS ${{ inputs.node-version }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
cache: ${{ inputs.cache-enabled == 'true' && 'pnpm' || '' }}
node-version: ${{ inputs.node-version }}
registry-url: ${{ inputs.registry-url }}
- name: Install PNPM Dependencies
env:
CYPRESS_INSTALL_BINARY: 0
run: pnpm install --frozen-lockfile
shell: bash
- name: Add node_modules/.bin to PATH
run: echo "${{ github.workspace }}/node_modules/.bin" >> $GITHUB_PATH
shell: bash
- name: Get Playwright Version
if: inputs.playwright-enabled == 'true'
shell: bash
id: playwright-version
run: |
VERSION=$(node -p "require('@playwright/test/package.json').version")
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: Cache Playwright Binaries
if: inputs.playwright-enabled == 'true' && inputs.cache-enabled == 'true'
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-playwright-${{ steps.playwright-version.outputs.VERSION }}-v2
- name: Install Playwright Browsers
if: inputs.playwright-enabled == 'true' && steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash
run: |
pnpm playwright install chromium