Skip to content

Commit 7f85dc3

Browse files
chrisjonesBSUpre-commit-ci[bot]marjanalbooyeh
authored
Including testing tutorial notebooks in PR unit CI workflow (#127)
* 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 <[email protected]>
1 parent 9f0cda5 commit 7f85dc3

6 files changed

+1248
-424
lines changed

.github/workflows/pytest.yml

+69-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,25 @@ on:
1414
- flowermd/**
1515
- environment-dev.yml
1616
- .github/workflows/pytest.yml
17-
# Allows workflow to be manually triggered
17+
issue_comment:
18+
types: [created]
19+
branches: [ main ]
20+
paths:
21+
- flowermd/**
22+
- environment-dev.yml
23+
- .github/workflows/pytest.yml
24+
1825
workflow_dispatch:
1926

2027
jobs:
2128
pytest:
22-
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
os: [macOS-latest, ubuntu-latest]
33+
python-version: ['3.10', '3.11']
34+
35+
runs-on: ${{ matrix.os }}
2336

2437
steps:
2538
- name: Check out repository
@@ -29,6 +42,7 @@ jobs:
2942
uses: conda-incubator/setup-miniconda@v2
3043
with:
3144
environment-file: environment-dev.yml
45+
python-version: ${{ matrix.python-version }}
3246
miniforge-variant: Mambaforge
3347
miniforge-version: 4.9.2-4
3448
use-mamba: true
@@ -46,3 +60,56 @@ jobs:
4660
with:
4761
token: ${{ secrets.CODECOV_TOKEN }}
4862
file: ./coverage.xml
63+
64+
test-tutorials:
65+
if: ${{ github.event.issue.pull_request && github.event.comment.body== '/testtutorials'}}
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Put a reaction to the comment
69+
run: gh api graphql --silent --raw-field query="mutation AddReaction {addReaction(input:{subjectId:\"$NODE_ID\",content:EYES}){reaction{content}subject{id}}}"
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
NODE_ID: ${{ github.event.comment.node_id }}
73+
- name: Check if PR is open
74+
run: |
75+
STATE=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json state --jq .state)
76+
if [ "$STATE" != "OPEN" ]; then
77+
echo "Cannot build for closed PRs"
78+
(
79+
echo "**${{ github.workflow }}**"
80+
echo "Cannot build Kuby for a closed PR. Use the `latest` version (built for the `master` branch) or create a new PR."
81+
) | \
82+
gh pr comment "${PR_NUMBER}" --repo ${{ github.repository }} -F -
83+
gh api graphql --silent --raw-field query="mutation AddReaction {addReaction(input:{subjectId:\"$NODE_ID\",content:THUMBS_DOWN}){reaction{content}subject{id}}}"
84+
gh api graphql --silent --raw-field query="mutation RemoveReaction {removeReaction(input:{subjectId:\"$NODE_ID\",content:EYES}){reaction{content}subject{id}}}"
85+
exit 1
86+
fi
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
PR_NUMBER: ${{ github.event.issue.number }}
90+
NODE_ID: ${{ github.event.comment.node_id }}
91+
- name: Get PR HEAD Ref
92+
id: getRef
93+
run: echo "pr_ref=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefOid | jq -r '.headRefOid')" >> $GITHUB_OUTPUT
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
PR_NUMBER: ${{ github.event.issue.number }}
97+
98+
- name: Check out repository
99+
uses: actions/checkout@v2
100+
101+
- name: Build environment
102+
uses: conda-incubator/setup-miniconda@v2
103+
with:
104+
environment-file: environment-dev.yml
105+
miniforge-variant: Mambaforge
106+
miniforge-version: 4.9.2-4
107+
use-mamba: true
108+
109+
- name: Install package
110+
shell: bash -l {0}
111+
run: pip install .
112+
113+
- name: Run pytest on tutorials
114+
shell: bash -l {0}
115+
run: python -m pytest -rs -v --nbmake tutorials/

environment-dev.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ dependencies:
1616
- py3Dmol
1717
- pytest
1818
- pytest-cov
19+
- nbmake
1920
- python >=3.10, <3.12
2021
- fresnel >=0.13.5
2122
- cmeutils >=1.1.1
22-
- grits >=0.3.0
23+
- pip:
24+
- git+https://github.com/cmelab/grits.git@main

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ def run(self):
9090
"flowermd": [
9191
"modules/**",
9292
"library/**",
93-
"assets/forcefields/*",
94-
"assets/molecule_files/*",
93+
"assets/forcefields/**",
94+
"assets/molecule_files/**",
9595
"utils/**",
9696
"internal/**",
97-
]
97+
],
9898
},
9999
install_requires=REQUIRED,
100100
include_package_data=True,

tutorials/3-flowerMD-coarse-graining.ipynb

+145-96
Large diffs are not rendered by default.

tutorials/4-flowerMD-welding.ipynb

+260-258
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)