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).
In PR's CIs, we have seen tests not belonging to the changed extension are run.
This is because we use
azure-cli-extensions/azure-pipelines.yml
Line 118 in b93f528
which is then used in
git diff:azure-cli-extensions/scripts/ci/test_source.py
Line 39 in dacf087
Using
SourceCommitIdis wrong, because this is not the commit after merging withmain. Changes that are onmainbut not onSourceCommitIdwill be identified bygit diff, resulting in tests for these changes being run.Instead,
HEADis the commit of mergingSourceCommitIdwith target branchmain.On the other hand, main repo https://github.com/Azure/azure-cli uses
HEADforgit diff, so doesn't have this problem:https://github.com/Azure/azure-cli/blob/a130dfe12ba3393a4a48afaf833ce0aa4a76c559/.azure-pipelines/templates/automation_test.yml#L46
BTW,
System.PullRequest.SourceCommitIdis not documented (https://github.com/MicrosoftDocs/azure-devops-docs/issues/4588).