@@ -5,7 +5,12 @@ import path from 'node:path';
55import { expect , test } from 'vitest' ;
66import { parse } from 'yaml' ;
77import { mkdtempForTestSync } from '@agent-device/test-kit' ;
8- import { selectAppleBridgeProof , selectIosSmoke , selectIosXctests } from '../apple-ci-impact.ts' ;
8+ import {
9+ selectAppleBridgeProof ,
10+ selectIosSmoke ,
11+ selectIosXctests ,
12+ selectMacosSmoke ,
13+ } from '../apple-ci-impact.ts' ;
914import { selectChecks } from '../check-affected/model.ts' ;
1015
1116const repoRoot = path . resolve ( import . meta. dirname , '../..' ) ;
@@ -226,12 +231,32 @@ test.each([
226231 [ 'macOS silently skipped' , { MACOS_OUTCOME : 'skipped' } , 1 ] ,
227232 [ 'iOS cleanup fails' , { IOS_CLEANUP_OUTCOME : 'failure' } , 1 ] ,
228233 [ 'macOS cleanup fails' , { MACOS_CLEANUP_OUTCOME : 'failure' } , 1 ] ,
234+ [ 'macOS not selected' , { MACOS_SELECTED : 'false' , MACOS_OUTCOME : 'skipped' } , 0 ] ,
235+ [ 'unselected macOS unexpectedly ran' , { MACOS_SELECTED : 'false' } , 1 ] ,
236+ [
237+ 'no phase selected' ,
238+ {
239+ IOS_SELECTED : 'false' ,
240+ IOS_OUTCOME : 'skipped' ,
241+ MACOS_SELECTED : 'false' ,
242+ MACOS_OUTCOME : 'skipped' ,
243+ IOS_CLEANUP_OUTCOME : 'skipped' ,
244+ MACOS_CLEANUP_OUTCOME : 'skipped' ,
245+ } ,
246+ 0 ,
247+ ] ,
248+ [
249+ 'cleanup skipped while a phase ran' ,
250+ { IOS_SELECTED : 'false' , IOS_OUTCOME : 'skipped' , MACOS_CLEANUP_OUTCOME : 'skipped' } ,
251+ 1 ,
252+ ] ,
229253] as const ) ( 'the final Apple status guard preserves failure: %s' , ( _label , overrides , expected ) => {
230254 const guard = appleJob ( ) . steps . find ( ( step ) => step . env ?. IOS_OUTCOME ) ! ;
231255 expect ( guard . if ) . toBe ( 'always()' ) ;
232256 expect ( guard . env ) . toEqual ( {
233257 IOS_SELECTED : '${{ steps.ios-impact.outputs.run }}' ,
234258 IOS_OUTCOME : '${{ steps.ios.outcome }}' ,
259+ MACOS_SELECTED : '${{ steps.macos-impact.outputs.run }}' ,
235260 MACOS_OUTCOME : '${{ steps.macos.outcome }}' ,
236261 IOS_CLEANUP_OUTCOME : '${{ steps.ios-cleanup.outcome }}' ,
237262 MACOS_CLEANUP_OUTCOME : '${{ steps.macos-cleanup.outcome }}' ,
@@ -241,6 +266,7 @@ test.each([
241266 ...process . env ,
242267 IOS_SELECTED : 'true' ,
243268 IOS_OUTCOME : 'success' ,
269+ MACOS_SELECTED : 'true' ,
244270 MACOS_OUTCOME : 'success' ,
245271 IOS_CLEANUP_OUTCOME : 'success' ,
246272 MACOS_CLEANUP_OUTCOME : 'success' ,
@@ -280,6 +306,35 @@ test('iOS smoke uses affected-check ownership and fails open on uncertain diffs'
280306 expect ( selectIosSmoke ( 'push' , [ 'src/foo.test.ts' ] ) . run ) . toBe ( true ) ;
281307} ) ;
282308
309+ test ( 'macOS smoke uses affected-check ownership and keeps the bridge proof inputs' , ( ) => {
310+ const steps = appleJob ( ) . steps ;
311+ const select = steps . find ( ( step ) => step . id === 'macos-impact' ) ! ;
312+ const build = steps . find ( ( step ) => step . id === 'build' ) ! ;
313+ const macos = steps . find ( ( step ) => step . id === 'macos' ) ! ;
314+ expect ( select . run ) . toContain ( 'scripts/apple-ci-impact.ts macos' ) ;
315+ expect ( steps . indexOf ( select ) ) . toBeLessThan ( steps . indexOf ( build ) ) ;
316+ expect ( build . if ) . toContain ( "steps.macos-impact.outputs.run != 'false'" ) ;
317+ expect ( macos . if ) . toContain ( "steps.macos-impact.outputs.run != 'false'" ) ;
318+ for ( const file of [
319+ 'src/foo.test.ts' ,
320+ 'packages/daemon/src/sessions/__tests__/session.test.ts' ,
321+ 'packages/platform-android/src/index.ts' ,
322+ 'test/integration/replays/ios/basic.ad' ,
323+ ] ) {
324+ expect ( selectMacosSmoke ( 'pull_request' , [ file ] ) . run , file ) . toBe ( false ) ;
325+ }
326+ for ( const file of [
327+ 'packages/platform-apple/src/foldable/fold-helper-cache.test.ts' ,
328+ 'packages/platform-apple/src/index.ts' ,
329+ 'src/index.ts' ,
330+ '.github/actions/smoke-macos/action.yml' ,
331+ ] ) {
332+ expect ( selectMacosSmoke ( 'pull_request' , [ file ] ) . run , file ) . toBe ( true ) ;
333+ }
334+ expect ( selectMacosSmoke ( 'pull_request' , null ) . run ) . toBe ( true ) ;
335+ expect ( selectMacosSmoke ( 'push' , [ 'src/foo.test.ts' ] ) . run ) . toBe ( true ) ;
336+ } ) ;
337+
283338function cacheInputs ( action : string , stepId = 'source-hash' ) : string [ ] {
284339 const doc = parse ( action ) as { runs ?: { steps ?: Array < { id ?: string ; run ?: string } > } } ;
285340 const hashStep = doc . runs ?. steps ?. find ( ( step ) => step . id === stepId ) ?. run ?? '' ;
@@ -542,7 +597,7 @@ test('a shallow PR merge still yields a known change set for all Apple selectors
542597 ) ;
543598 expect ( select ( 'xctest' ) ) . toContain ( 'skip;' ) ;
544599 expect ( select ( 'bridge' ) ) . toContain ( 'skip;' ) ;
545- expect ( select ( 'smoke' ) ) . toContain ( 'run; iOS device-lane input changed: src/feature.ts' ) ;
600+ expect ( select ( 'smoke' ) ) . toContain ( 'run; replay-ios input changed: src/feature.ts' ) ;
546601 } finally {
547602 fs . rmSync ( root , { recursive : true , force : true } ) ;
548603 }
0 commit comments