Configure Continuous Integration

Now we want to get deeper into the Continuous Intergration Setup.

At first we want to create a small dummy test. We can just take this one from the template package.

Creating tests

Please create the python package tests next to the plain_magic directory. The folder structure should look like this now.

some_directory/
   plain_magic/
      __init__.py
      cli.py
      number_magic.py
   tests/
      __init__.py
      test_number_magic.py
   setup.py

Install pytest via pip and try to execute the tests in the home directory

pip install pytest

cd some_directory
pytest

Configure Tox

Now we are trying to automate the whole installation and testing proceduce via tox. Therefore we need to put another configuration file in the main folder.

To check if you succeeded please install tox and execute it.

pip install tox

cd some_directory
tox

If all tests run through, you made it.

The folder structure shall look like this now:

some_directory/
   plain_magic/
      __init__.py
      cli.py
      number_magic.py
   tests/
      __init__.py
      test_number_magic.py
   setup.py
   tox.ini

Configure Gitlab to run the Tests

Now we want the current local repository to be on the Gitlab server. Therefore please follow these instructions, but keep in mind to skip the Use Project Template. We already created our own little repository.

Now we want to tell Gitlab to run the tests for us, every time we push. Therefore we need to add a file named .gitlab-ci.yml according to the instructions from the template documentation.