Skip to content

Commit a2f451b

Browse files
authored
ci(repo): Update CI flow; Integrate Turbo caching [SDK-854] (#1934)
* ci(repo): Update CI flow; Integrate Turbo caching * chore(repo): Add changeset * build(repo): Extracted actions (#1946)
1 parent fa901ab commit a2f451b

13 files changed

Lines changed: 382 additions & 364 deletions

File tree

.changeset/blue-lies-drop.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/actions/init/action.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
2+
name: Setup Action
3+
description: Checkout, setup node and dependencies
4+
inputs:
5+
node-version:
6+
description: 'The node version to use'
7+
required: false
8+
default: '18'
9+
playwright-enabled:
10+
description: 'Enable Playwright?'
11+
required: false
12+
default: 'false'
13+
turbo-enabled:
14+
description: 'Enable Turbo?'
15+
required: false
16+
default: 'true'
17+
turbo-cache-dir:
18+
description: 'The cache dir to use for Turbo'
19+
required: false
20+
default: './.turbo-cache'
21+
turbo-signature:
22+
description: 'The signature to use for Turbo'
23+
required: false
24+
turbo-remote-only:
25+
description: 'Only use remote cache?'
26+
required: false
27+
default: 'true'
28+
turbo-team:
29+
description: 'The team to use for Turbo remote auth'
30+
required: true
31+
turbo-token:
32+
description: 'The token to use for Turbo remote auth'
33+
required: true
34+
35+
runs:
36+
using: "composite"
37+
steps:
38+
- name: Configure Turborepo
39+
id: turbo
40+
uses: actions/github-script@v6
41+
env:
42+
# envs are required to pass inputs to the script
43+
ENABLED: ${{ inputs.turbo-enabled }}
44+
CACHE_DIR: ${{ inputs.turbo-cache-dir }}
45+
REMOTE_ONLY: ${{ inputs.turbo-remote-only }}
46+
SIGNATURE: ${{ inputs.turbo-signature }}
47+
TEAM: ${{ inputs.turbo-team }}
48+
TOKEN: ${{ inputs.turbo-token }}
49+
with:
50+
script: |
51+
const os = require('os')
52+
const cpus =
53+
typeof os.availableParallelism === "function"
54+
? os.availableParallelism()
55+
: os.cpus().length;
56+
57+
const { ENABLED, CACHE_DIR, SIGNATURE, REMOTE_ONLY, TEAM, TOKEN } = process.env
58+
59+
core.exportVariable('TURBO_ARGS',
60+
[
61+
'--output-logs=new-only',
62+
`--cache-dir=${CACHE_DIR}`,
63+
`--concurrency=${cpus}`
64+
].join(' ')
65+
)
66+
67+
if (ENABLED === 'true') {
68+
core.exportVariable('TURBO_TEAM', TEAM)
69+
core.exportVariable('TURBO_TOKEN', TOKEN)
70+
core.exportVariable('TURBO_REMOTE_ONLY', REMOTE_ONLY)
71+
}
72+
73+
if (SIGNATURE && SIGNATURE !== '') {
74+
core.exportVariable('TURBO_REMOTE_CACHE_SIGNATURE_KEY', SIGNATURE)
75+
}
76+
77+
core.exportVariable('FORCE_COLOR', '1')
78+
79+
- name: Turborepo CLI Args
80+
shell: bash
81+
run: echo $TURBO_ARGS
82+
83+
- name: Setup NodeJS ${{ inputs.node-version }}
84+
uses: actions/setup-node@v3
85+
with:
86+
node-version: ${{ inputs.node-version }}
87+
88+
- name: Cache node_modules
89+
uses: actions/cache@v3
90+
id: npm-cache
91+
with:
92+
path: ./node_modules
93+
key: ${{ runner.os }}-node-${{ inputs.node-version }}-node-modules-${{ hashFiles('**/package-lock.json') }}
94+
95+
- name: Install NPM Dependencies
96+
if: steps.npm-cache.outputs.cache-hit != 'true'
97+
run: npm ci --audit=false --fund=false
98+
shell: bash
99+
100+
- name: Get Playwright Version
101+
if: inputs.playwright-enabled == 'true'
102+
shell: bash
103+
id: playwright-version
104+
run: echo "VERSION=$(node -e "console.log($(npm ls @playwright/test --json).dependencies['@playwright/test'].version)")" >> "$GITHUB_OUTPUT"
105+
106+
- name: Cache Playwright Binaries
107+
if: inputs.playwright-enabled == 'true'
108+
uses: actions/cache@v3
109+
id: playwright-cache
110+
with:
111+
path: ~/.cache/ms-playwright
112+
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-playwright-${{ steps.playwright-version.outputs.VERSION }}
113+
114+
- name: Install Playwright Browsers
115+
if: inputs.playwright-enabled == 'true' && steps.playwright-cache.outputs.cache-hit != 'true'
116+
shell: bash
117+
run: npx playwright install --with-deps

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ runs:
3030
name: Install dependencies
3131
shell: bash
3232
run: npm ci
33-
- if: ${{ inputs.use-turbo-cache == 'true' }}
33+
- if: ${{ inputs.use-turbo-cache == 'true' }}
3434
name: Download turbo cache
3535
uses: actions/download-artifact@v3
3636
with:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Run Verdaccio
2+
description: Checkout, setup node and dependencies
3+
inputs:
4+
auth-email:
5+
description: 'The email to use for auth'
6+
required: false
7+
default: 'test@test.com'
8+
auth-password:
9+
description: 'The pass to use for auth'
10+
required: false
11+
default: 'pass'
12+
auth-user:
13+
description: 'The user to use for auth'
14+
required: false
15+
default: 'user'
16+
publish-cmd:
17+
description: 'The command to use to publish'
18+
required: true
19+
registry:
20+
description: 'The registry to use'
21+
required: false
22+
default: 'http://localhost:4873'
23+
24+
runs:
25+
using: "composite"
26+
steps:
27+
- name: Update NPM Registry to Verdaccio
28+
shell: bash
29+
run: npm set registry ${{ inputs.registry }}
30+
31+
- name: Run Verdaccio
32+
shell: bash
33+
run: |
34+
nohup ./node_modules/.bin/verdaccio --config ./verdaccio.yaml & sleep 5
35+
./node_modules/.bin/npm-cli-adduser -u ${{ inputs.auth-user }} -p ${{ inputs.auth-password }} -e ${{ inputs.auth-email }} -r ${{ inputs.registry }}
36+
./node_modules/.bin/npm-cli-login -u ${{ inputs.auth-user }} -p ${{ inputs.auth-password }} -e ${{ inputs.auth-email }} -r ${{ inputs.registry }}
37+
38+
- name: Publish to Verdaccio
39+
shell: bash
40+
run: ${{ inputs.publish-cmd }}

.github/workflows/base-changeset.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/base-prettier.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/base-registry.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/checks.yml

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)