DEV Community

Qiwen Yu
Qiwen Yu

Posted on

Add Continuous Integration to GitHub Repo

For this part of the work, CI (Continuous Integration) pipeline was applied in my GitHub opensource project, TextHTMLPress.

In general, CI is a method whereby we build and run our tests (i.e., integrate everything in our project) automatically whenever anything is pushed to the repo, or a new pull request is made. In this way, we can implement the idea that no developer is ever allowed to break the main branch.

For GitHub projects, GitHub provides its own CI service called GitHub Actions. Actions allow us to automate workflows in response to events in a GitHub repo (e.g., merging to main, creating a pull request, etc). In this repo, I created a GitHub Actions Workflow that runs my tests and can be triggered on any push to the default branch (e.g., main), and for any pull request to the default branch. To add an GitHub Actions for python project, the manual is here, which is to add a .yml workflow file to the .github/workflows directory of your repository. My workflow file can be found here.

The CI process integrated to my project, It will test code in ubuntu system with Python version 3.6, 3.7, 3.8 and 3.9. It can install dependencies, lint with Flake8, and run tests with pytest.

After I set up my CI, I submitted a PR to test my CI and it passed all tests automatically. Similarly, I submitted another PR to test the CI of another opensource.

Discussion (0)