-
-
Notifications
You must be signed in to change notification settings - Fork 16
109 lines (90 loc) · 4.58 KB
/
Copy pathtest-reproducibility.yml
File metadata and controls
109 lines (90 loc) · 4.58 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
name: test-reproducibility
on:
workflow_call:
jobs:
test-reproducibility:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: setup-mise
uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0
- name: cache-venv
env:
CACHE_KEY_PREFIX: venv-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
CACHE_KEY_DEPS: ${{ hashFiles('uv.lock') }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.local/share/uv
~/.cache/uv
${{ github.workspace }}/.venv
key: ${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-${{ github.run_id }}-
${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-
${{ env.CACHE_KEY_PREFIX }}-
- name: install-dependencies
run: uv sync --all-extras --all-groups --frozen
- name: setup-path
run: echo "${{ github.workspace }}/.venv/bin" >> "$GITHUB_PATH"
- name: cache-graphviz
id: cache-graphviz
env:
CACHE_KEY_PREFIX: graphviz-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/graphviz-cache
key: ${{ env.CACHE_KEY_PREFIX }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
${{ env.CACHE_KEY_PREFIX }}-${{ github.run_id }}-
${{ env.CACHE_KEY_PREFIX }}-
- name: install-graphviz
run: |
if [ "${{ steps.cache-graphviz.outputs.cache-hit }}" = "true" ]; then
sudo cp ~/graphviz-cache/bin/* /usr/bin/ 2>/dev/null || true
sudo cp ~/graphviz-cache/lib/* /usr/lib/x86_64-linux-gnu/ 2>/dev/null || true
sudo cp -r ~/graphviz-cache/share/graphviz /usr/share/ 2>/dev/null || true
sudo cp -r ~/graphviz-cache/lib/graphviz /usr/lib/x86_64-linux-gnu/ 2>/dev/null || true
sudo ldconfig
sudo dot -c
else
sudo apt-get update
sudo apt-get install -y graphviz
mkdir -p ~/graphviz-cache/{bin,lib,share}
cp /usr/bin/{dot,neato,twopi,circo,fdp,sfdp,patchwork,osage} ~/graphviz-cache/bin/ 2>/dev/null || true
cp /usr/lib/x86_64-linux-gnu/lib{gvc,cgraph,cdt,pathplan,gvpr,lab-gamut,ann,gts}* ~/graphviz-cache/lib/ 2>/dev/null || true
cp -r /usr/lib/x86_64-linux-gnu/graphviz ~/graphviz-cache/lib/ 2>/dev/null || true
cp -r /usr/share/graphviz ~/graphviz-cache/share/ 2>/dev/null || true
fi
- name: check-test-case-count
run: bake check-test-cases
- name: backup-existing-problems
run: |
mkdir -p .cache
cp -r leetcode .cache/
- name: delete-existing-problems
run: rm -rf leetcode/*/
- name: regenerate-all-problems-from-templates
run: bake gen-all-problems --force
env:
# Skip interactive confirmation
CI: true
- name: run-linting-to-verify-reproducibility
run: bake lint
- name: convert-notebooks-to-python
run: bake nb-to-py
- name: run-linting-to-verify-reproducibility-after-convert-nb-to-py
run: bake lint
- name: check-consistency-with-json
run: bake check-consistency --backup .cache/leetcode
- name: copy-solution-files-from-backup
run: |
for problem in .cache/leetcode/*/; do
problem_name=$(basename "$problem")
if [ -f "$problem/solution.py" ] && [ -d "leetcode/$problem_name" ]; then
cp "$problem/solution.py" "leetcode/$problem_name/solution.py"
fi
done
- name: run-tests
run: bake test