From 85b008f3f465486b1e5750f136783ffa6eaeb0ca Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Thu, 5 Oct 2023 21:21:49 -0400 Subject: [PATCH] ci: implement ci workflow and basic tests --- .github/workflows/ci.yml | 56 +++++++++++++++++++++++++++++++++ requirements-dev.txt | 4 +++ tests/__init__.py | 0 tests/conftest.py | 11 +++++++ tests/functional/test_python.py | 12 +++++++ 5 files changed, 83 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 requirements-dev.txt create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/functional/test_python.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0379ee3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +--- +name: CI + +on: + pull_request: + branches: [master] + types: [opened, synchronize, reopened] + push: + branches: [master] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + pytest: + strategy: + fail-fast: false + matrix: + os: + - macos-11 + - macos-12 + - windows-2019 + - windows-2022 + - ubuntu-20.04 + - ubuntu-22.04 + python: ["2.7", "3.8", "3.9", "3.10", "3.11"] + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Python + id: python + uses: ./ + with: + python-version: ${{ matrix.python }} + + - name: Install Python Dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install --upgrade -r requirements-dev.txt + + - name: Test with pytest + id: test + env: + INPUT_PYTHON_VERSION: ${{ matrix.python }} + shell: bash + run: | + python -m pytest \ + -rxXs \ + --tb=native \ + --verbose \ + tests diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..7fe5273 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +pytest==4.6.11;python_version<"3.5" +pytest==6.1.2;python_version>="3.5" and python_version<"3.6" +pytest==7.0.1;python_version>="3.6" and python_version<"3.7" +pytest==7.4.2;python_version>="3.7" diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..d06b233 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# standard imports +import os + +# lib imports +import pytest + + +@pytest.fixture(scope='session') +def input_python_version(): + return os.environ.get('INPUT_PYTHON_VERSION') diff --git a/tests/functional/test_python.py b/tests/functional/test_python.py new file mode 100644 index 0000000..d6ae13a --- /dev/null +++ b/tests/functional/test_python.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# standard imports +import platform +import sys + + +def test_python_platform_version(input_python_version): + assert platform.python_version().startswith(input_python_version) + + +def test_python_system_version(input_python_version): + assert sys.version.startswith(input_python_version)