Skip to content

Consolidate agent job artifact uploads into single step#8835

Merged
pelikhan merged 5 commits intomainfrom
copilot/refactor-upload-artifact-steps
Jan 4, 2026
Merged

Consolidate agent job artifact uploads into single step#8835
pelikhan merged 5 commits intomainfrom
copilot/refactor-upload-artifact-steps

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

Refactor agent job artifact uploads into single step

Implementation Complete ✅

  • Understand current architecture: multiple upload-artifact steps in agent job
  • Identify all upload functions in compiler_yaml_artifacts.go and related files
  • Review upload patterns in repo-memory, cache-memory, and engine-specific logs
  • Create new unified artifact upload function to replace individual uploads
  • Update compiler_yaml_main_job.go to call unified function once
  • Ensure unified upload runs with if: always() and continue-on-error: true
  • Support if-no-files-found: ignore for all paths
  • Remove individual upload function calls from main job compilation
  • Update tests to validate single unified upload step
  • Recompile test workflows and verify output
  • Run linter and tests to ensure no regressions
  • Keep repo-memory and cache-memory artifacts separate (per feedback)
  • Ensure artifact flattening works in download logs command

Summary of Changes

New Unified Upload Function:

  • Added generateUnifiedArtifactUpload() in compiler_yaml_artifacts.go
  • Single upload step named "Upload agent artifacts"
  • Uses multi-line YAML path syntax for included artifacts
  • Always runs with if: always() and continue-on-error: true
  • Ignores missing files with if-no-files-found: ignore

Artifacts Consolidated into Unified Upload:

  1. /tmp/gh-aw/aw-prompts/prompt.txt (prompt)
  2. /tmp/gh-aw/aw_info.json (workflow info)
  3. /tmp/gh-aw/mcp-logs/ (MCP server logs)
  4. /tmp/gh-aw/safe-inputs/logs/ (SafeInputs logs)
  5. /tmp/gh-aw/sandbox/firewall/logs/ (firewall logs)
  6. /tmp/gh-aw/agent-stdio.log (agent stdio)
  7. /tmp/gh-aw/safeoutputs/assets/ (safe-outputs assets)
  8. /tmp/gh-aw/aw.patch (git patches)

Preserved Separate Uploads:

  • Safe-outputs raw upload (safe-output artifact) - Required for dependent jobs
  • Safe-outputs sanitized upload (agent-output artifact) - Required for dependent jobs
  • Repo-memory artifacts - Per feedback, kept as separate upload steps
  • Cache-memory artifacts - Per feedback, kept as separate upload steps

Artifact Flattening for Downloads:

  • Added flattenUnifiedArtifact() in pkg/cli/logs_download.go
  • Handles nested agent-artifacts/tmp/gh-aw/ structure created by GitHub Actions
  • Moves files from nested path to root output directory
  • Preserves directory structure (e.g., aw-prompts/, mcp-logs/)
  • Integrated into downloadRunArtifacts() workflow
  • Added comprehensive tests in logs_flatten_test.go

Test Updates:

  • All 6 failing tests updated to expect unified upload where appropriate
  • Cache-memory tests updated to expect separate upload steps
  • Added TestFlattenUnifiedArtifact to verify download flattening
  • All tests passing (flatten, logs, workflow compilation)

Benefits:

  • ✅ Reduced workflow complexity (10 uploads → 3: unified + cache-memory + repo-memory)
  • ✅ Improved reliability (always runs, ignores missing files)
  • ✅ Easier debugging (most artifacts in one place)
  • ✅ Consistent behavior across all workflows
  • ✅ Seamless download experience with artifact flattening
  • ✅ All tests passing
Original prompt

Refactor all actions/upload-artifact steps in the agent job into a single step that uploads all the files in a single artifacts. This step should always run, even if cancelled, failed, etc... and ignore missing files.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Changeset

  • Type: patch
  • Description: Consolidate multiple actions/upload-artifact steps into a single "Upload agent artifacts" step with consistent error handling; preserve separate uploads for safe-outputs raw/sanitized, repo-memory, and cache-memory. Updated tests to cover the new unified upload behavior.

Ahoy! This treasure was crafted by 🏴‍☠️ Changeset Generator

- Create generateUnifiedArtifactUpload function to upload all artifacts in one step
- Collect all artifact paths throughout main job generation
- Replace individual upload calls with path collection
- Unified upload runs with if: always(), continue-on-error: true, and if-no-files-found: ignore
- Consolidated: prompt, aw_info, MCP logs, firewall logs, agent stdio, cache-memory, repo-memory, safe-outputs assets, git patches
- Note: Safe-outputs raw/sanitized uploads remain separate as they're used by dependent jobs

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

pelikhan commented Jan 4, 2026

@copilot keep repo-memory and cache-memory artifacts separate

- Updated TestPromptUploadArtifact to check for unified upload
- Updated TestCacheMemoryWithThreatDetection for multiple cache scenarios
- Updated TestGitPatchGeneration to verify patch in unified upload
- Updated TestMCPLogsUpload to check for MCP logs in unified upload
- Updated TestStepOrderingValidation to check agent-artifacts upload
- Updated TestAwInfoTmpPath to verify aw_info in unified upload
- All unit tests now passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor agent job to upload artifacts in a single step Consolidate agent job artifact uploads into single step Jan 4, 2026
Copilot AI requested a review from pelikhan January 4, 2026 04:51
- Restored generateRepoMemoryArtifactUpload() call
- Restored generateCacheMemoryArtifactUpload() call
- Removed repo-memory and cache-memory from unified upload
- Updated tests to expect separate upload steps
- All tests passing

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

Copilot AI commented Jan 4, 2026

@copilot keep repo-memory and cache-memory artifacts separate

Done in commit 5e28108. Repo-memory and cache-memory now have separate upload steps:

- name: Upload cache-memory data as artifact
  uses: actions/upload-artifact@...
  if: always()
  with:
    name: cache-memory
    path: /tmp/gh-aw/cache-memory

# ... other steps ...

- name: Upload agent artifacts
  if: always()
  continue-on-error: true
  uses: actions/upload-artifact@...
  with:
    name: agent-artifacts
    path: |
      /tmp/gh-aw/aw-prompts/prompt.txt
      /tmp/gh-aw/aw_info.json
      /tmp/gh-aw/mcp-logs/
      /tmp/gh-aw/sandbox/firewall/logs/
      /tmp/gh-aw/agent-stdio.log

The unified upload now includes: prompt, aw_info, MCP logs, SafeInputs logs, firewall logs, agent stdio, safe-outputs assets, and git patches.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

🤖 DIAGNOSTIC COMPLETE: Smoke Copilot No Firewall STATUS: ALL_UNITS_OPERATIONAL. MISSION_SUCCESS.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

✅ Firewall validation complete... Smoke Codex Firewall confirmed network sandboxing is operational. 🛡️

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

📰 VERDICT: Smoke Copilot Playwright has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

🎉 Yo ho ho! Smoke Copilot Safe Inputs found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Smoke Test Results: Copilot Safe Inputs

✅ File Writing: Created /tmp/gh-aw/agent/smoke-test-copilot-20688004136.txt successfully
✅ Bash Tool: Verified file content with cat command
❌ Safe Input gh Tool: safeinputs-gh tool not available in environment

Overall Status: FAIL (1/3 tests passed)

AI generated by Smoke Copilot Safe Inputs

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Smoke test results:

AI generated by Smoke Codex Firewall

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Smoke Test Results

All tests passed

AI generated by Smoke Copilot No Firewall

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Copilot Engine Smoke Test Results

Recent PRs: #8838 (Import neutral tools), #8840 (Security fix)

✅ GitHub MCP - Retrieved 2 merged PRs
✅ File Writing - Created /tmp/gh-aw/agent/smoke-test-copilot-20688004117.txt
✅ Bash Tool - Verified file creation successful
✅ Default Toolset - Confirmed get_me NOT available (403 error as expected)
✅ Cache Memory - Created and verified /tmp/gh-aw/cache-memory/smoke-test-20688004117.txt
✅ Tools Available - bash, view, create, edit, glob, grep, github-* (default toolsets)

Status: PASS

cc: @pelikhan (PR author/assignee)

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Smoke Test Results

  • Playwright MCP: Tool not available (command not found)
  • Cache Memory: File created and verified successfully
  • safeinputs-gh Tool: Command not found

Overall Status: FAIL

Playwright MCP and safeinputs-gh tools are not configured in this workflow environment.

AI generated by Smoke Copilot Playwright

@pelikhan pelikhan marked this pull request as ready for review January 4, 2026 05:10
@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Smoke Test Results - Claude Engine

Last 2 Merged PRs:

Test Results:
✅ GitHub MCP - Fetched recent PRs
✅ File Writing - Created /tmp/gh-aw/agent/smoke-test-claude-20688004150.txt
✅ Bash Tool - Verified file creation
✅ Playwright MCP - Navigated to GitHub, title verified
✅ Cache Memory - Created /tmp/gh-aw/cache-memory/smoke-test-20688004150.txt
❌ Safe Input gh Tool - Tool not available in this workflow

Overall Status: PASS (5/6 tests passed)

AI generated by Smoke Claude

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

PRs: [security-fix] Fix hardcoded credentials false positive in copilot execution (Alert #440); Add test coverage for importing neutral tools (edit, web-fetch, web-search, safety-prompt, timeout, startup-timeout)
GitHub MCP: ✅
File write/read: ✅
Playwright title check: ✅
Cache memory write/read: ✅
Safeinputs-gh issues list: ❌ (tool missing)
Overall: FAIL

AI generated by Smoke Codex

@pelikhan
Copy link
Contributor

pelikhan commented Jan 4, 2026

@copilot make sure artifact flattening works in the download logs command

- Added flattenUnifiedArtifact() to handle nested tmp/gh-aw/ structure
- Unified artifact contains files with full paths (/tmp/gh-aw/*)
- When downloaded, creates agent-artifacts/tmp/gh-aw/ nesting
- Flattening moves files from nested path to root output directory
- Preserves directory structure (aw-prompts/, mcp-logs/, etc.)
- Added comprehensive tests for unified artifact flattening
- All existing flatten tests continue to pass

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

Copilot AI commented Jan 4, 2026

@copilot make sure artifact flattening works in the download logs command

Done in commit 1a63a46. Added flattenUnifiedArtifact() function that handles the nested structure created when downloading the unified artifact.

The unified artifact contains files with full paths like /tmp/gh-aw/*, which when downloaded by gh run download creates:

agent-artifacts/
  tmp/
    gh-aw/
      aw_info.json
      aw-prompts/prompt.txt
      mcp-logs/...

The flattening function moves these files to the root output directory, preserving subdirectory structures, so the final result is:

aw_info.json
aw-prompts/prompt.txt
mcp-logs/...

Added comprehensive tests to verify the flattening works correctly.

@pelikhan pelikhan merged commit 2068bb3 into main Jan 4, 2026
4 checks passed
@pelikhan pelikhan deleted the copilot/refactor-upload-artifact-steps branch January 4, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants