@@ -423,16 +423,11 @@ func TestJobWithGitHubApp(t *testing.T) {
423423
424424 stepsContent := strings .Join (job .Steps , "" )
425425
426- // Token minting has moved to the activation job; the safe_outputs job should NOT
427- // contain "Generate GitHub App token" anymore.
428- assert .NotContains (t , stepsContent , "Generate GitHub App token" , "Token minting step should be in activation job, not safe_outputs job" )
426+ // Should include app token minting step
427+ assert .Contains (t , stepsContent , "Generate GitHub App token" )
429428
430- // The safe_outputs job should reference the activation output token
431- assert .Contains (t , stepsContent , "needs.activation.outputs.safe_outputs_app_token" ,
432- "Safe_outputs job should reference the token minted in the activation job" )
433-
434- // Should include app token invalidation step (using the activation output)
435- assert .Contains (t , stepsContent , "Invalidate GitHub App token" , "Token invalidation step should still be present in safe_outputs job" )
429+ // Should include app token invalidation step
430+ assert .Contains (t , stepsContent , "Invalidate GitHub App token" )
436431}
437432
438433// TestAssignToAgentWithGitHubAppUsesAgentToken tests that when github-app: is configured,
@@ -462,9 +457,8 @@ func TestAssignToAgentWithGitHubAppUsesAgentToken(t *testing.T) {
462457
463458 stepsContent := strings .Join (job .Steps , "" )
464459
465- // Token minting has moved to the activation job; the safe_outputs job should NOT
466- // contain "Generate GitHub App token" anymore.
467- assert .NotContains (t , stepsContent , "Generate GitHub App token" , "Token minting step should be in activation job, not safe_outputs job" )
460+ // App token minting step should be present (github-app: is configured)
461+ assert .Contains (t , stepsContent , "Generate GitHub App token" , "App token minting step should be present" )
468462
469463 // Find the assign_to_agent step section
470464 assignToAgentStart := strings .Index (stepsContent , "id: assign_to_agent" )
@@ -655,23 +649,27 @@ func TestGitHubAppWithPushToPRBranch(t *testing.T) {
655649
656650 stepsContent := strings .Join (job .Steps , "" )
657651
658- // Token minting has moved to the activation job; safe_outputs job should NOT contain it.
652+ // Should include app token minting step exactly once
659653 tokenMintCount := strings .Count (stepsContent , "Generate GitHub App token" )
660- assert .Equal (t , 0 , tokenMintCount , "App token minting step should be in activation job, not safe_outputs job ( found %d times) " , tokenMintCount )
654+ assert .Equal (t , 1 , tokenMintCount , "App token minting step should appear exactly once, found %d times" , tokenMintCount )
661655
662- // Should include app token invalidation step exactly once (invalidation stays in agent job)
656+ // Should include app token invalidation step exactly once
663657 tokenInvalidateCount := strings .Count (stepsContent , "Invalidate GitHub App token" )
664658 assert .Equal (t , 1 , tokenInvalidateCount , "App token invalidation step should appear exactly once, found %d times" , tokenInvalidateCount )
665659
666- // Invalidation step should reference the token from activation outputs
667- assert .Contains (t , stepsContent , "needs.activation.outputs.safe_outputs_app_token" ,
668- "Invalidation step should reference the activation job's safe_outputs_app_token output" )
660+ // Token step should come before checkout step (checkout references the token)
661+ tokenIndex := strings .Index (stepsContent , "Generate GitHub App token" )
662+ checkoutIndex := strings .Index (stepsContent , "Checkout repository" )
663+ assert .Less (t , tokenIndex , checkoutIndex , "Token minting step should come before checkout step" )
664+
665+ // Verify step ID is set correctly
666+ assert .Contains (t , stepsContent , "id: safe-outputs-app-token" )
669667}
670668
671669// TestJobWithGitHubAppWorkflowCallUsesTargetRepoNameFallback is a regression test verifying that
672- // the activation job (which now mints the safe-outputs app token) uses
673- // steps.resolve-host-repo .outputs.target_repo_name (repo name only, no owner prefix) as the
674- // repositories fallback for the GitHub App token mint step, instead of the full target_repo slug.
670+ // a safe-output job compiled for a workflow_call trigger uses
671+ // needs.activation .outputs.target_repo_name (repo name only, no owner prefix) as the repositories
672+ // fallback for the GitHub App token mint step, instead of the full target_repo slug.
675673// This prevents actions/create-github-app-token from receiving an invalid owner/repo slug
676674// in the repositories field when owner is also set.
677675func TestJobWithGitHubAppWorkflowCallUsesTargetRepoNameFallback (t * testing.T ) {
@@ -693,25 +691,24 @@ func TestJobWithGitHubAppWorkflowCallUsesTargetRepoNameFallback(t *testing.T) {
693691 },
694692 }
695693
696- // Token minting has moved to the activation job.
697- activationJob , err := compiler .buildActivationJob (workflowData , false , "" , "test.lock.yml" )
694+ job , _ , err := compiler .buildConsolidatedSafeOutputsJob (workflowData , string (constants .AgentJobName ), "test.md" )
698695
699- require .NoError (t , err , "Should successfully build activation job" )
700- require .NotNil (t , activationJob , "Activation job should not be nil" )
696+ require .NoError (t , err , "Should successfully build job" )
697+ require .NotNil (t , job , "Job should not be nil" )
701698
702- activationStepsContent := strings .Join (activationJob .Steps , "" )
699+ stepsContent := strings .Join (job .Steps , "" )
703700
704- // The activation job must use the step-level output (it runs the resolve-host-repo step itself),
705- // NOT the full slug from target_repo.
706- assert .Contains (t , activationStepsContent , "repositories: ${{ steps.resolve-host-repo.outputs.target_repo_name }}" ,
707- "Activation job GitHub App token step must use target_repo_name (repo name only) for workflow_call workflows" )
708- assert .NotContains (t , activationStepsContent , "repositories: ${{ needs.activation.outputs.target_repo_name }}" ,
709- "Activation job GitHub App token step must not use needs.activation (it IS the activation job)" )
701+ // Must use the repo-name-only output, NOT the full slug
702+ assert .Contains (t , stepsContent , "repositories: ${{ needs.activation.outputs.target_repo_name }}" ,
703+ "GitHub App token step must use target_repo_name (repo name only) for workflow_call workflows" )
704+ assert .NotContains (t , stepsContent , "repositories: ${{ needs.activation.outputs.target_repo }}" ,
705+ "GitHub App token step must not use target_repo (full slug) for workflow_call workflows" )
710706}
711707
712708// TestConclusionJobWithGitHubAppWorkflowCallUsesTargetRepoNameFallback is a regression test
713- // verifying that the conclusion job no longer mints a token itself (token minting moved to
714- // the activation job), and that the conclusion job references the activation output token.
709+ // verifying that the conclusion job compiled for a workflow_call trigger uses
710+ // needs.activation.outputs.target_repo_name (repo name only) as the repositories fallback
711+ // for the GitHub App token mint step.
715712func TestConclusionJobWithGitHubAppWorkflowCallUsesTargetRepoNameFallback (t * testing.T ) {
716713 compiler := NewCompiler ()
717714 compiler .jobManager = NewJobManager ()
@@ -737,12 +734,11 @@ func TestConclusionJobWithGitHubAppWorkflowCallUsesTargetRepoNameFallback(t *tes
737734
738735 stepsContent := strings .Join (job .Steps , "" )
739736
740- // Token minting moved to activation; conclusion job must NOT mint a token.
741- assert .NotContains (t , stepsContent , "actions/create-github-app-token" ,
742- "Conclusion job must not mint a GitHub App token (minting moved to activation job)" )
743- // Conclusion job should still invalidate the token via the activation output.
744- assert .Contains (t , stepsContent , "needs.activation.outputs.safe_outputs_app_token" ,
745- "Conclusion job should reference the safe_outputs_app_token from the activation job" )
737+ // Must use the repo-name-only output, NOT the full slug
738+ assert .Contains (t , stepsContent , "repositories: ${{ needs.activation.outputs.target_repo_name }}" ,
739+ "Conclusion job GitHub App token step must use target_repo_name (repo name only) for workflow_call workflows" )
740+ assert .NotContains (t , stepsContent , "repositories: ${{ needs.activation.outputs.target_repo }}" ,
741+ "Conclusion job GitHub App token step must not use target_repo (full slug) for workflow_call workflows" )
746742}
747743
748744// TestCallWorkflowOnly_UsesHandlerManagerStep asserts that a workflow configured with only
0 commit comments