Skip to content

Commit

Permalink
Including testing tutorial notebooks in PR unit CI workflow (#127)
Browse files Browse the repository at this point in the history
* add nbmake and test for notebooks, test on multiple python versions

* install grits from source, fix path to tutorials

* remove str in nb path

* install tutorials dir in setup.py, move tutorials into flowermd

* move tutorials back

* use nbmake in separate line

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove cmeutils install from source

* Put back data dir

* fix CG notebook

* fix param in welding tutorial

* pass python version to mamba, add macos

* create new job for testing tutorials

* remove python 3.9 from tests, change python version in env files

* fix python version arg

* fix input

* remove python 3.12 from env and tests

* comment out sims in surface wetting tutorial

* add on issue comment to yml file

* run through surface wetting sim, comment out sim run cells

* change comment trigger

* try adding branche and paths under issue_comment

* filter only PR comments in pytest workflow

* change the PR comment body condition

* Fix bug in test notebook if condition

* add checks for open PR and reaction to trigger comment

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: marjanalbouye <marjan.albouye73@gmail.com>
  • Loading branch information
3 people authored Apr 2, 2024
1 parent 9f0cda5 commit 7f85dc3
Show file tree
Hide file tree
Showing 6 changed files with 1,248 additions and 424 deletions.
71 changes: 69 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@ on:
- flowermd/**
- environment-dev.yml
- .github/workflows/pytest.yml
# Allows workflow to be manually triggered
issue_comment:
types: [created]
branches: [ main ]
paths:
- flowermd/**
- environment-dev.yml
- .github/workflows/pytest.yml

workflow_dispatch:

jobs:
pytest:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest]
python-version: ['3.10', '3.11']

runs-on: ${{ matrix.os }}

steps:
- name: Check out repository
Expand All @@ -29,6 +42,7 @@ jobs:
uses: conda-incubator/setup-miniconda@v2
with:
environment-file: environment-dev.yml
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
miniforge-version: 4.9.2-4
use-mamba: true
Expand All @@ -46,3 +60,56 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml

test-tutorials:
if: ${{ github.event.issue.pull_request && github.event.comment.body== '/testtutorials'}}
runs-on: ubuntu-latest
steps:
- name: Put a reaction to the comment
run: gh api graphql --silent --raw-field query="mutation AddReaction {addReaction(input:{subjectId:\"$NODE_ID\",content:EYES}){reaction{content}subject{id}}}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_ID: ${{ github.event.comment.node_id }}
- name: Check if PR is open
run: |
STATE=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json state --jq .state)
if [ "$STATE" != "OPEN" ]; then
echo "Cannot build for closed PRs"
(
echo "**${{ github.workflow }}**"
echo "Cannot build Kuby for a closed PR. Use the `latest` version (built for the `master` branch) or create a new PR."
) | \
gh pr comment "${PR_NUMBER}" --repo ${{ github.repository }} -F -
gh api graphql --silent --raw-field query="mutation AddReaction {addReaction(input:{subjectId:\"$NODE_ID\",content:THUMBS_DOWN}){reaction{content}subject{id}}}"
gh api graphql --silent --raw-field query="mutation RemoveReaction {removeReaction(input:{subjectId:\"$NODE_ID\",content:EYES}){reaction{content}subject{id}}}"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
NODE_ID: ${{ github.event.comment.node_id }}
- name: Get PR HEAD Ref
id: getRef
run: echo "pr_ref=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefOid | jq -r '.headRefOid')" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}

- name: Check out repository
uses: actions/checkout@v2

- name: Build environment
uses: conda-incubator/setup-miniconda@v2
with:
environment-file: environment-dev.yml
miniforge-variant: Mambaforge
miniforge-version: 4.9.2-4
use-mamba: true

- name: Install package
shell: bash -l {0}
run: pip install .

- name: Run pytest on tutorials
shell: bash -l {0}
run: python -m pytest -rs -v --nbmake tutorials/
4 changes: 3 additions & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ dependencies:
- py3Dmol
- pytest
- pytest-cov
- nbmake
- python >=3.10, <3.12
- fresnel >=0.13.5
- cmeutils >=1.1.1
- grits >=0.3.0
- pip:
- git+https://github.com/cmelab/grits.git@main
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ def run(self):
"flowermd": [
"modules/**",
"library/**",
"assets/forcefields/*",
"assets/molecule_files/*",
"assets/forcefields/**",
"assets/molecule_files/**",
"utils/**",
"internal/**",
]
],
},
install_requires=REQUIRED,
include_package_data=True,
Expand Down
241 changes: 145 additions & 96 deletions tutorials/3-flowerMD-coarse-graining.ipynb

Large diffs are not rendered by default.

518 changes: 260 additions & 258 deletions tutorials/4-flowerMD-welding.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 7f85dc3

Please sign in to comment.