DEV Community

Tong Liu
Tong Liu

Posted on

Reflect of Lab09

In Lab09, we are going to implement GitHub Actions which is a C/I tool to automate tests of our project. This technology is widely used by most repositories on GitHub because it could save the repository maintainer a lot of times on finding the potential bugs and checking the submitted code that don't conform with the suggested code style.

Links

My successful GitHub Actions run: 3464401840
Testing PR to Another Repo: 3466622227

Setup

To set up the GitHub Actions, we first need to create 2 folders, a .github in the root directory of the repository, and a workflows folder inside .github folder we just created. In the workflows folder, we create a YAML file to save the GitHub Actions configuration.
I programmed my project in C++ with Catch 2 for the testing framework, my GitHub Actions should be set up with C++ software stacks. The process of how I set up my YAML is as follows:

  1. To make the GitHub Actions workflows run, I first set up the actions and branches that I want the GitHub Actions workflow to execute on. In my repository, it should be the push action and pull_request action on the main branch.
  2. I need to install the C++ compiler for the testing environment to compile my tests, in this case, I used apt-get install -y clang to install clang++.
  3. Before running the test cases, I need to add the code to compile the test. I used clang++ $CXXFLAGS $CXX -o $OUTPUTFILE to compile my tests, CXXFLAGS, OUTPUTFILE, and CXX are the variables I define in the env: because I want to segregate my actual compile command with parameters that are passed to it.
    1. Now that my tests are compiled, I can run them now. To run them, I defined a new step in GitHub Actions. In this step, I just used ./test.o to run the compile binary tests.
    2. Last is to delete the compiled test file. I think this step is omittable since every time we run GitHub Actions, there will always be a new environment created to run the workflows, and once the workflows are done, the environment will be deleted, so files that are generated during the tests will remain in the test GitHub Actions environment and it should not pollute my repository.

GitHub Actions differences

The partner I have this time is Piotr Drozd (here's his repo link). As I compared his GitHub Actions script with mine, I found differences as follows:

  1. Since our repositories are built with different languages, the dependency and build tools we use for GitHub Actions are also different.
  2. The way how we pass parameters to the testing framework is different. he directly passes parameters to the command, and I use variables to pass parameters.

Thoughts on CI.

After this lab, my thought on CI has been dramatically shifted, because initially, I thought setting CI would be pretty difficult to do, however, when I actually get into it, I found out that not only the syntax for GitHub Actions is pretty straightforward, but there's also tons of templates for us to use. Also, I realized that using GitHub Actions can drastically decrease the possibility of my contributors making dumb mistakes because GitHub Actions will automatically check their submitted code and prompt them whenever violations happen.

Top comments (0)