all: && sync reformat lint test

sync:
    uv sync --all-extras

reformat:
    uv run ruff format
    uv run ruff check --fix

lint:
    uv run ruff format --check
    uv run ruff check
    uv run mypy

test:
    # uv run pytest -svv --log-cli-level=DEBUG --runintegration
    uv run pytest -svv --runintegration

install-gh:
    (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
    && sudo mkdir -p -m 755 /etc/apt/keyrings \
    && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
    && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
    && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
    && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
    && sudo apt update \
    && sudo apt install gh -y

download-kythe:
    mkdir -p scripts/gzs/kythe
    docker pull ghcr.io/aixcc-finals/buttercup-kythe:main
    docker create --name temp-kythe ghcr.io/aixcc-finals/buttercup-kythe:main
    docker cp temp-kythe:/kythe-v0.0.67.tar.gz scripts/gzs/
    docker rm temp-kythe
    tar xvzf scripts/gzs/kythe-v0.0.67.tar.gz -C scripts/gzs/kythe/ --strip-components=1
    rm scripts/gzs/kythe-v0.0.67.tar.gz
