-
Notifications
You must be signed in to change notification settings - Fork 2
102 lines (91 loc) · 3.37 KB
/
Copy pathdocs-check.yml
File metadata and controls
102 lines (91 loc) · 3.37 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
name: Docs Check
on:
pull_request:
paths:
- 'official-docs/**'
- 'docs-py/**'
push:
branches: [main]
paths:
- 'official-docs/**'
- 'docs-py/**'
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
with:
python-version: '3.12'
- name: Install package
run: uv sync --group dev
# main always validates live against fresh vlr.gg data; never uses the
# cache. Branch/PR runs reuse fixtures cached by earlier runs in the
# same PR (within a 2h TTL), falling back to live fetches for anything
# missing, so the check is correct even with a partially-stale cache.
- name: Run MDX examples check (main, live)
if: github.ref_name == 'main'
run: uv run scripts/check_mdx_examples.py --live
# actions/cache v6.1.0, pinned to a reviewed commit SHA.
- name: Restore fixture cache (branch)
id: mdx-fixtures
if: github.ref_name != 'main'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
with:
path: fixtures.tar.gz
key: mdx-fixtures-${{ github.ref_name }}-run-${{ github.run_id }}
restore-keys: |
mdx-fixtures-${{ github.ref_name }}-
- name: Unpack fixtures (branch)
if: github.ref_name != 'main'
run: |
if [ -f fixtures.tar.gz ]; then
mkdir -p .cache
tar -C .cache -xzf fixtures.tar.gz
fi
- name: Check fixture cache age (branch, 2h TTL)
id: cache-age
if: github.ref_name != 'main'
run: |
matched="${{ steps.mdx-fixtures.outputs.cache-matched-key }}"
now=$(date +%s)
if [ -n "$matched" ]; then
epoch="${matched##*-}"
age=$(( now - epoch ))
else
age=999999
fi
if [ "$age" -gt 7200 ]; then
rm -rf .cache/mdx-html
rm -f fixtures.tar.gz
mkdir -p .cache/mdx-html
echo "fresh=false" >> "$GITHUB_OUTPUT"
else
echo "fresh=true" >> "$GITHUB_OUTPUT"
fi
echo "now=$now" >> "$GITHUB_OUTPUT"
- name: Run MDX examples check (branch)
if: github.ref_name != 'main'
run: |
if [ "${{ steps.cache-age.outputs.fresh }}" == "true" ]; then
uv run scripts/check_mdx_examples.py --skip-warm
else
uv run scripts/check_mdx_examples.py
fi
# always(): a run that fails validation still saved its warm fixtures,
# so the next fix commit restores and validates fast instead of warming.
- name: Package fixtures (branch)
if: always() && github.ref_name != 'main' && steps.cache-age.outputs.fresh == 'false'
run: |
mkdir -p .cache/mdx-html
if [ -n "$(ls -A .cache/mdx-html)" ]; then
tar -C .cache -czf fixtures.tar.gz mdx-html
else
rm -f fixtures.tar.gz
fi
- name: Save fixture cache (branch)
if: always() && github.ref_name != 'main' && steps.cache-age.outputs.fresh == 'false'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
with:
path: fixtures.tar.gz
key: mdx-fixtures-${{ github.ref_name }}-${{ steps.cache-age.outputs.now }}