-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make actions use docker compose file
- Loading branch information
1 parent
ef209c0
commit 349560b
Showing
5 changed files
with
72 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,46 @@ | ||
name: Run Unit Tests on Multiple Python Versions | ||
|
||
name: Run Unit Tests on Multiple Python Versions and Distributions | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
pytest_legacy_python: | ||
name: python:${{ matrix.python-version }} | ||
runs-on: ubuntu-20.04 | ||
container: | ||
image: python:${{ matrix.python-version }}-buster | ||
test-python-versions: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
python-version: ["2.7", "3.6"] | ||
python-version: ["python27", "python36", "python310"] | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Display Python version | ||
run: python -c "import sys; print(sys.version)" | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Test with pytest | ||
- name: Run pytest | ||
run: | | ||
pip install pytest pytest-cov | ||
pytest tests/ | ||
docker run --rm \ | ||
-v ${{ github.workspace }}:/app \ | ||
${{ env.REPOSITORY }}:${{ matrix.python-version }}-pytest \ | ||
pytest -v --ignore=tests/test_system.py | ||
pytest_latest_python: | ||
name: ${{ matrix.os }} ${{ matrix.python-version }} | ||
runs-on: ${{ matrix.os }} | ||
test-systems: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: ["3.11"] | ||
distro: ["amazonlinux", "centos7", "osx"] | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Display Python version | ||
run: python -c "import sys; print(sys.version)" | ||
- name: Setup test command | ||
id: setup | ||
run: | | ||
if [ "${{ matrix.distro }}" == "osx" ]; then | ||
echo "::set-output name=command::python -m pytest" | ||
else | ||
echo "::set-output name=command::pytest" | ||
fi | ||
- name: Test with pytest | ||
- name: Run system tests | ||
run: | | ||
pip install pytest pytest-cov | ||
pytest tests/ | ||
docker run --rm -v ${{ github.workspace }}:/app \ | ||
${{ env.REPOSITORY }}:${{ matrix.distro }}-pytest \ | ||
${{ steps.setup.outputs.command }} -v tests/test_system.py -p no:cacheprovider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import sys | ||
|
||
import pytest | ||
|
||
# Add the parent directory to the path so we can import the latest version of the script | ||
oom_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) | ||
sys.path.insert(0, oom_dir) | ||
|
||
from oom_investigate import System | ||
|
||
# Ignore DeprecationWarning and PendingDeprecationWarning warnings | ||
pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") | ||
pytestmark = pytest.mark.filterwarnings("ignore::PendingDeprecationWarning") | ||
|
||
|
||
class TestSystem: | ||
def test_distro_info_imports(self): | ||
# very basic test to check if the distro info is returned | ||
# Designed to run on docker containers for python 2.7, 3.6, 3.10 | ||
system = System() | ||
distro_info = system.get_distro_info() | ||
assert distro_info[0] is not None | ||
assert distro_info[1] is not None |