DEV Community

gus
gus

Posted on

Github Action

For this week's lab I implemented Github Actions for my GAS SSG. First I went back and got my tests from last week working. Even though I implemented testing many of them were failing for reasons I didn't have time to get to, which I thankfully got the chance to get figured out this week. The biggest issue that held me up last week was file input not working if I didn't compile my program as I normally do, which I realized was because I hadn't changed my Visual Studio working directory - so my files were being compiled from one folder while the project was in another - obviously the path was wrong when compiling from the project folder.

Next I started working on setting up Github Actions for continuous integration - the intention being that once it's set up my program and its tests will be automatically compiled and any compilation errors will be flagged. I worked on it for a bit last night and was having issues with the inclusion of direct.h. I was wondering if something to do with the compiler or the platform was the issue, but ultimately I realized the only function using direct.h was my newFolder() function. I took a look at how I was using it there and realized it was just being used to make a directory, which std::filesystem can already do. With that in mind, I removed the portion that used direct.h and left the directory creation to std::filesystem.

In the meantime, I noticed I hadn't pulled from my repo last night so my Github Action was removed after pushing those other changes. I remade the .yml and tried again, and everything compiled smoothly.

Next I added some additional tests to my testing file. All functions are covered already, so I added some more types of tests to my processText function to cover other functionalities like getting input from within a folder and reading a .md in addition to a .txt. In doing so I moved my contributing.md to a contributing directory along with my linting and formatting scripts, changed the scripts to reflect the new filepath and also specified which source files to cover, so as to avoid formatting and linting catch.hpp. I created a pull request which successfully passed the workflow I defined earlier. I pushed a commit to cause the compilation stage of the workflow to fail, which it did, and then reverted it.

Finally, I moved onto working on Kien's potato SSG. His setup with catch2 is similar to mine, we both have it set up to provide us a main which we compile separately when we want to test it, rather than having it integrated into the program all the time. This made it easy to get started on his, I read his contributing.md which specified one should create a new source file to write their desired test cases, which I did. After messing around with file paths for a bit and figuring out how to get my test to pass, I pushed a commit and created a pull request with a test for his HTMLFile.getTitle() function. Unfortunately I realized with the workflow he had set up this wouldn't trigger his CI so I opted to insert my test case in test.cpp instead to see if it passed his workflow, which thankfully it did.

This week's lab was pretty cool, I've seen these Github Actions all over the place while working on open source projects, as well as in some of my classes now. It was surprisingly easy to get set up and seems like something I'd definitely use in the future for how straightforward it is to add to a repo.

Top comments (0)