Monday 31 August 2020

Continuous Integration test & build

 In our previous post we created a simple YAML file that 

Trigger: when either our dev or prod branch was pushed to the repo

Pool: Specify the build environment, below we use Microsoft, but you have options.

variables: we specify variables with names, so below when we use '$(BuildConfiguration)' its replaces with 'Release'

next come our steps, they are made up of tasks each tasks does something hopefully valuable in our deployment, lets now direct the tasks that make up our first and only step

however these steps don't really work for us so just delete them all as a matter of fact get rid of the solution and buildPlatform variables, this is because otb this yml file is optimized for Visual Studio Senior

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:




So when done you should have something like the above, first lets add a section to test our code

# Execute xunit tests
  displayName'xUnit unit tests'
    arguments'--configuration $(buildConfiguration)'

now lets add a failing test to any of your unit test files just to see what happens

        public void TestToFail() => Assert.True(false);

next save and push your code, and check out the pipeline

now our pipline failed but click the published test run and you'll see something like the following 

which is a pretty cool dashboard.

Now lets remove that failing test and add a task to build our project

# Build dotnet core project
  displayName'dotnet build Tic tac toe : $(buildConfiguration)'

if we inspect the results we can see our two tasks executed.

 now that we have tested and built our project where do we deploy it? well lets tackle that in our next post.