Lab 08 Continuous Integration (CI)

ajogseneca

Ajo George

Posted on November 16, 2024

Lab 08 Continuous Integration (CI)

What is happening

In this we were tasked to implement CI workflow to the tool that. Also we were tasked to add some more test cases to make sure our CI implementation is working smoothly and also write some test cases in our classmates repos to test their CI integration

What i did

To finish of the first task which include CI workflow and automation of the test case running, i started with adding a workflow file to my GitHub Repo with the help of GitHub itself.
In this we include a .yml which is modified for python apps.

Image description

In this image we can see that, it auto runs the test case if there is a pull request or a merge happening in that main branch.

Also we can see that the use of API key of Gorq as it is required to conduct the test and also i have added this as a secret environment variable with in the GitHub.

Image description

In this screenshot of the code we can see the main steps and requirements that the .yml install's while running the test cases. then the code is finally tested with the help of pytest.

My new test case

So i wrote a simple test case for the functions which take part in argument parsing,

  1. class TestParseArguments(unittest.TestCase):
    In this function it acts as a simulation of passing a file and a model as an argument and then checks if it is correctly parsed and assigned to args.file and args.model. It also checks if the TOML configuration is empty.

  2. def test_parse_arguments_with_token(self):
    In this function, it simulates passing a file and a model and also the flag --token, Then it checks if args.token flag is correctly set to True.

What is did in my classmate Repo

I have used my friend Liam's repo, when i took it was too late it has already most the test cases covered so i managed to create a simple one using the help of jest.mock

The test consist of setup of mocks to prevent any interference with the actual file of the tools. Now the test case which node ./index.js nonExistentFile.js which situates the behavior of the tool when a non-existing file is passed as an argument, which will throw an error.

Conclusion

I should say this was not that easy; I ran into a lot of issues with the conversion of my files into packages, as Python requires everything to be in a package for proper CI integration. Then there were issues associated with setting up the test cases with GitHub with the API, which required updating my source code. I managed to implement some simple test cases for me as well as my classmate's repo.

At the end, this lab helped me learn and see more important information about test cases, automation, GitHub, etc. I want to learn more about this to properly understand this to the fullest. I think I will do that slowly.

AJO GEORGE 15-11-2024

💖 💪 🙅 🚩
ajogseneca
Ajo George

Posted on November 16, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related