Skip to content

chore(deps): update actions/cache action to v4.3.0 (#65) #117

chore(deps): update actions/cache action to v4.3.0 (#65)

chore(deps): update actions/cache action to v4.3.0 (#65) #117

name: ci
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]
jobs:
test-reproducibility:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.13"
- name: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install --no-interaction --no-ansi
- name: Cache Graphviz installation
id: cache-graphviz
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ~/graphviz-cache
key: graphviz-installed-${{ runner.os }}
- 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: poetry run python -m leetcode_py.tools.check_test_cases --threshold=10 --max=none
- 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: make gen-all-problems FORCE=1
env:
# Skip interactive confirmation
CI: true
- name: Run linting to verify reproducibility
run: make lint
- 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: make test