CI Workflow
This week I worked on adding a CI workflow to my project through Github actions. The set up was easy:
- I selected a new workflow from the "Actions" section in my repo:
- Searched for and selected the .NET workflow:
- I edited the template YAML file to work with my project files:
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore ./Text2StaticHtml/Text2StaticHtml.sln
- name: Build
run: dotnet build ./Text2StaticHtml/Text2StaticHtml.sln --no-restore
- name: Test
run: dotnet test ./Text2StaticHtml/Text2StaticHtmlNunitTest/Text2StaticHtmlNunitTest.csproj --no-build --verbosity normal
- Committed the YAML file to my repo.
Testing CI Workflow
After adding the CI workflow, I added new test cases for my project to make sure that the workflow got triggered on push and pull request. Then, I made a faulty logic change to intentionally fail a test during the workflow and fixed the faulty logic after I saw that the CI action failed as a result of the faulty logic.
So, after I was satisfied that the workflow worked, I merged the changes.
Adding To a Friend's Project
I also added a new test case to my friend's project to make sure that his CI workflow worked as well. Since, his project is written in Python he is using Pytest as a testing framework. Because his testing setup is similar to mine, adding a new test case was very simple. I implemented a new test case to check for non-existent file inputs after I asked my friend if there was a specific test case that he wanted me to add to improve his test coverage. The PR for the changes I made can be found here.
What I Learned
I learned how to setup a CI workflow through Github actions. I can see why a CI workflow is so important, it allows for the automatic building and testing of the project whenever changes are made. I will definitely add CI workflows to my future projects to make my life easier specially with automatic testing.
Top comments (0)