Continuous integration is a very important practice for software projects which consist of multiple contributors. Usually, just a code review is not enough to merge a pull request to the master branch since a very simple but a hidden mistake can occur errors during the actual build process. Therefore, what we could do is,
But! how about having the CI part as a module of the source code hosting environment? Awesome right!. Github Actions offers a nice CI/CD solution inside the well known Github environment.
I experimented Github Actions and added it to our project as per below.
Step 1:There are many predefined CI workflows. Where as our project needs a custom workflow since there are multiple platforms and also some configurations.
Step 2:Write your workflow script. CI workflow may consist of more than one jobs. I have created two jobs for two different platforms (Linux and Windows).
name: C/C++ CIon: [push, pull_request]jobs: build-linux:runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: configure run: sudo apt-get install libgtk-3-dev -y && sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-37 libwebkit2gtk-4.0-dev - name: build run: bash build.shbuild-windows:runs-on: windows-latest steps: - uses: actions/checkout@v1 - name: build run: ./build
This workflow has two jobs.
build-linux will clone our project and run the required build script on Linux platform.
build-windows will do the same on Windows platform. Importantly, this workflow will be triggered when a new commit is pushed or when a new pull request is created.
Step 3:Eventually, test the workflow by triggering it (Eg:- by creating a pull request).
Happy Coding :sunglasses: