Functorial drawing #215
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
name: build | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
env: | |
SRC_DIR: discopy | |
TEST_DIR: test | |
DOCS_DIR: docs | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [ 3.9 ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install linter | |
run: | |
python -m pip install pyproject-flake8 coverage pylint | |
- name: Check for errors | |
run: | |
# stop the build if there are Python syntax errors or undefined names | |
pflake8 discopy | |
- name: pylint | |
run: | |
pylint discopy | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [ 3.9, "3.10", "3.11", "3.12" ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' # caching pip dependencies | |
- name: Install | |
run: | | |
pip install coverage pytest | |
pip install torch --index-url https://download.pytorch.org/whl/cpu # Install PyTorch without CUDA | |
pip install .[test] | |
- name: Test | |
run: | |
coverage run -m pytest | |
- name: Coverage | |
run: | |
coverage report --fail-under=98 --show-missing | |
docs: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [ 3.9 ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- name: Cache | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ env.DOCS_DIR }}/_api | |
${{ env.DOCS_DIR }}/_build | |
key: ${{ runner.os }}-docs-${{ hashFiles('discopy/**', 'docs/**') }} # TODO: refactor to use env.SRC_DIR and DOCS_DIR | |
restore-keys: | | |
${{ runner.os }}-docs | |
- name: Install | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y pandoc | |
pip install .[docs] | |
- name: Build | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
sphinx-build ${{ env.DOCS_DIR }} ${{ env.DOCS_DIR }}/_build/html | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs | |
path: ${{ env.DOCS_DIR }}/_build/html # or path/to/artifact |