patterngitMinor
VSTS Azure for DevOps: Unit test checking mechanism on pull request
Viewed 0 times
pullrequestcheckingazuremechanismfortestvstsdevopsunit
Problem
Is there a way in VSTS Azure for DevOps to implement unit test checking mechanism on pull request.
The condition is to only allow commits that change something in the unittest folder for example.
Notes:
-
we are using GoCD as a CI/CD system so it's external building.
-
Git is internal hosted within VSTS.
The condition is to only allow commits that change something in the unittest folder for example.
Notes:
-
we are using GoCD as a CI/CD system so it's external building.
-
Git is internal hosted within VSTS.
Solution
If you have the option, Github offers Actions which allow you to run workflows on different events - one of them being push.
If Github is not an option, I would recommend creating a build where deployment of the artifacts only happens if the build is done on master.
On your feature branches, on checkin, a build will happen which will pull the latest code, compile, and then run unit tests, security scanning, and code coverage (if applicable). Since this is a feature branch, the build ends there.
If it is on master, it then performs the steps to package/deploy the artifacts.
In Branches > Master > Branch Policies (in the ellipses menu), add a Build Validation.
I recommend marking it required.
If you aren't worried about merge conflicts causing a rebuild, you can make it expire immediately upon master changing (requiring a rebuild, which will fail on merge conflicts).
If you are a large team where you might frequently step on one another, you can make it never expire and leave it up to the developer to fix manually before they are able to merge.
If Github is not an option, I would recommend creating a build where deployment of the artifacts only happens if the build is done on master.
On your feature branches, on checkin, a build will happen which will pull the latest code, compile, and then run unit tests, security scanning, and code coverage (if applicable). Since this is a feature branch, the build ends there.
If it is on master, it then performs the steps to package/deploy the artifacts.
In Branches > Master > Branch Policies (in the ellipses menu), add a Build Validation.
I recommend marking it required.
If you aren't worried about merge conflicts causing a rebuild, you can make it expire immediately upon master changing (requiring a rebuild, which will fail on merge conflicts).
If you are a large team where you might frequently step on one another, you can make it never expire and leave it up to the developer to fix manually before they are able to merge.
Context
StackExchange DevOps Q#5923, answer score: 1
Revisions (0)
No revisions yet.