-
Notifications
You must be signed in to change notification settings - Fork 899
147 lines (134 loc) Β· 6.12 KB
/
lychee.yml
File metadata and controls
147 lines (134 loc) Β· 6.12 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
name: π Lychee
on: [pull_request]
concurrency:
group: lychee-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
check:
name: Check Links
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- name: π Lychee Link Checker (First Run)
id: lychee
uses: lycheeverse/lychee-action@v2
with:
args: >-
--cache
--cache-exclude-status 429,500,502,503,504
--max-cache-age 5m
--verbose
--no-progress
--exclude '.*'
--timeout 20
--max-retries 8
--retry-wait-time 5
--include '^https://'
--exclude 'https://www.gnu.org'
--exclude 'https://docs.solidjs.com'
--accept 200,201,204,304,403,429
'./apps/docs/content'
output: lychee/out.md
fail: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: π Retry Lychee Link Checker (Second Run for Timeouts)
id: lychee-retry
if: ${{ always() && steps.lychee.outputs.exit_code != 0 }}
uses: lycheeverse/lychee-action@v2
with:
args: >-
--cache
--cache-exclude-status 429,500,502,503,504
--max-cache-age 5m
--verbose
--no-progress
--exclude '.*'
--timeout 30
--max-retries 10
--retry-wait-time 10
--include '^https://'
--exclude 'https://www.gnu.org'
--exclude 'https://docs.solidjs.com'
--accept 200,201,204,304,403,429
'./apps/docs/content'
output: lychee/out-retry.md
fail: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: π Clean up Lychee Report
if: ${{ always() && github.event.pull_request.head.repo.fork == false }}
run: |
# Use retry results if available, otherwise use first run results
if [ -f "lychee/out-retry.md" ]; then
REPORT_FILE="lychee/out-retry.md"
elif [ -f "lychee/out.md" ]; then
REPORT_FILE="lychee/out.md"
fi
if [ -n "$REPORT_FILE" ]; then
# Parse stats from lychee markdown table
TOTAL=$(grep 'Total' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
SUCCESS=$(grep 'Successful' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
ERRORS=$(grep 'Errors' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
REDIRECTS=$(grep 'Redirected' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
EXCLUDED=$(grep 'Excluded' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
TIMEOUTS=$(grep 'Timeouts' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
UNKNOWN=$(grep 'Unknown' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
UNSUPPORTED=$(grep 'Unsupported' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
# Extract errors section
ERRORS_SECTION=$(sed -n '/^## Errors/,/^## /p' "$REPORT_FILE" | sed '$d' | tail -n +2)
# Format errors section
FORMATTED_ERRORS=""
while IFS= read -r line; do
if [[ $line =~ ^### ]]; then
file=$(echo "$line" | sed 's/### Errors in //')
FORMATTED_ERRORS+="\n**\`$file\`**\n"
elif [[ $line =~ ^\* ]]; then
FORMATTED_ERRORS+="$line\n"
fi
done <<< "$ERRORS_SECTION"
# Create formatted output using echo statements
echo "## π Lychee Link Check Report" > lychee/formatted.md
echo "" >> lychee/formatted.md
echo "**$TOTAL links:** \`β
$SUCCESS OK\` | \`π« $ERRORS errors\` | \`π $REDIRECTS redirects\` | \`π» $EXCLUDED excluded\`" >> lychee/formatted.md
echo "" >> lychee/formatted.md
if [ "$ERRORS" -eq 0 ]; then
echo "### β
All links are working!" >> lychee/formatted.md
else
echo "### β Errors" >> lychee/formatted.md
echo -e "$FORMATTED_ERRORS" >> lychee/formatted.md
fi
echo "---" >> lychee/formatted.md
echo "" >> lychee/formatted.md
echo "<details>" >> lychee/formatted.md
echo "<summary>Full Statistics Table</summary>" >> lychee/formatted.md
echo "" >> lychee/formatted.md
echo "| Status | Count |" >> lychee/formatted.md
echo "|--------|-------|" >> lychee/formatted.md
echo "| β
Successful | $SUCCESS |" >> lychee/formatted.md
echo "| π Redirected | $REDIRECTS |" >> lychee/formatted.md
echo "| π» Excluded | $EXCLUDED |" >> lychee/formatted.md
echo "| π« Errors | $ERRORS |" >> lychee/formatted.md
echo "| β Unsupported | $UNSUPPORTED |" >> lychee/formatted.md
echo "| β³ Timeouts | $TIMEOUTS |" >> lychee/formatted.md
echo "| β Unknown | $UNKNOWN |" >> lychee/formatted.md
echo "" >> lychee/formatted.md
echo "</details>" >> lychee/formatted.md
fi
- name: π Comment Broken Links
if: ${{ always() && github.event.pull_request.head.repo.fork == false }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: lychee
path: lychee/formatted.md
- name: π« Fail if broken links found
if: ${{ steps.lychee-retry.conclusion == 'success' && steps.lychee-retry.outputs.exit_code != 0 || steps.lychee-retry.conclusion == 'failure' }}
run: |
if [ "${{ steps.lychee-retry.conclusion }}" == "success" ]; then
echo "Failing based on retry run results"
exit ${{ steps.lychee-retry.outputs.exit_code }}
else
echo "Failing based on first run results"
exit ${{ steps.lychee.outputs.exit_code }}
fi