Skip to content

Commit c18d48d

Browse files
committed
chore(root): Improve caching of CI (#1936)
1 parent 6f5f70e commit c18d48d

File tree

12 files changed

+646
-150
lines changed

12 files changed

+646
-150
lines changed

.github/workflows/tests.yml

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ on:
55
- main
66
pull_request:
77
jobs:
8-
lint:
8+
build:
99
runs-on: buildjet-4vcpu-ubuntu-2204
10+
outputs:
11+
cache-hit: ${{ steps.pnpm-cache.outputs.cache-hit }}
1012
container:
1113
image: node:22
1214
steps:
@@ -19,95 +21,114 @@ jobs:
1921
corepack enable
2022
corepack prepare [email protected] --activate
2123
pnpm config set script-shell "/usr/bin/bash"
22-
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
2324
2425
- name: pnpm Cache
2526
uses: buildjet/cache@v4
2627
with:
27-
path: ${{ steps.pnpm-setup.outputs.pnpm_cache_dir }}
28-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
28+
path: |
29+
~/.pnpm-store
30+
node_modules
31+
*/*/node_modules
32+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
2933
restore-keys: |
30-
${{ runner.os }}-pnpm-store-
34+
${{ runner.os }}-pnpm-
3135
3236
- name: Install packages
37+
if: steps.pnpm-cache.outputs.cache-hit != 'true'
3338
run: pnpm install --frozen-lockfile
3439

40+
- name: turborepo Cache
41+
uses: buildjet/cache@v4
42+
with:
43+
path: |
44+
.turbo
45+
key: ${{ runner.os }}-turbo-${{ github.sha }}
46+
restore-keys: |
47+
${{ runner.os }}-turbo-
48+
3549
- name: Run Build
3650
run: pnpm build
3751

38-
- name: Run Lint
39-
run: pnpm lint
40-
41-
test:
52+
lint:
4253
runs-on: buildjet-4vcpu-ubuntu-2204
54+
needs: [build]
4355
container:
4456
image: node:22
4557
steps:
4658
- name: Checkout
4759
uses: actions/checkout@v4
4860

49-
- name: Enable Corepack
50-
id: pnpm-setup
61+
- name: Setup pnpm
5162
run: |
5263
corepack enable
5364
corepack prepare [email protected] --activate
54-
pnpm config set script-shell "/usr/bin/bash"
55-
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
5665
57-
- name: pnpm Cache
66+
- name: Restore dependencies
5867
uses: buildjet/cache@v4
5968
with:
60-
path: ${{ steps.pnpm-setup.outputs.pnpm_cache_dir }}
61-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
62-
restore-keys: |
63-
${{ runner.os }}-pnpm-store-
69+
path: |
70+
~/.pnpm-store
71+
node_modules
72+
*/*/node_modules
73+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
6474

65-
- name: Install packages
66-
run: pnpm install --frozen-lockfile
75+
- name: turborepo Cache
76+
uses: buildjet/cache@v4
77+
with:
78+
path: |
79+
.turbo
80+
key: ${{ runner.os }}-turbo-${{ github.sha }}
81+
restore-keys: |
82+
${{ runner.os }}-turbo-
6783
6884
- name: Run Build
6985
run: pnpm build
7086

71-
- name: Run Tests
72-
run: pnpm test
73-
env:
74-
SPAM_ASSASSIN_HOST: ${{ secrets.SPAM_ASSASSIN_HOST }}
75-
SPAM_ASSASSIN_PORT: ${{ secrets.SPAM_ASSASSIN_PORT }}
87+
- name: Run Lint
88+
run: pnpm lint
7689

77-
build:
90+
test:
7891
runs-on: buildjet-4vcpu-ubuntu-2204
92+
needs: [build]
7993
container:
8094
image: node:22
8195
steps:
8296
- name: Checkout
8397
uses: actions/checkout@v4
8498

85-
- name: Enable Corepack
86-
id: pnpm-setup
99+
- name: Setup pnpm
87100
run: |
88101
corepack enable
89102
corepack prepare [email protected] --activate
90-
pnpm config set script-shell "/usr/bin/bash"
91-
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
92103
93-
- name: pnpm Cache
104+
- name: Restore dependencies
94105
uses: buildjet/cache@v4
95106
with:
96-
path: ${{ steps.pnpm-setup.outputs.pnpm_cache_dir }}
97-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
98-
restore-keys: |
99-
${{ runner.os }}-pnpm-store-
107+
path: |
108+
~/.pnpm-store
109+
node_modules
110+
*/*/node_modules
111+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
100112

101-
- name: Install packages
102-
run: pnpm install --frozen-lockfile
113+
- name: turborepo Cache
114+
uses: buildjet/cache@v4
115+
with:
116+
path: |
117+
.turbo
118+
key: ${{ runner.os }}-turbo-${{ github.sha }}
119+
restore-keys: |
120+
${{ runner.os }}-turbo-
103121
104-
- name: Run Build
105-
run: pnpm build
122+
- name: Run Tests
123+
run: pnpm test
124+
env:
125+
SPAM_ASSASSIN_HOST: ${{ secrets.SPAM_ASSASSIN_HOST }}
126+
SPAM_ASSASSIN_PORT: ${{ secrets.SPAM_ASSASSIN_PORT }}
106127

107128
dependencies:
108129
runs-on: buildjet-4vcpu-ubuntu-2204
109130
container:
110-
image: node:18
131+
image: node:22
111132
steps:
112133
- name: Checkout
113134
uses: actions/checkout@v4

packages/react-email/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@radix-ui/react-slot": "1.1.0",
4646
"@radix-ui/react-toggle-group": "1.1.0",
4747
"@radix-ui/react-tooltip": "1.1.2",
48-
"@react-email/render": "workspace:*",
48+
"@react-email/components": "workspace:*",
4949
"@swc/core": "1.4.15",
5050
"@types/babel__core": "7.20.5",
5151
"@types/fs-extra": "11.0.1",

packages/react-email/src/cli/commands/export.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs, { unlinkSync, writeFileSync } from 'node:fs';
22
import path from 'node:path';
3-
import type { Options } from '@react-email/render';
3+
import type { Options } from '@react-email/components';
44
import { type BuildFailure, build } from 'esbuild';
55
import { glob } from 'glob';
66
import logSymbols from 'log-symbols';

packages/react-email/src/utils/get-email-component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-non-null-assertion */
22
import path from 'node:path';
33
import vm from 'node:vm';
4-
import type { render } from '@react-email/render';
4+
import type { render } from '@react-email/components';
55
import { type BuildFailure, type OutputFile, build } from 'esbuild';
66
import type React from 'react';
77
import type { RawSourceMap } from 'source-map-js';

packages/tailwind/integrations/integrations.spec.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1+
import { spawnSync } from 'node:child_process';
12
import path from 'node:path';
2-
import shell from 'shelljs';
33

44
const $ = (command: string, cwd: string = path.resolve(__dirname, '..')) => {
5-
const executionResult = shell.exec(command, {
5+
process.stderr.write(`${cwd} $ ${command}\n`);
6+
const returns = spawnSync(command, {
7+
shell: true,
68
cwd,
7-
fatal: true,
8-
silent: true,
9+
stdio: 'inherit',
910
});
10-
if (executionResult.code !== 0) {
11-
process.stdout.write(executionResult.stderr);
12-
process.stderr.write(executionResult.stderr);
13-
}
1411
expect(
15-
executionResult.code,
12+
returns.status,
1613
`Expected command "${command}" to work properly but it returned a non-zero exit code`,
1714
).toBe(0);
1815
};

0 commit comments

Comments
 (0)