@@ -190,6 +190,52 @@ When tools.github.github-token is set, the top-level github-app fallback should
190190 "tools.github.github-app should NOT be set when github-token is configured" )
191191}
192192
193+ // TestTopLevelGitHubAppToolsGitHubFalseSkip tests that the fallback is NOT applied
194+ // to tools.github when github is explicitly disabled (github: false).
195+ func TestTopLevelGitHubAppToolsGitHubFalseSkip (t * testing.T ) {
196+ compiler := NewCompilerWithVersion ("1.0.0" )
197+
198+ tmpDir := t .TempDir ()
199+ workflowsDir := filepath .Join (tmpDir , ".github" , "workflows" )
200+ require .NoError (t , os .MkdirAll (workflowsDir , 0755 ))
201+
202+ // Workflow with top-level github-app but tools.github explicitly disabled
203+ workflowContent := `---
204+ on: issues
205+ permissions:
206+ contents: read
207+ github-app:
208+ app-id: ${{ vars.APP_ID }}
209+ private-key: ${{ secrets.APP_PRIVATE_KEY }}
210+ tools:
211+ github: false
212+ engine: copilot
213+ ---
214+
215+ # Workflow With GitHub Tool Explicitly Disabled
216+
217+ When tools.github is set to false, the top-level github-app fallback should NOT re-enable it.
218+ `
219+ mdPath := filepath .Join (workflowsDir , "main.md" )
220+ require .NoError (t , os .WriteFile (mdPath , []byte (workflowContent ), 0644 ))
221+
222+ origDir , err := os .Getwd ()
223+ require .NoError (t , err )
224+ require .NoError (t , os .Chdir (workflowsDir ))
225+ defer func () { _ = os .Chdir (origDir ) }()
226+
227+ data , err := compiler .ParseWorkflowFile ("main.md" )
228+ require .NoError (t , err )
229+
230+ // The top-level github-app should be resolved at the top level
231+ require .NotNil (t , data .TopLevelGitHubApp , "TopLevelGitHubApp should be populated" )
232+
233+ // tools.github should remain disabled — applyDefaultTools removes the key when false.
234+ // After compilation, ParsedTools.GitHub should be nil (no GitHub MCP tool enabled).
235+ assert .Nil (t , data .ParsedTools .GitHub ,
236+ "ParsedTools.GitHub should be nil when tools.github: false — fallback must not re-enable it" )
237+ }
238+
193239// workflow is propagated to the activation job (reactions/status comments).
194240func TestTopLevelGitHubAppImportActivation (t * testing.T ) {
195241 compiler := NewCompilerWithVersion ("1.0.0" )
0 commit comments