< Previous - Home - Next >
With our existing repository and newly-created Azure App Service, we have laid the foundation for our application. Now, we must connect our source code and its destination. The first step in this journey is called Continuous Integration (CI).
Continous 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 Core
workflow from the GitHub Actions marketplace. In your repo, click on Actions in the top menu > New Workflow (button) > scroll down to the 'Continuous integration workflows' section and setup the '.NET Core' action. -
Review the layout of the workflow. There is a single job (named 'build') with multiple steps (restore, build, test).
-
In your workflow, under the "Setup .NET Core" step, change the .NET version to
2.2
to match the version defined by the application. -
Configure path filters to only trigger this workflow for changes in the
/Application
folder. -
Configure the workflow to trigger on pushes and pull requests.
-
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 if you find one that might 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.
< Previous - Home - Next >