Skip to content

fix: detect .zip bundles in archive mode (apm pack default changed to zip)#49

Closed
danielmeppiel wants to merge 1 commit into
mainfrom
danielmeppiel-fix-zip-bundle-detection
Closed

fix: detect .zip bundles in archive mode (apm pack default changed to zip)#49
danielmeppiel wants to merge 1 commit into
mainfrom
danielmeppiel-fix-zip-bundle-detection

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Why

The APM CLI intentionally and permanently flipped its apm pack --archive default output format from .tar.gz to .zip (src/apm_cli/bundle/packer.py: archive_format: str = "zip", with --archive-format tar.gz as the opt-out). This action's bundle detection still only matched .tar.gz, so packing with a current CLI fails with apm pack produced no bundle even though the CLI did produce a valid .zip bundle.

Empirical evidence

Failing job: microsoft/apm GH-AW Compatibility (build-release.ymlgh-aw-compat) on tag v0.21.0 — run 27832510355, job 82376879301.

[*] Packed 8 file(s) -> /tmp/gh-aw-compat-test/build/inline-workflow-1.0.0.zip
[i] Note: --archive now produces .zip by default. Use --archive-format tar.gz to ...
##[error]APM action failed: apm pack produced no bundle.

The fix belongs here in apm-action, not the CLI — the CLI default is deliberate.

Root cause

src/bundler.tsfindBundleOrNull(buildDir, archive). The archive branch filtered e.endsWith('.tar.gz') only, so a .zip emit produced an empty list → null → caller throws "apm pack produced no bundle."

The fix (one line of detection)

const archives = entries.filter(e => e.endsWith('.zip') || e.endsWith('.tar.gz')).sort();
  • Keeps the single-candidate guarantee; the multiple-archive error message is now format-agnostic: "Multiple archive bundles found in build directory after apm pack: ...".
  • Directory-mode behavior unchanged. tar.gz support intact (still valid via --archive-format tar.gz; bundles-file/restore paths in multibundle.ts still use .tar.gz).
  • installer.ts (apm-<suffix>.tar.gz binary download) and release.ts matrix-pack tar.gz logic untouched.

Doc-string corrections (action.yml)

  • pack input: now states archive: true follows the CLI default and produces .zip, with .tar.gz still supported via the CLI opt-out.
  • archive input: reworded from "Produce .tar.gz instead of directory" to reflect the .zip default.

Tests

Extended src/__tests__/bundler.test.ts (runPackStep suite):

  • detects a .zip bundle in archive mode,
  • still detects a .tar.gz bundle in archive mode,
  • still throws on multiple archive candidates (now with the format-agnostic message).

Build + verify

This is a compiled action — dist/ was rebuilt and committed.

  • npm ci
  • npm run typecheck
  • npm run lint
  • npm run build (regenerates dist/index.js) ✅ — dist/index.js committed
  • dist-drift check (CI's git diff --name-only dist/) ✅ — no drift after commit
  • npm test ✅ — 184 passed, 5 suites

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

… zip)

The APM CLI flipped its `apm pack --archive` default output from .tar.gz to
.zip. The action's bundle detection only matched .tar.gz, so packing with a
current CLI failed with "apm pack produced no bundle" even though a .zip
bundle was produced.

findBundleOrNull now detects both .zip and .tar.gz in archive mode, with a
format-agnostic multiple-archive error message. tar.gz remains fully
supported (CLI opt-out via --archive-format tar.gz; bundles-file/restore
paths unchanged). Doc strings in action.yml corrected to reflect the new
.zip default. dist/ rebuilt.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 25, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the action’s bundle discovery logic to remain compatible with the APM CLI’s apm pack --archive default changing from producing .tar.gz to producing .zip, and updates tests/docs accordingly.

Changes:

  • Update findBundleOrNull(..., archive=true) to detect both .zip and .tar.gz outputs and make the “multiple archive” error message format-agnostic.
  • Extend runPackStep tests to cover .zip detection, keep .tar.gz coverage, and update the multi-archive assertion message.
  • Update action.yml input descriptions to reflect the CLI’s new default, and rebuild dist/index.js.
Show a summary per file
File Description
src/bundler.ts Detect .zip and .tar.gz bundle artifacts in archive mode; improve ambiguity error message.
src/tests/bundler.test.ts Add/adjust tests to validate .zip detection and updated multi-archive error messaging.
dist/index.js Rebuilt compiled action output reflecting the source changes.
action.yml Update input documentation to reflect .zip archive default behavior.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/4 changed files
  • Comments generated: 2

Comment thread action.yml
Comment on lines 37 to 40
pack:
description: 'Pack a bundle after install. Format is controlled by `bundle-format` (default: apm). Produces .tar.gz by default.'
description: 'Pack a bundle after install. Format is controlled by `bundle-format` (default: apm). With `archive: true`, follows the apm CLI default and produces a .zip; .tar.gz remains supported via the CLI opt-out.'
required: false
default: 'false'
Comment thread action.yml
Comment on lines 72 to 75
archive:
description: 'Produce .tar.gz instead of directory (used with pack: true)'
description: 'Produce an archive bundle instead of a directory (used with pack: true). Follows the apm CLI default, which now produces .zip; .tar.gz is still supported.'
required: false
default: 'true'
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #47, which predates this PR and fixes the same root cause (apm pack --archive default flipped to .zip) more completely.

#47 fixes the .zip break across all three affected surfaces; this PR only addressed findBundleOrNull (the pack-detection path / the failing gh-aw-compat job). The two surfaces left unfixed here are covered by #47:

  • detectBundleFormat — restore uses tar tzf, which can't read a .zip on GNU tar (Linux runners), so restoring a .zip bundle would still throw.
  • parseBundleListFile (multibundle.ts) — a bundles-file entry ending in .zip is hard-rejected.

Merging #47 instead.

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