Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic python test setup to CI #114

Merged
merged 7 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI Checks

on:
workflow_call:


jobs:

unit-tests:
name: Unit Tests
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
python-version: [ "3.11" ]

steps:
- name: SCM Checkout
uses: actions/checkout@v4

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Run Tests
run: |
poetry run nox -s unit-tests

integration-tests:
name: Integration Tests
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
python-version: [ "3.11" ]

steps:
- name: SCM Checkout
uses: actions/checkout@v4

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Run Tests
run: |
poetry run nox -s integration-tests
26 changes: 5 additions & 21 deletions .github/workflows/ci-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,14 @@ name: Continues Integration (Master)

on:
workflow_dispatch:
pull_request:
branches-ignore:
- master
- main
- gh-pages
push:
- master
- main
- "Test-Automation"
schedule:
# “At 00:00 on every 7th day-of-month from 1 through 31.” (https://crontab.guru)
- cron: "0 0 1/7 * *"

jobs:

verify:
runs-on: ubuntu-latest

steps:

- name: SCM Checkout
uses: actions/checkout@v4

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/python-environment@main
with:
python-version: "3.11"

- name: Run all checks
run: |
echo "Stub: This needs to call the checks in the future"
uses: ./.github/workflows/checks.yml
20 changes: 1 addition & 19 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,8 @@ name: Continues Integration (PR)

on:
pull_request:
branches-ignore:
- master
- main
- "Test-Automation"

jobs:

verify:
runs-on: ubuntu-latest

steps:

- name: SCM Checkout
uses: actions/checkout@v4

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/[email protected]
with:
python-version: "3.11"

- name: Run all checks
run: |
echo "Stub: This needs to call the checks in the future"
uses: ./.github/workflows/checks.yml
47 changes: 47 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from __future__ import annotations
from pathlib import Path
from typing import Iterable
import nox
from nox import Session

__all__ = [
"unit_tests",
"integration_tests",
]

_ROOT : Path = Path(__file__).parent


def _test_command(path: Path) -> Iterable[str]:
base_command = ["poetry", "run"]
pytest_command = ["pytest", "-v", f"{path}"]
return base_command + pytest_command


def _unit_tests(session: Session) -> None:
command = _test_command(_ROOT / "test" / "unit")
session.run(*command)


def _integration_tests(session: Session) -> None:
command = _test_command(_ROOT / "test" / "integration")
session.run(*command)


@nox.session(name="unit-tests", python=False)
def unit_tests(session: Session) -> None:
"""Runs all unit tests"""
_unit_tests(session)


@nox.session(name="integration-tests", python=False)
def integration_tests(session: Session) -> None:
"""Runs the all integration tests"""
_integration_tests(session)


@nox.session(name="all-tests", python=False)
def all_tests(session: Session) -> None:
"""Runs all tests (Unit and Integration)"""
command = _test_command(_ROOT / "test")
session.run(*command)
Loading
Loading