I have my PR pipeline with the following stages, one being dependent on the previous one:
Changed: basically determines what services have changed so it ignores testing and buildings ones that haven't.UnitTesting: installs services into agent pool and runs the unit tests if the services have changes to them.BuildAndPush: builds and pushes thetest-<version>image to ACR if unit tests are passing.IntegrationTesting: honestly haven't figured this out yet, but it should pull all the images and deploy them somehow.SeleniumTesting: same as 4.
Anyway, I had UnitTesting before BuildAndPush because I figured it was the quickest way to determine if a build is failing by cutting out the the time of building the image.
It is quicker:
UnitTestingone service takes about 1.5 minutes. The bulk of that isnpm installandnpm build. The tests themselves are only about 10-15 seconds.BuildAndPushone service takes about 2.25 minutes, but that doesn't including the testing portion.
That being said I feel like the UnitTesting stage adds an additional 1.25 minutes per service that really isn't necessary: just BuildAndPush and unit test the image would actually be faster overall for the pipeline. The developer would know if the build is failing still well under 5 minutes.
So that is what I can't figure out:
How do you run unit tests in a Docker image in an Azure Pipeline?