Skip to content

Commit

Permalink
add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
flaport committed Feb 3, 2022
1 parent f56ad35 commit 9deb980
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 4 deletions.
164 changes: 164 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: main
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
paths-ignore:
- ".github/**"
- "!.github/workflows/main.yml"
- "docs/**"
- "*.md"
- ".git*"

jobs:
clean:
runs-on: ubuntu-latest
container:
image: condaforge/mambaforge
volumes:
- ${{ github.workspace }}:/github/workspace
steps:
- name: Checkout
uses: actions/checkout@master
- name: Install dependencies
run: mamba install -c fastai -c conda-forge nbdev nbstripout
- name: Clean notebooks
run: nbdev_clean_nbs
- name: Strip notebook outputs
run: find . -name "*.ipynb" | xargs nbstripout
- name: Check if git status is clean
run: |
if [ ! -z "$(git status --porcelain)" ]; then
echo "Notebooks are not cleaned! They still contain outputs and/or metadata."
echo "You probably forgot to clear the notebook outputs before pushing."
echo "Please make sure all pre-commit hooks are properly installed to prevent this issue."
false;
fi
diff:
runs-on: ubuntu-latest
container:
image: condaforge/mambaforge
volumes:
- ${{ github.workspace }}:/github/workspace
steps:
- name: Checkout
uses: actions/checkout@master
- name: Install dependencies
run: mamba install -c fastai -c conda-forge nbdev
- name: Check for no diff between notebooks and library
run: |
if [ ! -z "$(nbdev_diff_nbs)" ]; then
echo "Python library does not match backing notebooks (diff between notebooks and library detected). "
echo "You probably forgot to re-generate the library before pushing."
echo "Please make sure all pre-commit hooks are properly installed to prevent this issue."
false;
fi
test:
runs-on: ubuntu-latest
# needs:
# - docker
container:
image: flaport/sax
volumes:
- ${{ github.workspace }}:/github/workspace
steps:
- name: Checkout
uses: actions/checkout@master
- name: Test notebooks
run: nbdev_test_nbs | tee nbdev_test_nbs.log
- name: Expose 'nbdev_test_nbs.log' as artifact
uses: actions/upload-artifact@master
with:
name: nbdev_test_nbs.log
path: /github/workspace/nbdev_test_nbs.log

run:
runs-on: ubuntu-latest
needs:
- clean
- diff
# - docker
container:
image: flaport/sax
volumes:
- ${{ github.workspace }}:/github/workspace
steps:
- name: Checkout
uses: actions/checkout@master
- name: Run notebooks
run: find . -name "*.ipynb" | grep -v ipynb_checkpoints | xargs -I {} papermill -k python3 {} {}
- name: Expose 'nbs' as artifact
uses: actions/upload-artifact@master
with:
name: nbs
path: /github/workspace/nbs
- name: Expose 'examples' as artifact
uses: actions/upload-artifact@master
with:
name: examples
path: /github/workspace/examples
- name: Expose 'index.ipynb' as artifact
uses: actions/upload-artifact@master
with:
name: index.ipynb
path: /github/workspace/index.ipynb

docs:
runs-on: ubuntu-latest
needs:
- run
container:
image: flaport/sax
volumes:
- ${{ github.workspace }}:/github/workspace
steps:
- name: Checkout
uses: actions/checkout@master
- name: Download 'nbs' artifact
uses: actions/download-artifact@master
with:
name: nbs
path: ./nbs
- name: Download 'examples' artifact
uses: actions/download-artifact@master
with:
name: examples
path: ./examples
- name: Download 'index.ipynb' artifact
uses: actions/download-artifact@master
with:
name: index.ipynb
path: ./index.ipynb
- name: Build docs
run: nbdev_build_docs
- name: Store artifacts
uses: actions/upload-artifact@master
with:
name: docs
path: /github/workspace/docs

pages:
runs-on: ubuntu-latest
needs:
- docs
container:
image: flaport/sax
volumes:
- ${{ github.workspace }}:/github/workspace
steps:
- name: Checkout
uses: actions/checkout@master
- name: Download 'docs' artifact
uses: actions/download-artifact@master
with:
name: docs
path: /github/workspace/docs
- name: Deploy
uses: JamesIves/github-pages-deploy-action@4.1.7
with:
branch: pages
folder: docs
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM condaforge/mambaforge:4.11.0-0

COPY environment.yml /environment.yml
RUN sed -i "s/^[ ]*-[ ]*sax=\+.*//g" environment.yml
RUN mamba env update -n base -f /environment.yml
RUN conda run -n base python -m ipykernel install --user --name base --display-name base
RUN conda run -n base python -m ipykernel install --user --name sax --display-name sax
RUN rm -rf /environment.yml

COPY docs/nbdev_showdoc.patch /nbdev_showdoc.patch
Expand All @@ -12,6 +14,3 @@ RUN rm -rf /nbdev_showdoc.patch
ADD . /sax
RUN pip install /sax
RUN rm -rf /sax

RUN conda create -n sax --clone base
RUN conda run -n sax python -m ipykernel install --user --name sax --display-name sax
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ dependencies:
- pre-commit==2.17.0
- pyright==0.0.13
- pytables==3.7.0
- pytest==6.2.5
- pyyaml==6.0
- scipy==1.7.3
- shapely==1.8.0
- tqdm==4.62.3
- twine==0.0.0
- twine==3.7.1
- pip:
- flax==0.4.0
- jax==0.2.27
Expand Down

0 comments on commit 9deb980

Please sign in to comment.