-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (140 loc) · 5.46 KB
/
linkcheck.yml
File metadata and controls
164 lines (140 loc) · 5.46 KB
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
# Run sphinx's linkcheck to pop up
# broken and redirected links.
name: Linkcheck
on:
push:
paths:
- '*.diff'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
jobs:
linkcheck:
runs-on: ubuntu-latest
strategy:
matrix:
branch: ['main', '3.13', '3.12']
include:
- branch: 'main'
#fix-redir-with-found: 'fix-redir-with-found.diff'
fix-timeout: 'fix-timeout.diff'
- branch: '3.13'
#fix-broken: 'fix-broken.diff'
#fix-redir-permanently: 'fix-redir-permanently.diff'
#fix-redir-temporarily: 'fix-redir-temporarily.diff'
fix-timeout: 'fix-timeout.diff'
- branch: '3.12'
#fix-redir-with-found: 'fix-redir-with-found.diff'
fix-timeout: 'fix-timeout.diff'
fail-fast: false
steps:
- name: Check out this repo
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check out CPython
uses: actions/checkout@v4
with:
repository: python/cpython
persist-credentials: false
ref: ${{ matrix.branch }}
path: cpython
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3'
cache: 'pip'
cache-dependency-path: 'cpython/Doc/requirements.txt'
- name: Install dependencies
run: |
pip install -U pip
pip install flake8
- name: Apply fix-broken
if: matrix.fix-broken != 0
run: |
cd cpython
cat ../${{ matrix.fix-broken }}
git apply ../${{ matrix.fix-broken }}
- name: Apply fix-redir-permanently
if: matrix.fix-redir-permanently != 0
run: |
cd cpython
cat ../${{ matrix.fix-redir-permanently }}
git apply ../${{ matrix.fix-redir-permanently }}
- name: Apply fix-redir-temporarily
if: matrix.fix-redir-temporarily != 0
run: |
cd cpython
cat ../${{ matrix.fix-redir-temporarily }}
git apply ../${{ matrix.fix-redir-temporarily }}
- name: Apply fix-redir-with-found
if: matrix.fix-redir-with-found != 0
run: |
cd cpython
cat ../${{ matrix.fix-redir-with-found }}
git apply ../${{ matrix.fix-redir-with-found }}
- name: Apply fix-timeout
if: matrix.fix-timeout != 0
run: |
cd cpython
cat ../${{ matrix.fix-timeout }}
git apply ../${{ matrix.fix-timeout }}
# Exclude other reported issues, to get e.g. W605 invalid escape sequence '\d'
- name: Flake8 on Doc/conf.py
run: |
flake8 cpython/Doc/conf.py --ignore E122,E501,E401,E402,F401,W291 --output-file ${{ matrix.branch }}-flake8.txt
- name: Make virtual environment
run: |
make -C cpython/Doc venv
- name: Build documentation
run: |
make -C cpython/Doc html
- name: Run linkcheck
run: |
make -C cpython/Doc linkcheck SPHINXOPTS="--keep-going" SPHINXERRORHANDLING="" || true
- name: Split log
run: |
BRANCH=${{ matrix.branch }}
SRCFILE="cpython/Doc/build/linkcheck/output.txt"
touch ${BRANCH}-log-broken.txt ${BRANCH}-log-redir-temporarily.txt ${BRANCH}-log-redir-permanently.txt ${BRANCH}-log-redir-with-found.txt ${BRANCH}-log-timeout.txt ${BRANCH}-log-timeout.txt
grep ' \[broken] ' ${SRCFILE} | sort > ${BRANCH}-log-broken.txt || true
grep ' \[redirected temporarily] ' ${SRCFILE} | sort > ${BRANCH}-log-redir-temporarily.txt || true
grep ' \[redirected permanently] ' ${SRCFILE} | sort > ${BRANCH}-log-redir-permanently.txt || true
grep ' \[redirected with Found] ' ${SRCFILE} | sort > ${BRANCH}-log-redir-with-found.txt || true
grep ' \[timeout] ' ${SRCFILE} | sort > ${BRANCH}-log-timeout.txt || true
sed '/\[broken]/d;/\[redirected temporarily]/d;/\[redirected with Found]/d;/\[redirected permanently]/d;/\[timeout]/d' ${SRCFILE} | sort > ${BRANCH}-log-others.txt
sort ${SRCFILE} > ${BRANCH}-linkcheck.txt
- run: cat ${{ matrix.branch }}-log-broken.txt
- run: cat ${{ matrix.branch }}-log-redir-temporarily.txt
- run: cat ${{ matrix.branch }}-log-redir-permanently.txt
- run: cat ${{ matrix.branch }}-log-redir-with-found.txt
- run: cat ${{ matrix.branch }}-log-timeout.txt
- run: cat ${{ matrix.branch }}-log-others.txt
- name: Upload output as artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.branch }}-logs
path: |
${{ matrix.branch }}-*.txt
${{ matrix.branch }}-flake8.txt
push:
runs-on: ubuntu-latest
needs: linkcheck
permissions:
contents: write
steps:
- name: Check out this repo
uses: actions/checkout@v4
- name: Download logs
uses: actions/download-artifact@v4
- name: Commit and push logs
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git status
git add *-logs/*.txt
git diff-index --cached --quiet HEAD || { git commit -m "Update linkcheck log"; git pull --rebase; git push; }