Update notebooks for cloud environments #370
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Update notebooks for cloud environments" | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| - "!gh-pages" | |
| - "!open-in-colab" | |
| - "!open-in-kaggle" | |
| pull_request: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: "0 4 * * SUN" | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: "Branch on multiphenicsx repository" | |
| type: string | |
| jobs: | |
| open_in_colab: | |
| uses: fem-on-colab/open-in-colab-workflow/.github/workflows/workflow_call.yml@main | |
| with: | |
| source_directory: website_source_not_used | |
| work_directory: open_in_colab | |
| notebook_pattern: "**/*.ipynb" | |
| notebook_preparation: | | |
| python3 -m pip install --no-dependencies nbvalx simpleeval | |
| git clone https://github.com/multiphenics/multiphenicsx.git | |
| cd multiphenicsx | |
| if [ -n "${{ (inputs || github.event.inputs).branch }}" ]; then | |
| git checkout "${{ (inputs || github.event.inputs).branch }}" | |
| fi | |
| NO_TESTS_COLLECTED=5 | |
| python3 -m pytest --ipynb-action=create-notebooks --collapse --work-dir=.ipynb_colab tutorials || (($?==$NO_TESTS_COLLECTED)) | |
| find tutorials -type d -name .ipynb_colab -exec rsync -avz --remove-source-files --include="*.ipynb" --exclude="*" {}/ {}/.. \; | |
| find tutorials -type f -name '*\[*].ipynb' -exec bash -c 'for f; do dir=$(dirname "$f"); base=$(basename "$f"); stem="${base%%[*}"; plain="$dir/$stem.ipynb"; if [ -f "$plain" ]; then rm "$plain"; fi; done' _ {} + | |
| rsync -avz --delete --include "*/" --include="*.ipynb" --exclude="*" tutorials ../open_in_colab/ | |
| find ../open_in_colab/ -type f -name "*.ipynb" -exec bash -c 'for f; do new=${f//[\[\]=]/_}; if [[ "$f" != "$new" && ! -e "$new" ]]; then mv "$f" "$new" && ln -s "$(basename "$new")" "$f"; fi; done' _ {} + | |
| fem_on_colab_packages: | | |
| gmsh@current | |
| fenicsx==development-real@current$dolfinx | |
| pip_packages: | | |
| viskex%multiphenicsx | |
| multiphenicsx@https://github.com/multiphenics/multiphenicsx.git@current£--check-build-dependencies --no-build-isolation | |
| test_script: | | |
| python3 -m pytest --nbval open_in_colab/tutorials | |
| find open_in_colab -type l -name "*.ipynb" -exec bash -c 'for link; do target=$(readlink -f "$link"); [[ -f "$target" ]] && rm "$link" && mv "$target" "$link"; done' _ {} + | |
| publish_on: github@multiphenics/multiphenics.github.io@open-in-colab | |
| publish_if_repository: multiphenics/multiphenics.github.io | |
| open_in_kaggle: | |
| uses: fem-on-kaggle/open-in-kaggle-workflow/.github/workflows/workflow_call.yml@main | |
| with: | |
| source_directory: website_source_not_used | |
| work_directory: open_in_kaggle | |
| notebook_pattern: "**/*.ipynb" | |
| notebook_preparation: | | |
| python3 -m pip install --no-dependencies nbvalx simpleeval | |
| git clone https://github.com/multiphenics/multiphenicsx.git | |
| cd multiphenicsx | |
| if [ -n "${{ (inputs || github.event.inputs).branch }}" ]; then | |
| git checkout "${{ (inputs || github.event.inputs).branch }}" | |
| fi | |
| NO_TESTS_COLLECTED=5 | |
| python3 -m pytest --ipynb-action=create-notebooks --collapse --work-dir=.ipynb_kaggle tutorials || (($?==$NO_TESTS_COLLECTED)) | |
| find tutorials -type d -name .ipynb_kaggle -exec rsync -avz --remove-source-files --include="*.ipynb" --exclude="*" {}/ {}/.. \; | |
| find tutorials -type f -name '*\[*].ipynb' -exec bash -c 'for f; do dir=$(dirname "$f"); base=$(basename "$f"); stem="${base%%[*}"; plain="$dir/$stem.ipynb"; if [ -f "$plain" ]; then rm "$plain"; fi; done' _ {} + | |
| rsync -avz --delete --include "*/" --include="*.ipynb" --exclude="*" tutorials ../open_in_kaggle/ | |
| find ../open_in_kaggle/ -type f -name "*.ipynb" -exec bash -c 'for f; do new=${f//[\[\]=]/_}; if [[ "$f" != "$new" && ! -e "$new" ]]; then mv "$f" "$new" && ln -s "$(basename "$new")" "$f"; fi; done' _ {} + | |
| fem_on_kaggle_packages: | | |
| gmsh@current | |
| fenicsx==development-real@current$dolfinx | |
| pip_packages: | | |
| viskex%multiphenicsx | |
| multiphenicsx@https://github.com/multiphenics/multiphenicsx.git@current£--check-build-dependencies --no-build-isolation | |
| test_script: | | |
| python3 -m pytest --nbval open_in_kaggle/tutorials | |
| find open_in_kaggle -type l -name "*.ipynb" -exec bash -c 'for link; do target=$(readlink -f "$link"); [[ -f "$target" ]] && rm "$link" && mv "$target" "$link"; done' _ {} + | |
| publish_on: github@multiphenics/multiphenics.github.io@open-in-kaggle | |
| publish_if_repository: multiphenics/multiphenics.github.io | |
| warn: | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'multiphenics/multiphenics.github.io' && github.ref == 'refs/heads/main' && github.event_name == 'schedule' | |
| steps: | |
| - name: Warn if scheduled workflow is about to be disabled | |
| uses: fem-on-colab/warn-workflow-about-to-be-disabled-action@58c6022d9aeb22accfa8df9bf5b58c3d8867208c # v1.0.0 | |
| with: | |
| workflow-filename: open_in_cloud.yml | |
| days-elapsed: 50 |