Skip to content

Commit eae0327

Browse files
committed
ci: add test-reproducibility
1 parent 5815e75 commit eae0327

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
jobs:
10+
test-reproducibility:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
18+
with:
19+
python-version: "3.13"
20+
21+
- name: Install Poetry
22+
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
23+
with:
24+
virtualenvs-create: true
25+
virtualenvs-in-project: true
26+
installer-parallel: true
27+
28+
- name: Load cached venv
29+
id: cached-poetry-dependencies
30+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
31+
with:
32+
path: .venv
33+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
34+
35+
- name: Install dependencies
36+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
37+
run: poetry install --no-interaction --no-ansi
38+
39+
- name: Cache Graphviz
40+
id: cache-graphviz
41+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
42+
with:
43+
path: /usr/bin/dot
44+
key: graphviz-${{ runner.os }}
45+
46+
- name: Install Graphviz
47+
if: steps.cache-graphviz.outputs.cache-hit != 'true'
48+
run: sudo apt-get update && sudo apt-get install -y graphviz
49+
50+
- name: Delete existing problems
51+
run: rm -rf leetcode/*/
52+
53+
- name: Regenerate all problems from templates
54+
run: make gen-all-problems FORCE=1
55+
env:
56+
# Skip interactive confirmation
57+
CI: true
58+
59+
- name: Run linting to verify reproducibility
60+
run: make lint

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ p-del:
8181
# Generate All Problems - useful for people who fork this repo
8282
gen-all-problems:
8383
@echo "This will DELETE all existing problems and regenerate from JSON templates."
84-
@read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
84+
@if [ "$$CI" != "true" ]; then \
85+
read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1; \
86+
fi
8587
@echo "Deleting existing problems..."
8688
@rm -rf leetcode/*/
8789
@echo "Generating all problems..."

0 commit comments

Comments
 (0)