Skip to content

Commit

Permalink
TEST: Testing upper and lower dependency version bounds via CI (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpelley authored Aug 29, 2024
1 parent 2f293c3 commit 1b07e24
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 18 deletions.
64 changes: 47 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on: [pull_request]


jobs:
test:
lower-bound-packages:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest

steps:
# SETUP

############################
- name: Checkout code
uses: actions/checkout@v4
with:
Expand All @@ -26,13 +26,46 @@ jobs:
- name: Add checkout directory to PYTHONPATH
run: echo "PYTHONPATH=$(pwd):$PYTHONPATH" >> $GITHUB_ENV

- name: Cache pip environment
id: cache-pip-env
uses: actions/cache@v4
- name: Install dependencies
id: install-dependencies
run: |
pip install .[tests,minver]
pip uninstall dagrunner -y
- name: Set up SSH for localhost
run: |
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh-keyscan -H $(hostname) >> ~/.ssh/known_hosts
chmod 600 ~/.ssh/authorized_keys
# TESTS
############################
- name: Run pytest
run: pytest .


unpinned-packages:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest

steps:
# SETUP
############################
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # Ensure branch is checked out, not detached state (so we can push a commit later)
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('pyproject.toml') }}
restore-keys: pip-
python-version: 3.x
cache: 'pip'

- name: Add checkout directory to PYTHONPATH
run: echo "PYTHONPATH=$(pwd):$PYTHONPATH" >> $GITHUB_ENV

- name: Install dependencies
id: install-dependencies
Expand All @@ -48,14 +81,12 @@ jobs:
chmod 600 ~/.ssh/authorized_keys
# TESTS (inc. test coverage)

# excluded logging as per https://github.com/MetOffice/dagrunner/issues/39
############################
- name: Run pytest + coverage report gen
run: pytest --cov=dagrunner --cov-report=term --cov-report=html | tee coverage_output.txt; test ${PIPESTATUS[0]} -eq 0


# TESTS (main branch)

# TESTS ('main' branch)
############################
- name: Cache ref branch coverage report
id: cache-ref-coverage
uses: actions/cache@v4
Expand All @@ -70,15 +101,14 @@ jobs:
path: ref
ref: ${{ github.base_ref }}

# excluded logging as per https://github.com/MetOffice/dagrunner/issues/39
- name: Run tests with coverage for ref branch
if: steps.cache-ref-coverage.outputs.cache-hit != 'true'
run: |
cd ref
pytest --cov=dagrunner --cov-report=term --cov-report=html | tee coverage_output.txt; test ${PIPESTATUS[0]} -eq 0
# TESTS (compare coverage)

############################
- name: Compare coverage
id: comp-coverage
run: |
Expand Down Expand Up @@ -119,7 +149,7 @@ jobs:
htmlcov/
# PRE-COMMIT

############################
- name: Python interpreter version sha (PYSHA)
run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV

Expand All @@ -139,7 +169,7 @@ jobs:
pre-commit run --all-files
# DOCUMENTATION

############################
- name: Build documentation
run: |
./docs/gen_docs dagrunner ./docs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Python Project](https://img.shields.io/badge/language-Python%20>=3.9-blue?logo=python&logoColor=white)
[![GitHub Tag](https://img.shields.io/github/v/tag/MetOffice/dagrunner)](https://github.com/MetOffice/dagrunner/tags)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
![Experimental](https://img.shields.io/badge/status-experimental-orange)
![Python Project](https://img.shields.io/badge/language-Python-blue?logo=python&logoColor=white)
![Static Badge](https://img.shields.io/badge/install-pip-blue)
![PR CI status](https://github.com/MetOffice/dagrunner/actions/workflows/tests.yml/badge.svg)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ dev = [
"pre-commit",
"pytest-cov"
]
# specifying lower bound versions of packages (testing purposes)
minver=[
'networkx == 3.2',
'dask[distributed] == 2024.1.1',
]

[project.urls]
Repository = "https://github.com/MetOffice/dagrunner"
Expand Down

0 comments on commit 1b07e24

Please sign in to comment.