Skip to content

Tests not belonging to the changed extension are run #4565

@jiasli

Description

@jiasli

In PR's CIs, we have seen tests not belonging to the changed extension are run.

This is because we use

ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId)

which is then used in git diff:

cmd_tpl = 'git --no-pager diff --name-only origin/{commit_start} {commit_end} -- {code_dir}'

Using SourceCommitId is wrong, because this is not the commit after merging with main. Changes that are on main but not on SourceCommitId will be identified by git diff, resulting in tests for these changes being run.

Instead, HEAD is the commit of merging SourceCommitId with target branch main.

On the other hand, main repo https://github.com/Azure/azure-cli uses HEAD for git diff, so doesn't have this problem:

https://github.com/Azure/azure-cli/blob/a130dfe12ba3393a4a48afaf833ce0aa4a76c559/.azure-pipelines/templates/automation_test.yml#L46

azdev test --no-exitfirst --repo=./ --src=HEAD --tgt=origin/$(System.PullRequest.TargetBranch) --cli-ci --profile ${{ parameters.profile }} --verbose --series

BTW, System.PullRequest.SourceCommitId is not documented (https://github.com/MicrosoftDocs/azure-devops-docs/issues/4588).

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions