-
Notifications
You must be signed in to change notification settings - Fork 31
209 lines (182 loc) · 6.9 KB
/
pnl-ci-docs.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: PsyNeuLink Docs CI
on:
push:
branches-ignore:
- 'dependabot/**'
tags:
- 'v*'
pull_request:
# run only the latest instance of this workflow job for the current branch/PR
# cancel older runs
# fall back to run id if not available (run id is unique -> no cancellations)
concurrency:
group: ci-${{ github.ref || github.run_id }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
docs-build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
# Matrix setup is a hacky way to include 'base' build in pull requests
# The entire matrix is set up and 'base' builds are pruned based
# on event name and final configuration (ubuntu, python3.7).
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-architecture: ['x64']
os: [ubuntu-latest, macos-latest, windows-latest]
event:
- ${{ github.event_name }}
pnl-version: ['head', 'base']
exclude:
- event: 'push'
pnl-version: 'base'
- os: macos-latest
pnl-version: 'base'
- os: windows-latest
pnl-version: 'base'
- python-version: '3.8'
pnl-version: 'base'
- python-version: '3.9'
pnl-version: 'base'
- python-version: '3.10'
pnl-version: 'base'
- python-version: '3.11'
pnl-version: 'base'
outputs:
on_master: ${{ steps.on_master.outputs.on-branch }}
steps:
# increased fetch-depth and tag checkout needed as in pnl-ci.yml
- name: Checkout sources
uses: actions/checkout@v3
if: ${{ matrix.pnl-version == 'head' }}
with:
fetch-depth: 200
ref: ${{ github.ref }}
- name: Checkout pull base
uses: actions/checkout@v3
if: ${{ matrix.pnl-version == 'base' }}
with:
fetch-depth: 200
ref: ${{ github.base_ref }}
- name: Checkout tags
run: git fetch --tags origin master
- name: Check if on master
if: ${{ github.event_name == 'push' }}
id: on_master
uses: ./.github/actions/on-branch
with:
branch: master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
# Block python3.7.17 on macos. see:
# https://github.com/actions/setup-python/issues/682
python-version: ${{ (matrix.os == 'macos-latest' && matrix.python-version == '3.7') && '3.7.16' || matrix.python-version }}
architecture: ${{ matrix.python-architecture }}
- name: Get pip cache location
shell: bash
id: pip_cache
run: |
python -m pip install -U pip
python -m pip --version
echo "pip_cache_dir=$(python -m pip cache dir)" | tee -a $GITHUB_OUTPUT
- name: Wheels cache
uses: actions/cache@v3
with:
path: ${{ steps.pip_cache.outputs.pip_cache_dir }}/wheels
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.python-architecture }}-pip-wheels-${{ hashFiles('requirements.txt', 'doc_requirements.txt') }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.python-architecture }}-pip-wheels-${{ hashFiles('requirements.txt', 'doc_requirements.txt') }}
# We need to install all PNL deps since docs config imports psyneulink module
- name: Install local, editable PNL package
uses: ./.github/actions/install-pnl
with:
features: 'doc'
- name: Add git tag
# The generated docs include PNL version,
# set it to a fixed value to prevent polluting the diff
# This needs to be done after installing PNL
# to not interfere with dependency resolution
id: add_zero_tag
if: github.event_name == 'pull_request'
run: git tag --force 'v0.0.0.0'
- name: Build Documentation
run: make -C docs/ html -e SPHINXOPTS="-aE -j auto"
- name: Remove git tag
# The generated docs include PNL version,
# A special tag was set to a fixed value
# to prevent polluting the diff
if: steps.add_zero_tag.outcome != 'skipped'
run: git tag -d 'v0.0.0.0'
- name: Upload Documentation
uses: actions/upload-artifact@v3
with:
name: Documentation-${{matrix.pnl-version}}-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.python-architecture }}
retention-days: 1
path: docs/build/html
- name: Store PR number
if: ${{ github.event_name == 'pull_request' }}
run: echo ${{ github.event.pull_request.number }} > ./pr_number.txt
- name: Upload PR number for other workflows
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: pr_number
path: ./pr_number.txt
docs-deploy:
strategy:
fail-fast: false
matrix:
python-version: [3.7]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: write
needs: [docs-build]
environment: github-pages
if: github.event_name == 'push' &&
(github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/devel' ||
github.ref == 'refs/heads/docs' ||
(startsWith(github.ref, 'refs/tags/') && contains(needs.*.outputs.on_master, 'master'))
)
steps:
- name: Checkout docs
uses: actions/checkout@v3
with:
ref: gh-pages
- name: Download branch docs
uses: actions/download-artifact@v3
with:
name: Documentation-head-${{ matrix.os }}-${{ matrix.python-version }}-x64
path: _built_docs/${{ github.ref }}
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/devel' || github.ref == 'refs/heads/docs'
- name: Update branch docs
shell: bash
run: |
mkdir -p branch
rm -rf "branch/${GITHUB_REF##*/}"
# Remove '.doctrees' and move to correct location
rm -rf "_built_docs/${GITHUB_REF}/.doctrees"
mv -f "_built_docs/${GITHUB_REF}" branch/
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/devel' || github.ref == 'refs/heads/docs'
- name: Download main docs
uses: actions/download-artifact@v3
with:
name: Documentation-head-${{ matrix.os }}-${{ matrix.python-version }}-x64
# This overwrites files in current directory
if: startsWith(github.ref, 'refs/tags/') && contains(needs.*.outputs.on_master, 'master')
- name: Update main docs
shell: bash
run: |
# Remove '.doctrees'
rm -rf ".doctrees"
if: startsWith(github.ref, 'refs/tags/') && contains(needs.*.outputs.on_master, 'master')
- name: Commit docs changes
shell: bash
run: |
# Commit changes to git
git add .
git config user.name "Documentation Bot"
git config user.email "[email protected]"
git commit -m "Docs changes for $GITHUB_REF $GITHUB_SHA"
git push