Skip to content

Commit 3d416a9

Browse files
authored
allow turning off manifest logging on CI (#113)
1 parent 93d56b1 commit 3d416a9

File tree

5 files changed

+75
-13
lines changed

5 files changed

+75
-13
lines changed

src/config/config-types.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,8 @@ export interface LazyConfig {
336336
* Warning! This will be true even if another workspace lists one of the ignored workspaces as a dependency.
337337
*/
338338
ignoreWorkspaces?: string[]
339+
/**
340+
* Whether to log manifests directly to the terminal on CI
341+
*/
342+
logManifestsOnCi?: boolean
339343
}

src/config/config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,4 +352,11 @@ export class Config {
352352
envInputs: config?.envInputs ?? [],
353353
}
354354
}
355+
356+
/**
357+
* @returns {boolean}
358+
*/
359+
get logManifestsOnCi() {
360+
return this.rootConfig.config.logManifestsOnCi ?? false
361+
}
355362
}

src/config/validateConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export const lazyConfigSchema = z
134134
scripts: z.record(lazyScriptSchema).optional(),
135135
tasks: z.record(lazyScriptSchema).optional(),
136136
ignoreWorkspaces: z.array(z.string()).optional(),
137+
logManifestsOnCi: z.boolean().optional(),
137138
})
138139
.strict()
139140

src/tasks/runTaskIfNeeded.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export async function runTaskIfNeeded(task, tasks) {
7878

7979
if (!didRunTask || didSucceed) {
8080
task.logger.note('input manifest: ' + relative(cwd, previousManifestPath))
81-
if (isCi) {
81+
if (isCi && tasks.config.logManifestsOnCi) {
8282
task.logger.group(
8383
'input manifest',
8484
readFileSync(

test/integration/ci-logging.test.ts

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dir, makePackageJson, runIntegrationTest } from './runIntegrationTests.js'
1+
import { Dir, makeConfigFile, makePackageJson, runIntegrationTest } from './runIntegrationTests.js'
22

33
const simpleDir = {
44
packages: {
@@ -24,6 +24,7 @@ const simpleDir = {
2424
}),
2525
},
2626
},
27+
'lazy.config.js': makeConfigFile({ logManifestsOnCi: true }),
2728
} satisfies Dir
2829

2930
describe('on ci', () => {
@@ -47,27 +48,29 @@ describe('on ci', () => {
4748
expect(output).toMatchInlineSnapshot(`
4849
"lazyrepo 0.0.0-test
4950
-------------------
50-
No config files found, using default configuration.
51+
Loaded config file: lazy.config.js
5152
5253
build::packages/utils finding files took 1.00s
53-
build::packages/utils hashed 3/3 files in 1.00s
54+
build::packages/utils hashed 4/4 files in 1.00s
5455
build::packages/utils cache miss, no previous manifest found
5556
build::packages/utils RUN echo $RANDOM > .out.txt in packages/utils
5657
build::packages/utils input manifest: packages/utils/.lazy/build/manifest.tsv
5758
::group::build::packages/utils input manifest
59+
file lazy.config.js d3592e2a9f8a8206d3870b5d17980068986a638e773c8d103ffda1f426b6a6a9 100.000
5860
file package-lock.json e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 100.000
5961
file packages/utils/index.js e7fb2f4978d27e4f9e23fe22cea20bb3da1632fabb50362e2963c68700a6f1a5 100.000
6062
file packages/utils/package.json 66a4aa54ada27c4596c6e5c7103b46bedef607d952c8985ca520a85c27a16543 100.000
6163
6264
::endgroup::
6365
build::packages/utils ✔ done in 1.00s
6466
build::packages/core finding files took 1.00s
65-
build::packages/core hashed 3/3 files in 1.00s
67+
build::packages/core hashed 4/4 files in 1.00s
6668
build::packages/core cache miss, no previous manifest found
6769
build::packages/core RUN echo $RANDOM > .out.txt in packages/core
6870
build::packages/core input manifest: packages/core/.lazy/build/manifest.tsv
6971
::group::build::packages/core input manifest
70-
upstream package inputs build::packages/utils 2699f1c1aec310b2069f1c207e86385d8f65cb7d9c8a03e9b31be18a5ebde35e
72+
upstream package inputs build::packages/utils bfb72cca7e92aa107893ee16e90022329ba3e1f96cfac17358dcbd196cb233e7
73+
file lazy.config.js d3592e2a9f8a8206d3870b5d17980068986a638e773c8d103ffda1f426b6a6a9 100.000
7174
file package-lock.json e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 100.000
7275
file packages/core/index.js e7fb2f4978d27e4f9e23fe22cea20bb3da1632fabb50362e2963c68700a6f1a5 100.000
7376
file packages/core/package.json ea5dc87ceba8dcac6a0c56e525f861a648ee06094ccf5a8fa33b75ac1f3e75c4 100.000
@@ -85,6 +88,51 @@ describe('on ci', () => {
8588
)
8689
})
8790

91+
test('the full manifest is not logged if you did not specify the option', async () => {
92+
await runIntegrationTest(
93+
{
94+
structure: { ...simpleDir, 'lazy.config.js': makeConfigFile({}) },
95+
packageManager: 'npm',
96+
workspaceGlobs: ['packages/*'],
97+
},
98+
async (t) => {
99+
const { output, status } = await t.exec(['build'], {
100+
env: {
101+
__test__IS_CI_OVERRIDE: 'true',
102+
GITHUB_ACTIONS: 'true',
103+
__test__CONSTANT_MTIME: 'true',
104+
},
105+
})
106+
107+
expect(status).toBe(0)
108+
expect(output).toMatchInlineSnapshot(`
109+
"lazyrepo 0.0.0-test
110+
-------------------
111+
Loaded config file: lazy.config.js
112+
113+
build::packages/utils finding files took 1.00s
114+
build::packages/utils hashed 4/4 files in 1.00s
115+
build::packages/utils cache miss, no previous manifest found
116+
build::packages/utils RUN echo $RANDOM > .out.txt in packages/utils
117+
build::packages/utils input manifest: packages/utils/.lazy/build/manifest.tsv
118+
build::packages/utils ✔ done in 1.00s
119+
build::packages/core finding files took 1.00s
120+
build::packages/core hashed 4/4 files in 1.00s
121+
build::packages/core cache miss, no previous manifest found
122+
build::packages/core RUN echo $RANDOM > .out.txt in packages/core
123+
build::packages/core input manifest: packages/core/.lazy/build/manifest.tsv
124+
build::packages/core ✔ done in 1.00s
125+
126+
Tasks: 2 successful, 2 total
127+
Cached: 0/2 cached
128+
Time: 1.00s
129+
130+
"
131+
`)
132+
},
133+
)
134+
})
135+
88136
test('the full diff is logged', async () => {
89137
await runIntegrationTest(
90138
{
@@ -118,10 +166,10 @@ describe('on ci', () => {
118166
expect(secondRun.output).toMatchInlineSnapshot(`
119167
"lazyrepo 0.0.0-test
120168
-------------------
121-
No config files found, using default configuration.
169+
Loaded config file: lazy.config.js
122170
123171
build::packages/utils finding files took 1.00s
124-
build::packages/utils hashed 1/2 files in 1.00s
172+
build::packages/utils hashed 1/3 files in 1.00s
125173
build::packages/utils cache miss
126174
::group::build::packages/utils changes since last run
127175
- removed file packages/utils/index.js
@@ -130,13 +178,14 @@ describe('on ci', () => {
130178
build::packages/utils RUN echo $RANDOM > .out.txt in packages/utils
131179
build::packages/utils input manifest: packages/utils/.lazy/build/manifest.tsv
132180
::group::build::packages/utils input manifest
181+
file lazy.config.js d3592e2a9f8a8206d3870b5d17980068986a638e773c8d103ffda1f426b6a6a9 100.000
133182
file package-lock.json e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 100.000
134183
file packages/utils/package.json 66a4aa54ada27c4596c6e5c7103b46bedef607d952c8985ca520a85c27a16543 100.000
135184
136185
::endgroup::
137186
build::packages/utils ✔ done in 1.00s
138187
build::packages/core finding files took 1.00s
139-
build::packages/core hashed 1/4 files in 1.00s
188+
build::packages/core hashed 1/5 files in 1.00s
140189
build::packages/core cache miss
141190
::group::build::packages/core changes since last run
142191
± changed upstream package inputs build::packages/utils
@@ -146,7 +195,8 @@ describe('on ci', () => {
146195
build::packages/core RUN echo $RANDOM > .out.txt in packages/core
147196
build::packages/core input manifest: packages/core/.lazy/build/manifest.tsv
148197
::group::build::packages/core input manifest
149-
upstream package inputs build::packages/utils 8b4a40e0f67481c7690f423d943417fa32b97951ccff33e6a167396c6be4be74
198+
upstream package inputs build::packages/utils 194d911887b4c64a70785117830794d541da5943c526313d47075223dda3e349
199+
file lazy.config.js d3592e2a9f8a8206d3870b5d17980068986a638e773c8d103ffda1f426b6a6a9 100.000
150200
file package-lock.json e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 100.000
151201
file packages/core/fun.js 02a83cd560777ec0e33d85bc9dc50fec8de108c55c945443cb608bfa65be9884 100.000
152202
file packages/core/index.js e7fb2f4978d27e4f9e23fe22cea20bb3da1632fabb50362e2963c68700a6f1a5 100.000
@@ -186,18 +236,18 @@ describe('on ci', () => {
186236
expect(output).toMatchInlineSnapshot(`
187237
"lazyrepo 0.0.0-test
188238
-------------------
189-
No config files found, using default configuration.
239+
Loaded config file: lazy.config.js
190240
191241
build::packages/utils finding files took 1.00s
192-
build::packages/utils hashed 3/3 files in 1.00s
242+
build::packages/utils hashed 4/4 files in 1.00s
193243
build::packages/utils cache miss, no previous manifest found
194244
build::packages/utils RUN echo $RANDOM > .out.txt in packages/utils
195245
build::packages/utils input manifest: packages/utils/.lazy/build/manifest.tsv
196246
build::packages/utils input manifest
197247
[ grouped content suppressed on unsupported CI environment ]
198248
build::packages/utils ✔ done in 1.00s
199249
build::packages/core finding files took 1.00s
200-
build::packages/core hashed 3/3 files in 1.00s
250+
build::packages/core hashed 4/4 files in 1.00s
201251
build::packages/core cache miss, no previous manifest found
202252
build::packages/core RUN echo $RANDOM > .out.txt in packages/core
203253
build::packages/core input manifest: packages/core/.lazy/build/manifest.tsv

0 commit comments

Comments
 (0)