Skip to content

Include test toolkit in cached image when toolkit flags are set#4144

Open
jeffreybulanadi wants to merge 1 commit into
microsoft:mainfrom
jeffreybulanadi:fix/2076-include-test-toolkit-in-image
Open

Include test toolkit in cached image when toolkit flags are set#4144
jeffreybulanadi wants to merge 1 commit into
microsoft:mainfrom
jeffreybulanadi:fix/2076-include-test-toolkit-in-image

Conversation

@jeffreybulanadi

Copy link
Copy Markdown

Summary

When imageName is specified in Run-AlPipeline and any of installTestRunner, installTestFramework, installTestLibraries, or installPerformanceToolkit are set, pass the corresponding includeTest* flags to New-BcContainer so that New-BcImage bakes the test toolkit into the cached image.

Fixes microsoft/AL-Go#2076

Root Cause

In AppHandling/Run-AlPipeline.ps1, the GetBuildContainer function builds $Parameters for the $NewBcContainer scriptblock. The imageName was included in these parameters, but includeTestToolkit, includeTestLibrariesOnly, includeTestFrameworkOnly, and includePerformanceToolkit were not. As a result, New-BcContainer always called New-BcImage with includeTestToolkit=False, regardless of what was requested.

The test toolkit then had to be imported from scratch on every container creation via Import-TestToolkitToBcContainer, adding roughly one minute per pipeline run on self-hosted runners that use cacheImageName.

Fix

Expand the if ($imageName) block to also add toolkit inclusion flags when any toolkit install switch is set. The mapping mirrors the existing logic used in Import-TestToolkitToBcContainer later in the pipeline:

  • includeTestLibrariesOnly = installTestLibraries
  • includeTestFrameworkOnly = !installTestLibraries AND (installTestFramework OR installPerformanceToolkit)
  • includePerformanceToolkit = installPerformanceToolkit

Behavior

  • First build: image is created with the test toolkit baked in.
  • Subsequent builds that reuse the cached image: Import-TestToolkitToBcContainer finds the toolkit already installed and completes quickly, saving approximately one minute per run.
  • Builds without imageName (GitHub-hosted runners): no change.
  • Builds with imageName but no toolkit flags: no change.

Workaround Comparison

The reporter workaround was to override NewBcContainer with a custom script that adds these parameters manually. This fix makes that workaround unnecessary by handling it in the pipeline itself.

When imageName is specified in Run-AlPipeline and any of installTestRunner,
installTestFramework, installTestLibraries, or installPerformanceToolkit are
set, pass the corresponding includeTest* flags to New-BcContainer so that
New-BcImage bakes the test toolkit into the cached image.

Previously these flags were absent from the container creation parameters,
so New-BcImage always created images with includeTestToolkit=False. The
toolkit then had to be imported from scratch into every new container, adding
roughly one minute per pipeline run on self-hosted runners that use
cacheImageName.

With this change, the first build creates the image with the toolkit included;
subsequent builds that reuse the cached image find the toolkit already present
and the Import-TestToolkitToBcContainer step completes quickly as a no-op.

The include logic mirrors the existing mapping used in the
Import-TestToolkitToBcContainer call further down in the pipeline:
  includeTestLibrariesOnly  = installTestLibraries
  includeTestFrameworkOnly  = !installTestLibraries AND (installTestFramework OR installPerformanceToolkit)
  includePerformanceToolkit = installPerformanceToolkit

Fixes microsoft/AL-Go#2076

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jeffreybulanadi jeffreybulanadi requested a review from a team as a code owner April 30, 2026 05:07
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.

[Bug]: New-BCImage triggered by pipeline does not add test toolkit to installation

1 participant