-
Notifications
You must be signed in to change notification settings - Fork 67
95 lines (92 loc) · 2.53 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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