-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
11,761 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
hsa | ||
slippy |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# https://EditorConfig.org | ||
|
||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.ipynb] | ||
# Content is json, but it seems to be minimally formatted | ||
indent_size = unset | ||
|
||
[*.js] | ||
indent_size = 2 | ||
|
||
[*.json] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
indent_size = unset | ||
|
||
[*.py] | ||
# yapf and black will use indents other than 4 spaces | ||
indent_size = unset | ||
|
||
[*.rst] | ||
indent_size = unset | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
max_line_length = 100 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: 'Build Jupyterbook' | ||
description: 'Build the Jupyterbook with desired run features' | ||
|
||
inputs: | ||
jb-cache: | ||
description: “Set up the Jupyterbook Cache (boolean)” | ||
required: true | ||
publish-to-gh: | ||
description: “Publish to GitHub Pages (boolean)” | ||
required: true | ||
jb-save: | ||
description: "Save the Jupyterbook Build (boolean)" | ||
required: true | ||
token: | ||
description: 'A GitHub Personal Access Token (for publishing)' | ||
required: false | ||
default: '0' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup JupyterBook Cache | ||
if: inputs.jb-cache == 'true' | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./book/_build | ||
# NOTE: change key to "jupyterbook-N+1" to force rebuilding cache | ||
key: jupyterbook-0 | ||
|
||
- uses: ./.github/actions/setupconda | ||
|
||
- name: Build JupyterBook | ||
shell: bash -l {0} | ||
run: | | ||
./scripts/build_resources.sh | ||
- name: Dump Build Logs | ||
if: always() | ||
shell: bash -l {0} | ||
run: | | ||
if (test -a book/_build/html/reports/*log); then cat book/_build/html/reports/*log ; fi | ||
- name: Upload Pages HTML | ||
if: inputs.publish-to-gh == 'true' | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: book/_build/html | ||
|
||
- name: Setup GitHub Pages | ||
if: inputs.publish-to-gh == 'true' | ||
uses: actions/configure-pages@v5 | ||
|
||
- name: Deploy to GitHub Pages | ||
if: inputs.publish-to-gh == 'true' | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
|
||
- name: Upload Complete Build Folder | ||
if: ${{ always() && inputs.jb-save == 'true'}} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-${{ runner.os }} | ||
path: book/_build/ | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: 'Setup Conda' | ||
description: 'Create conda environment for GitHub Action Job' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: mamba-org/setup-micromamba@v1 | ||
with: | ||
environment-file: conda/conda-lock.yml | ||
environment-name: bioscape | ||
cache-environment: true | ||
cache-downloads: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Test website build across operating systems | ||
|
||
on: | ||
schedule: | ||
# run this once a week (sunday midnight) to preserve cache | ||
# https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy | ||
- cron: '0 0 * * 0' | ||
pull_request_target: | ||
types: [labeled, synchronize] | ||
paths: | ||
- '.github/**/*' | ||
- '{{ cookiecutter.repo_directory }}/**' | ||
- 'book/**/*' | ||
- 'conda/**' | ||
- 'scripts/**' | ||
- 'cookiecutter.yaml' | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-test: | ||
# This workflow accesses secrets (~/.netrc) so only run if labelled by repo owner | ||
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | ||
if: contains(github.event.pull_request.labels.*.name, 'preview') | ||
name: Build and test on OS - ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ "ubuntu-latest", "macos-latest" ] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- uses: ./.github/actions/buildresources | ||
with: | ||
jb-cache: false | ||
publish-to-gh: false | ||
jb-save: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Deploy | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- 'book/**' | ||
- '{{ cookiecutter.repo_directory }}/**' | ||
- 'scripts/**' | ||
- '.github/workflows/deploy.yaml' | ||
- 'cookiecutter.yaml' | ||
|
||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: github-pages | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/buildresources | ||
with: | ||
jb-cache: false | ||
publish-to-gh: true | ||
jb-save: true | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
import nb_clean as nbc | ||
import nbformat | ||
import yaml | ||
|
||
with open('./book/_config.yml') as f: | ||
data = yaml.safe_load(f) | ||
|
||
# Sometimes we use rendered notebooks instead of executing them | ||
exclude_paths = [] | ||
for pattern in data['execute']['exclude_patterns']: | ||
exclude_paths += list(Path('book/tutorials').glob(pattern)) | ||
exclude_notebooks = [path.as_posix() for path in exclude_paths] | ||
print('Excluded from execution:\n', '\n'.join(exclude_notebooks)) | ||
|
||
# Scrub outputs for spellcheck and linkcheck | ||
for notebook in exclude_notebooks: | ||
print(f'Scrubbing outputs: {notebook}...') | ||
nb = nbformat.read(notebook, as_version=nbformat.NO_CONVERT) | ||
cleaned = nbc.clean_notebook(nb, | ||
remove_empty_cells=True, | ||
preserve_cell_metadata=True) | ||
nbformat.write(cleaned, notebook) | ||
|
||
|
||
all_ipynbs = [path.as_posix() for path in Path('book/tutorials').rglob('*.ipynb')] | ||
ipynbs = [p for p in all_ipynbs if not '.ipynb_checkpoints' in p] | ||
|
||
results = [] | ||
for notebook in ipynbs: | ||
#if not notebook in exclude_notebooks: | ||
print(f'Checking {notebook}...') | ||
nb = nbformat.read(notebook, as_version=nbformat.NO_CONVERT) | ||
result = nbc.check_notebook(nb, | ||
remove_empty_cells=False, | ||
preserve_cell_metadata=True) | ||
results.append(result) | ||
|
||
if False in results: | ||
sys.exit(1) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Build Without Cache | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/buildresources | ||
with: | ||
jb-cache: false | ||
publish-to-gh: false | ||
jb-save: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: QualityControl | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
quality-control: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: ./.github/actions/setupconda | ||
|
||
- name: Install NB-Clean | ||
run: | | ||
pip install nb-clean==2.0.2 | ||
- name: Ensure clean notebooks | ||
run: | | ||
python .github/workflows/ensure_clean_notebooks.py | ||
# NOTE: this isn't a comprehensive spellcheck, just common typos | ||
- name: Spellcheck | ||
if: always() | ||
uses: codespell-project/actions-codespell@master | ||
with: | ||
check_filenames: true | ||
skip: '*.js,*.css,qaqc.yml,*.geojson' | ||
ignore_words_file: .codespellignore | ||
only_warn: 1 | ||
|
||
# borrowed from https://github.com/ProjectPythia/pythia-foundations/blob/main/.github/workflows/link-checker.yaml | ||
- name: Disable Notebook Execution Before Linkcheck | ||
if: always() | ||
shell: python | ||
run: | | ||
import yaml | ||
with open('./book/_config.yml') as f: | ||
data = yaml.safe_load(f) | ||
data['execute']['execute_notebooks'] = 'off' | ||
with open('./book/_config.yml', 'w') as f: | ||
yaml.dump(data, f) | ||
- name: Check External Links | ||
continue-on-error: true | ||
timeout-minutes: 5 | ||
if: always() | ||
run: | | ||
jb build book --builder linkcheck |
Oops, something went wrong.