Skip to content

feat(azldev): enable --from-spec to use fmf from local rendered spec (needs skip-file-filter) - #347

Merged
Nan Liu (liunan-ms) merged 2 commits into
microsoft:mainfrom
bhagyapathak:bhagya/enable-skip-file-filter
Sep 16, 2026
Merged

Nan Liu (liunan-ms) merged 2 commits into
microsoft:mainfrom
bhagyapathak:bhagya/enable-skip-file-filter

Conversation

@bhagyapathak

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI lite review requested due to automatic review settings September 9, 2026 08:37

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.

🟡 Changes recommended

The new --from-spec flow needs follow-up fixes/updates (git prerequisite mismatch, missing unit tests, and CLI/docs regeneration) before it’s reliable and fully integrated.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new local-development mode for azldev component test to run TMT plans directly from a component’s locally rendered spec tree (fmf) via a new --from-spec flag, instead of cloning the catalog test metadata source.

Changes:

  • Add --from-spec flag and plumb it through test execution settings.
  • Switch the TMT run directory to either the cloned repo (default) or the rendered spec directory (--from-spec).
  • Add validation (resolveSpecRunDir) to ensure the rendered spec directory contains an fmf root (.fmf/version).
File summaries
File Description
internal/app/azldev/cmds/component/test.go Adds --from-spec support, routes TMT execution to rendered spec dirs, and validates presence of fmf metadata.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/app/azldev/cmds/component/test.go
Comment thread internal/app/azldev/cmds/component/test.go
Comment thread internal/app/azldev/cmds/component/test.go
@bhagyapathak
bhagyapathak force-pushed the bhagya/enable-skip-file-filter branch from 5671da0 to a4866aa Compare September 9, 2026 08:42
Copilot AI review requested due to automatic review settings September 9, 2026 10:02
@bhagyapathak
bhagyapathak force-pushed the bhagya/enable-skip-file-filter branch from a4866aa to 15c15a9 Compare September 9, 2026 10:02

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.

🟡 Changes recommended

The new --from-spec help/comment text hard-codes an incorrect rendered-spec base path (“specs/...”) instead of referencing the configured rendered-specs-dir layout, which is user-facing and misleading.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

internal/app/azldev/cmds/component/test.go:537

  • The comment for [resolveSpecRunDir] says it runs from 'specs///', but the rendered spec directory is derived from the project 'rendered-specs-dir' setting (e.g. 'SPECS/c/curl'). Updating this comment avoids baking in an incorrect directory name.
// resolveSpecRunDir validates that the component's rendered spec directory
// exists and carries an fmf root, returning it as the tmt run directory. It
// backs the --from-spec flow, which runs a plan straight from
// specs/<x>/<name>/ instead of cloning the catalog 'source'. tmt writes its run
// artifacts under a separate --workdir-root, so the rendered tree is only read.
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread internal/app/azldev/cmds/component/test.go
Copilot AI review requested due to automatic review settings September 9, 2026 10:12
@bhagyapathak
bhagyapathak force-pushed the bhagya/enable-skip-file-filter branch from 15c15a9 to 9d33ed3 Compare September 9, 2026 10:12

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.

🟡 Changes recommended

The new --from-spec validation and flow can be made more correct and efficient with small fixes (FMF file-type validation and earlier failure before costly venv/pip work).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread internal/app/azldev/cmds/component/test.go
Comment thread internal/app/azldev/cmds/component/test.go
Copilot AI review requested due to automatic review settings September 9, 2026 10:23
@bhagyapathak
bhagyapathak force-pushed the bhagya/enable-skip-file-filter branch from 9d33ed3 to 12246a1 Compare September 9, 2026 10:23

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.

🟡 Changes recommended

The updated help text has an internal inconsistency about git prerequisites when using --from-spec, and should be corrected to avoid misleading users.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread internal/app/azldev/cmds/component/test.go
…ec dir

Add a --from-spec flag to 'azldev component test' that runs the mapped tmt plan directly from the component's rendered spec directory (specs/<x>/<name>/) instead of cloning the catalog source@ref. Requires render.skip-file-filter = true and a prior 'azldev component render' so the loose fmf tree is preserved. Local inner-loop convenience; cloud/TEE runs still clone.
Copilot AI review requested due to automatic review settings September 9, 2026 10:34
@bhagyapathak
bhagyapathak force-pushed the bhagya/enable-skip-file-filter branch from 12246a1 to 0b70a10 Compare September 9, 2026 10:34

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.

🟢 Approval recommended

The change is localized, preserves the default behavior, adds explicit validation/error messaging for the new path, and includes targeted unit tests for the new functionality.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@bhagyapathak

Copy link
Copy Markdown
Contributor Author

Attaching log files for util-linux tmt test runs using spec fmf/plans

azldev component test util-linux
--from-spec
--image-path base/out/images/vm-base/azl4-vm-base.x86_64-0.1.qcow2
--rpm base/out/rpms/rpm-base/util-linux-2.41.3-14.azl4.x86_64.rpm
--rpm base/out/rpms/rpm-base/util-linux-core-2.41.3-14.azl4.x86_64.rpm

tmt-util-linux-spec-fmf.txt

@liunan-ms Nan Liu (liunan-ms) 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.

LGTM, question: do you consider removing the git clone flow after switching to using rendered files?

@liunan-ms Nan Liu (liunan-ms) added the state: needs review PRs that need review label Sep 15, 2026
Copilot AI review requested due to automatic review settings September 16, 2026 20:57

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.

🟡 Changes recommended

The stale-render marker check must be fixed before approval, along with the requested documentation and test updates.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (3)

internal/app/azldev/cmds/component/test.go:559

  • component render writes RENDER_FAILED when the rendered tree is stale or invalid, and other consumers skip directories carrying this marker. This path only checks .fmf/version, so a failed render that leaves old output (for example, an external output rendered without overwrite) can make --from-spec execute stale specs; check the marker before accepting the directory and require a successful re-render.
func resolveSpecRunDir(env *azldev.Env, specDir string) (string, error) {
	if specDir == "" {
		return "", errors.New(
			"'--from-spec' requires a rendered spec directory; ensure 'project.rendered-specs-dir' is set")
	}

	fmfVersion := filepath.Join(specDir, ".fmf", "version")

internal/app/azldev/cmds/component/test.go:200

  • The new execution mode is documented in the generated CLI page, but docs/user/reference/config/tests.md:53-57 still says component TMT execution clones the configured source unconditionally. Please update that user-facing reference to describe --from-spec and its render.skip-file-filter/prior-render prerequisites so the new behavior is not contradicted.
	cmd.Flags().BoolVar(&options.FromSpec, "from-spec", false,
		"Run the plan from the component's rendered spec directory (under the configured "+
			"'project.rendered-specs-dir', e.g. 'SPECS/c/curl') instead of cloning the catalog "+
			"'source'. Requires 'render.skip-file-filter = true' and a prior "+
			"'azldev component render'. Local inner-loop convenience; not used by cloud (TEE) runs.")

internal/app/azldev/cmds/component/test.go:200

  • This adds a new component-test workflow, but the generated agent guidance still only recommends azldev adv mock shell in both build-component templates and never mentions azldev component test/--from-spec. Please update the templates and regenerate the emitted skill output so agents following the repository's documented workflow can discover this feature.
	cmd.Flags().BoolVar(&options.FromSpec, "from-spec", false,
		"Run the plan from the component's rendered spec directory (under the configured "+
			"'project.rendered-specs-dir', e.g. 'SPECS/c/curl') instead of cloning the catalog "+
			"'source'. Requires 'render.skip-file-filter = true' and a prior "+
			"'azldev component render'. Local inner-loop convenience; not used by cloud (TEE) runs.")
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

### Options

```
--from-spec Run the plan from the component's rendered spec directory (under the configured 'project.rendered-specs-dir', e.g. 'SPECS/c/curl') instead of cloning the catalog 'source'. Requires 'render.skip-file-filter = true' and a prior 'azldev component render'. Local inner-loop convenience; not used by cloud (TEE) runs.
Comment on lines +354 to +368
require.NoError(t, runOneTMTTest(testEnv.Env, test, settings))

ranTMT := false

for _, args := range testEnv.CommandsExecuted {
require.NotEmpty(t, args)
assert.NotEqual(t, "git", filepath.Base(args[0]),
"--from-spec must not invoke git, but ran: %v", args)

if filepath.Base(args[0]) == tmtProgram {
ranTMT = true
}
}

assert.True(t, ranTMT, "expected the tmt run command to be invoked from the spec dir")
@liunan-ms
Nan Liu (liunan-ms) merged commit aea6af8 into microsoft:main Sep 16, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: needs review PRs that need review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants