-
Notifications
You must be signed in to change notification settings - Fork 3.3k
157 lines (138 loc) · 5.19 KB
/
docs-checks.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
name: Check Docs
# https://github.com/marketplace/actions/sphinx-build
on:
push:
branches: ["master", "release/*"]
# use this event type to share secrets with forks.
# it's important that the PR head SHA is checked out to run the changes
pull_request_target:
branches: ["master", "release/*"]
paths:
- ".actions/**"
- ".github/workflows/docs-checks.yml"
- "requirements/**"
- "docs/**"
- "src/**"
- "setup.py"
- "pyproject.toml" # includes metadata used in the package creation
- "!*.md"
- "!**/*.md"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
defaults:
run:
shell: bash
jobs:
make-doctest:
runs-on: ubuntu-latest
container:
image: pytorchlightning/pytorch_lightning:docs
strategy:
fail-fast: false
matrix:
pkg-name: ["app", "pytorch"]
env:
FREEZE_REQUIREMENTS: "1"
steps:
- uses: actions/checkout@v3
with:
submodules: true
ref: ${{ github.event.pull_request.head.sha }}
- uses: aws-actions/configure-aws-credentials@v1
if: ${{ matrix.pkg-name == 'app' }}
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_ID }}
aws-region: us-east-1
- run: aws s3 sync s3://sphinx-packages/ pypi/
if: ${{ matrix.pkg-name == 'app' }}
# Note: This uses an internal pip API and may not always work
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: docs-test-${{ matrix.pkg-name }}-${{ hashFiles('requirements/${{ matrix.pkg-name }}/*.txt') }}
restore-keys: docs-test-${{ matrix.pkg-name }}-
- name: Install LAI package
# This is needed as App docs is heavily using/referring to lightning package
if: ${{ matrix.pkg-name == 'app' }}
run: |
pip install -e . -U -v -f https://download.pytorch.org/whl/cpu/torch_stable.html -f pypi
- name: Adjust docs refs
if: ${{ matrix.pkg-name == 'app' }}
run: |
pip install -q -r .actions/requirements.txt
python .actions/assistant.py copy_replace_imports --source_dir="./docs" \
--source_import="pytorch_lightning,lightning_fabric" \
--target_import="lightning.pytorch,lightning.fabric"
- name: Install this package
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
run: |
pip install -e .[extra,cloud,ui] -U -r requirements/${{ matrix.pkg-name }}/docs.txt -f pypi
pip list
- name: Test Documentation
env:
SPHINX_MOCK_REQUIREMENTS: 0
working-directory: ./docs/source-${{ matrix.pkg-name }}
run: |
make doctest
make coverage
make-html:
runs-on: ubuntu-latest
container:
image: pytorchlightning/pytorch_lightning:docs
strategy:
fail-fast: false
matrix:
pkg-name: ["app", "pytorch"]
env:
FREEZE_REQUIREMENTS: "1"
steps:
- uses: actions/checkout@v3
with:
submodules: true
ref: ${{ github.event.pull_request.head.sha }}
- uses: aws-actions/configure-aws-credentials@v1
if: ${{ matrix.pkg-name != 'pytorch' }}
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_ID }}
aws-region: us-east-1
- run: aws s3 sync s3://sphinx-packages/ pypi/
if: ${{ matrix.pkg-name != 'pytorch' }}
# Note: This uses an internal pip API and may not always work
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: docs-make-${{ matrix.pkg-name }}-${{ hashFiles('requirements/${{ matrix.pkg-name }}/*.txt') }}
restore-keys: docs-make-${{ matrix.pkg-name }}-
- name: Install package & dependencies
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
run: |
pip --version
pip install -e . -U -r requirements/${{ matrix.pkg-name }}/docs.txt \
-f https://download.pytorch.org/whl/cpu/torch_stable.html -f pypi
pip list
shell: bash
- name: Make Documentation
working-directory: ./docs/source-${{ matrix.pkg-name }}
run: |
make html --debug --jobs $(nproc) SPHINXOPTS="-W --keep-going"
- name: Check External Links in Sphinx Documentation (Optional)
working-directory: ./docs/source-${{ matrix.pkg-name }}
run: |
make linkcheck
continue-on-error: true
- name: Upload built docs
uses: actions/upload-artifact@v3
with:
name: docs-${{ matrix.pkg-name }}-${{ github.sha }}
path: docs/build/html/
# Use always() to always run this step to publish test results when there are test failuress
if: success()