Skip to content

Continuous Integration with GitHub Actions

salma-s edited this page Mar 28, 2020 · 6 revisions

Due to the agile approach and feature-branch-styled GitHub Conventions chosen for the Wedium project, the team wants to ensure features can be automatically tested so no breaking changes are inserted into master.

What Artifacts Should be Tested

The following items have been identified as crucial to test to ensure that existing code does not break:

  • All Wedium API NUnit tests (Due to .NET's inversion of control for API applications, changes to Startup.cs may result in breaking existing code. Furthermore, changes in models are very likely to break existing code.)

When Should Artifacts be Tested

The following have been identified as crucial times to execute tests for, to ensure that existing code does not break:

  • On pull request into master (This is the easiest time to test code to eliminate chances of breaking changes being introduced into the master branch).
  • On push into master (This ensures GitHub's automatic merger (used for pull requests) does not fail and introduce a breaking change. If the tests fail then the pull request that introduced the change will be rolled back).

GitHub Actions

The testing is completed through the use of the GitHub Actions which have been established (defined in ./.github/workflows).

Why Use GitHub Actions

GitHub Actions was chosen to complete the testing due to the following reasons:

  • It is integrated into GitHub and does not require third party services and the accounts associated with them
  • There are a number of base templates to base Wedium's unique action off. As a result, setting the action up to complete the test requirements outlined above is quick and easy to implement.
  • A few of the group members have experience writing GitHub Actions (as part of another course)
  • It can be configured easily to make use of GitHub Secrets (detailed below)).

GitHub Secrets Integration

As Wedium's database is live and the repository inevitably will be made public upon completion, it is important to not include the connection string in any file (or in any commit) to prevent foreign users gaining access to sensitive information. GitHub Secrets have to be utilised to provide the connection string to GitHub Actions to allow all unit tests to connect to the database and complete successfully.

Ultimately, GitHub Secrets allows the unit tests to be run easily when executed by GitHub Actions (by getting the connection string from the test machine's environment variables) and developers (by temporarily inserting the connection string into appsettings.json).

Clone this wiki locally