From 49b4815bf0b1b07a34b9f7fdebe3c07b3b3b2918 Mon Sep 17 00:00:00 2001 From: diehlbw <36572844+diehlbw@users.noreply.github.com> Date: Thu, 30 May 2024 06:56:53 -0500 Subject: [PATCH] CI Test suite for multiple enviroments (#15) --- .github/workflows/ci.yml | 77 +++++++++++++++++++++++++++++++++++----- setup.cfg | 9 ++--- 2 files changed, 73 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef7f20b..0934e35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,8 @@ on: permissions: "read-all" jobs: - run-linting: - name: linting via pre-commit + linting: + name: Linting runs-on: ubuntu-latest steps: @@ -18,7 +18,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: "3.10" - name: Install pre-commit run: | pip install --upgrade pip @@ -26,8 +26,8 @@ jobs: - name: Run pre-commit steps run: | pre-commit run --all-files - run-tests: - name: tests via pytest + test-coverage: + name: Coverage py3.10 runs-on: ubuntu-latest steps: @@ -36,17 +36,76 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: "3.10" - name: Install dependencies run: | pip install --upgrade pip pip install -e .[dev,audit] - name: Run tests run: | - pytest . - - name: Upload coverage + coverage run -m pytest + - name: Generate report + run: | + coverage xml + coverage report + - name: Generate html + if: failure() + run: | + coverage html + - name: Upload report + if: always() uses: actions/upload-artifact@v4 with: name: coverage-data - path: coverage/coverage.xml + path: coverage/* if-no-files-found: error + test-packaging: + name: Test packaging + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install dependencies + run: | + pip install --upgrade pip + pip install build twine + - name: Build package + run: | + python -m build + python -m twine check dist/* + test-versions: + # Limit matrix to after base is passing + needs: [test-coverage, linting, test-packaging] + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11"] + os: + - ubuntu-latest + - windows-latest + - macos-latest + include: + - experimental: false + + name: Test python-${{ matrix.python-version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install --upgrade pip + pip install -e .[dev,audit] + - name: Run tests + run: | + pytest diff --git a/setup.cfg b/setup.cfg index 135110e..1dca8e3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -51,8 +51,8 @@ all = audit = aequitas>=1.0.0 dev = + coverage>=7.5.1 autopep8>=1.3.5 - pytest-cov>=2.5.1 pytest-json>=0.4.0 pytest>=5.1.1 traitlets>=5.1.1 @@ -71,15 +71,13 @@ docs = [tool:pytest] -addopts = --cov-config=setup.cfg --cov=seismometer --cov-report=term --cov-report=html --cov-report=xml:coverage/coverage.xml testpaths = tests -json_report = coverage/test-report.json -jsonapi = True filterwarnings = ignore::UserWarning ignore::PendingDeprecationWarning [coverage:run] +source = seismometer branch = True [coverage:report] @@ -90,6 +88,9 @@ omit = [coverage:html] directory = coverage/html-report +[coverage:xml] +output = coverage/coverage.xml + [tool:isort] line_length = 119 profile = black