Continuous Integration
- Create a branch called
ci - Create the 2 files
ci/calculator.pyandci/test_calculator.py. - Build a Gitlab-CI with 2 stages:
- Static analysis, with 3 jobs (linting, formating, type-checking)
- The type checking job should enforce type hints and be allowed to fail!
- Testing (use
pytest) - ensure job output shows which ones are executed.- Use pytest-cov and make use of
coverage1 andartifactskeywords so that one can see the generatedhtmlreport.
- Use pytest-cov and make use of
- Static analysis, with 3 jobs (linting, formating, type-checking)
- Open a merge request and set lecturer (Manuel Reis) as the reviewer.
Important
⚠️ You need to enable CI/CD in Settings→General→“Visibility, project features, permissions” and enable instance runners under Settings→CI/CD→Runners.
Note
Since you are using DKRZ’s Gitlab, refer to the documentation:
ci/calculator.py:def add(a, b): return a + b def sub(a, b): return a - b def div(a, b): return a / b def mul(a, b): return a * bci/test_calculator.py:import pytest import calculator as cal @pytest.mark.parametrize("op", ["add", "mul", "sub", "div"]) def test_ops(op): assert hasattr(cal, op) def test_add(): cal.add(1, 1) == 2 def test_sub(): cal.sub(1, 1) == 0 def test_mul(): cal.mul(1, 1) == 1 def test_div(): cal.div(1, 1) == 1