@@ -54,24 +54,28 @@ describe("GitHub release workflow", () => {
5454 } ) ;
5555
5656 it ( "keeps merged fork code out of the trusted release checkout" , ( ) => {
57- const checkout = steps . find ( ( step ) => step . name === "Check out trusted main history" ) ;
57+ const checkout = steps . find ( ( step ) => step . name === "Check out trusted base history" ) ;
5858 expect ( checkout ?. uses ) . toBe ( "actions/checkout@v4" ) ;
59- expect ( checkout ?. with ) . toEqual (
60- expect . objectContaining ( {
61- ref : "main" ,
62- "fetch-depth" : 0 ,
63- "persist-credentials" : false ,
64- } ) ,
65- ) ;
66- expect ( JSON . stringify ( checkout ?. with ) ) . not . toContain ( "target_sha" ) ;
59+ expect ( checkout ?. with ) . toEqual ( {
60+ "fetch-depth" : 0 ,
61+ "persist-credentials" : false ,
62+ } ) ;
63+ expect ( checkout ?. with ) . not . toHaveProperty ( "ref" ) ;
64+ expect ( JSON . stringify ( checkout ) ) . not . toContain ( "github.event.pull_request" ) ;
65+ expect ( source ) . not . toContain ( "refs/pull/" ) ;
6766 expect ( source ) . not . toContain ( "allow-unsafe-pr-checkout" ) ;
6867
6968 const verifyScript = script ( "Verify target is on main" ) ;
70- expect ( verifyScript ) . toContain ( "refs/heads/main:refs/remotes/ origin/ main" ) ;
69+ expect ( verifyScript ) . toContain ( "git fetch --no-tags origin main" ) ;
7170 expect ( verifyScript ) . toContain ( 'git cat-file -e "$TARGET_SHA^{commit}"' ) ;
72- expect ( verifyScript ) . toContain (
73- 'git merge-base --is-ancestor "$TARGET_SHA" refs/remotes/origin/main' ,
74- ) ;
71+ const ancestorCheck = 'git merge-base --is-ancestor "$TARGET_SHA" origin/main' ;
72+ const detachTarget = 'git checkout --detach "$TARGET_SHA"' ;
73+ const verifyHead = 'test "$(git rev-parse HEAD)" = "$TARGET_SHA"' ;
74+ expect ( verifyScript ) . toContain ( ancestorCheck ) ;
75+ expect ( verifyScript ) . toContain ( detachTarget ) ;
76+ expect ( verifyScript ) . toContain ( verifyHead ) ;
77+ expect ( verifyScript . indexOf ( detachTarget ) ) . toBeGreaterThan ( verifyScript . indexOf ( ancestorCheck ) ) ;
78+ expect ( verifyScript . indexOf ( verifyHead ) ) . toBeGreaterThan ( verifyScript . indexOf ( detachTarget ) ) ;
7579
7680 const notesScript = script ( "Build release notes" ) ;
7781 expect ( notesScript ) . toContain ( 'manual_object="${TARGET_SHA}:${manual_notes}"' ) ;
0 commit comments