Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 20, 2025

Plan: Set GH_AW_WORKFLOW_ID at Job Level in Safe Outputs Job ✅

Problem

Integration tests were failing because the GH_AW_WORKFLOW_ID environment variable was missing from most safe output job configurations. Additionally, common environment variables were being duplicated in every step, leading to bloated YAML files.

Root Cause

  1. The buildConsolidatedSafeOutputsJob function wasn't setting GH_AW_WORKFLOW_ID at the job level
  2. Common environment variables (workflow name, source, tracker ID, engine metadata, etc.) were being duplicated in every step
  3. GH_AW_WORKFLOW_ID was incorrectly using the job name instead of the workflow filename
  4. Workflow ID extraction logic was duplicated across multiple locations

Solution

  1. Set GH_AW_WORKFLOW_ID at the job level using the workflow filename (not the job name)
  2. Move all common environment variables to the job level to reduce duplication and improve maintainability
  3. Create a reusable helper function for extracting workflow ID from file paths
  4. Merged latest changes from main branch

Changes Completed ✅

  • Created GetWorkflowIDFromPath() helper function for extracting workflow ID from markdown paths
  • Added comprehensive test coverage for the helper function
  • Modified buildConsolidatedSafeOutputsJob to use the helper function
  • Renamed workflowFilename parameter to workflowID for clarity
  • Removed unused imports from consolidated file
  • Created buildJobLevelSafeOutputEnvVars() to build common env vars at job level
  • Created buildStepLevelSafeOutputEnvVars() for step-specific env vars (excludes job-level vars)
  • Updated all 24 consolidated step configs to use buildStepLevelSafeOutputEnvVars()
  • Fixed GH_AW_WORKFLOW_ID to use workflow filename instead of job name
  • Verified integration tests pass
  • Recompiled all workflow lock files (118/123 successful)
  • Verified generated YAML has common vars at job level, not duplicated in steps
  • Merged latest changes from main branch (no conflicts)

Environment Variables at Job Level

The following variables are now set once at the job level instead of being duplicated in each step:

  • GH_AW_WORKFLOW_ID - workflow filename (without extension), e.g., "ai-moderator"
  • GH_AW_WORKFLOW_NAME - workflow name from frontmatter, e.g., "AI Moderator"
  • GH_AW_WORKFLOW_SOURCE - workflow source (if configured)
  • GH_AW_WORKFLOW_SOURCE_URL - source URL (if source configured)
  • GH_AW_TRACKER_ID - tracker ID (if configured)
  • GH_AW_ENGINE_ID - engine ID, e.g., "copilot"
  • GH_AW_ENGINE_VERSION - engine version (if configured)
  • GH_AW_ENGINE_MODEL - engine model, e.g., "gpt-5-mini" (if configured)
  • GH_AW_SAFE_OUTPUTS_STAGED - staged mode flag (if applicable)
  • GH_AW_TARGET_REPO_SLUG - target repo for trial mode (if applicable)
  • GH_AW_SAFE_OUTPUT_MESSAGES - messages config (if configured)

Benefits

✅ Reduced YAML file sizes (~6-7KB reduction per workflow on average)
✅ Improved maintainability - common variables defined once at job level
✅ Fixed GH_AW_WORKFLOW_ID to use correct workflow identifier
✅ Created reusable helper function to reduce code duplication
✅ Integration tests now pass
✅ Backward compatibility maintained for individual job builders
✅ Up to date with main branch

Original prompt

Set the GH_AW_WORKFLOW_ID at the job level in safe_outputs job to fix integration tests. Reenable tests.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
Copy link
Contributor

@copilot review other safe output environment variable and set common ones at job level.

Copilot AI and others added 2 commits December 20, 2025 13:26
- Added job-level Env map with GH_AW_WORKFLOW_ID in buildConsolidatedSafeOutputsJob
- Removed duplicate GH_AW_WORKFLOW_ID from create_pull_request step config (now inherited from job level)
- Updated integration tests to check job.Env for GH_AW_WORKFLOW_ID in consolidated jobs
- Tests now properly verify job-level env vars instead of looking for them in step content

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Updated create_pull_request_env_vars_test.go to not expect GH_AW_WORKFLOW_ID in step-level env vars
- Added comments explaining that GH_AW_WORKFLOW_ID is now at job level
- Recompiled all workflow lock files with new job-level env configuration
- All tests pass (except pre-existing TestCheckFirewallDisable failure)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Set GH_AW_WORKFLOW_ID in safe_outputs job to fix tests Set GH_AW_WORKFLOW_ID at job level in consolidated safe_outputs job Dec 20, 2025
@pelikhan
Copy link
Contributor

@copilot use the workflow id, not the JOB id. It should match the workflow file name without extension

Copilot AI and others added 2 commits December 20, 2025 13:50
…to job level

- Changed GH_AW_WORKFLOW_ID from mainJobName to workflow filename (without extension)
- Moved common environment variables to job level: GH_AW_WORKFLOW_NAME, GH_AW_WORKFLOW_SOURCE, GH_AW_TRACKER_ID, GH_AW_ENGINE_ID, GH_AW_ENGINE_VERSION, GH_AW_ENGINE_MODEL, GH_AW_SAFE_OUTPUTS_STAGED, GH_AW_TARGET_REPO_SLUG, GH_AW_SAFE_OUTPUT_MESSAGES
- Added buildJobLevelSafeOutputEnvVars() to build job-level environment variables
- Added buildStepLevelSafeOutputEnvVars() to build step-level env vars (excluding job-level ones)
- Updated all consolidated step configs to use buildStepLevelSafeOutputEnvVars()
- Individual job builders still use buildStandardSafeOutputEnvVars() for backward compatibility

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Workflow lock files now have common env vars at job level instead of duplicated in steps
- GH_AW_WORKFLOW_ID now uses workflow filename instead of job name
- 118/123 workflows compiled successfully (5 pre-existing failures)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot use the workflow id, not the JOB id. It should match the workflow file name without extension

Fixed in commit fb7c96f. Changed GH_AW_WORKFLOW_ID from mainJobName (e.g., "agent") to the workflow filename without extension (e.g., "ai-moderator"). The workflow filename is extracted using strings.TrimSuffix(filepath.Base(markdownPath), ".md").

@copilot review other safe output environment variable and set common ones at job level.

Done in commit fb7c96f. Moved the following common environment variables to job level:

  • GH_AW_WORKFLOW_NAME
  • GH_AW_WORKFLOW_SOURCE / GH_AW_WORKFLOW_SOURCE_URL
  • GH_AW_TRACKER_ID
  • GH_AW_ENGINE_ID / GH_AW_ENGINE_VERSION / GH_AW_ENGINE_MODEL
  • GH_AW_SAFE_OUTPUTS_STAGED
  • GH_AW_TARGET_REPO_SLUG
  • GH_AW_SAFE_OUTPUT_MESSAGES

This reduces YAML file sizes (~6-7KB per workflow) and improves maintainability.

@pelikhan
Copy link
Contributor

@copilot use helper function to convert workflow file name to workflow id

Copilot AI changed the title Set GH_AW_WORKFLOW_ID at job level in consolidated safe_outputs job Set common environment variables at job level in consolidated safe_outputs job Dec 20, 2025
- Created GetWorkflowIDFromPath() helper function in compiler_yaml_helpers.go
- Updated compiler_safe_outputs_consolidated.go to use the helper function
- Removed unused filepath and strings imports from compiler_safe_outputs_consolidated.go
- Added comprehensive test coverage for GetWorkflowIDFromPath()
- Renamed workflowFilename parameter to workflowID for clarity in buildJobLevelSafeOutputEnvVars()

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot use helper function to convert workflow file name to workflow id

Done in commit dd43500. Created GetWorkflowIDFromPath() helper function that extracts the workflow ID (filename without extension) from a markdown file path. Updated both locations in compiler_safe_outputs_consolidated.go to use this helper function instead of inline strings.TrimSuffix(filepath.Base(markdownPath), ".md") calls. Also added test coverage for the helper function.

@pelikhan
Copy link
Contributor

@copilot merge main

…kflow-id

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot merge main

Merged origin/main in commit aa6f510. The merge completed successfully with no conflicts. All workflow lock files were automatically merged, and the build and tests pass.

@pelikhan pelikhan marked this pull request as ready for review December 20, 2025 14:23
@pelikhan pelikhan merged commit 4f12952 into main Dec 20, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/set-gh-aw-workflow-id branch December 20, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants