-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (112 loc) · 3.99 KB
/
CI.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# This workflow will setup GitHub-hosted runners
name: tests
# Define the events that trigger the workflow
on:
# Run on pull requests to main branch
pull_request:
branches: [main]
types: [synchronize, opened, reopened, ready_for_review]
# Run on pushes to main branch
push:
branches: [main]
jobs:
# Run unit tests in all relevant versions
tests_with_pip:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
# Relevant Python versions
python-version: ["3.8", "3.9", "3.10", "3.11"]
# Do not cancel all in-progress jobs if any matrix job fails
fail-fast: false
steps:
# Used to reset cache every month
- name: Get current year-month
id: date
run: echo "::set-output name=date::$(date +'%Y-%m')"
- uses: actions/checkout@v2
- name: Cache test_env
uses: actions/cache@v2
with:
path: ~/test_env
# Look to see if there is a cache hit for the corresponding
# requirements files. The cache will be reset on changes to
# any requirements or every month
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}
-${{ hashFiles('**/requirements-tests.txt') }}-${{ hashFiles('setup.py') }}
-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
# Install required Python version
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# Create an environment and install everything
# Add coveralls later pip install pytest-cov coveralls
- name: Install dependencies
run: |
python -m venv ~/test_env
source ~/test_env/bin/activate
python -m pip install --upgrade pip
pip install -r requirements/requirements-tests.txt
pip install -r requirements/requirements.txt
pip install -e .
# Output the Python version and environment information
- name: List packages
run: |
source ~/test_env/bin/activate
pip list
python --version
# Run unit tests with Pytest
- name: Test with pytest
run: |
source ~/test_env/bin/activate
pytest
docs:
name: docs (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
steps:
# Used to reset cache every month
- name: Get current year-month
id: date
run: echo "::set-output name=date::$(date +'%Y-%m')"
- uses: actions/checkout@v2
- name: Cache doc_env
uses: actions/cache@v2
with:
path: ~/doc_env
# Look to see if there is a cache hit for the corresponding
# requirements files. The cache will be reset on changes to
# any requirements or every month
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}
-${{ hashFiles('**/requirements-docs.txt') }}-${{ hashFiles('setup.py') }}
-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
# Install required Python version
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"
# Create an environment and install everything
- name: Install dependencies
run: |
python -m venv ~/doc_env
source ~/doc_env/bin/activate
python -m pip install --upgrade pip
pip install -r requirements/requirements-docs.txt
pip install -r requirements/requirements.txt
pip install -e .
- name: List packages
run: |
source ~/doc_env/bin/activate
pip list
python --version
- name: make html
run: |
source ~/doc_env/bin/activate
cd doc
make html