< Previous Challenge - Home - Next Challenge >
With our Azure resources created we have laid the foundations resources for our application. Now, we must connect our source code and its destination. The first step in this journey is called Continuous Integration (CI).
Continuous integration is the process of merging local code changes into source control and may include steps to automatically build and/or test the code. When done effectively, Continuous Integration allows developers to rapidly iterate and collaborate, and it helps ensure that newly added code does not break the current application.
Review the following articles:
In this challenge, you will build and test the .NET Core application.
-
Create a new
.NET
workflow.NOTE: To get a new scaffold workflow, in your repo click on Actions in the top menu > New Workflow (button) > scroll down to the 'Continuous integration workflows' section and select the configure button on the '.NET' example.
-
Review the layout of the workflow. There is a single job (named 'build') with multiple steps (restore, build, test).
NOTE: There are some new events for the workflow we haven't used before for 'push' and 'pull_request'.
-
In your workflow, under the "Setup .NET Core" step, check the .NET version is
6.0.x
to match the version defined by the application. -
Ensure the workflow is configured to trigger on both pushes and pull requests.
-
Configure both these triggers with path filters to only trigger this workflow for changes in the
/Application
folder. -
Update the predefined steps used to build the .NET Core application
NOTE: For each step below, you will need to update each command to pass the relative path to the
.csproj
as an argument):restore
- will get all the dependencies. Update with an argument to the application csproj file.build
- will actually compile our code. Update with an argument to the application csproj file.test
- will execute all our unit tests. Update with an argument to the unit test csproj file.
-
Test the workflow by making a small change to the application code (i.e., add a comment). Commit, push and ensure the workflow completes successfully.
At this point, any changes pushed to the /Application
folder automatically triggers the workflow...and that is Continuous Integration!
- Any changes pushed to the
/Application
folder automatically triggers the workflow - .NET Core restore, build and test steps completes successfully
- Introduction to GitHub Actions
- .NET Core Action to build and test
- Understanding workflow path filters
- dotnet commands
- GitHub Actions for Azure
- If you are having trouble finding a starting point, try clicking over to the 'Actions' tab of your GitHub repository.
- Take advantage of the prebuilt workflow templates often will save you a ton of work!
- In this challenge, if the workflow fails, an email is set to the repo owner. Sometimes, you may want to log or create a GitHub issue when the workflow fails.
- Add a step to your workflow to create a GitHub issue when there is a failure.