diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..3951c97 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,41 @@ +name: CI (test) + +on: + push: + branches: + - main + pull_request: + branches: + - main + + +jobs: + test: + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11"] + + runs-on: ubuntu-latest + + defaults: + run: + working-directory: 01-ci-lab + + steps: + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run test + run: pytest + + - name: Run linter + run: flake8 . \ No newline at end of file diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index 7382287..c064e26 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -1,5 +1,6 @@ def add(a, b): return a + b + def divide(a, b): - return a / b \ No newline at end of file + return a / b diff --git a/01-ci-lab/tests/test_calculator.py b/01-ci-lab/tests/test_calculator.py index 08c4a28..b3cc2ad 100644 --- a/01-ci-lab/tests/test_calculator.py +++ b/01-ci-lab/tests/test_calculator.py @@ -1,7 +1,9 @@ from app.calculator import add, divide + def test_add(): assert add(2, 3) == 5 + def test_divide(): - assert divide(10, 2) == 5 \ No newline at end of file + assert divide(10, 2) == 5