diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 85dbef0..00cdc7d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,12 +27,13 @@ jobs: matrix: os: [ "ubuntu-latest" ] python-version: [ "3.8", "3.13" ] - grafana-version: [ "6.7.6", "7.5.17", "8.5.27", "9.5.18", "10.3.5", "10.4.1", "11.2.2" ] + grafana-version: [ "6.7.6", "7.5.17", "8.5.27", "9.5.21", "10.3.12", "10.4.14", "11.4.0" ] env: OS_TYPE: ${{ matrix.os }} PYTHON_VERSION: ${{ matrix.python-version }} GRAFANA_VERSION: ${{ matrix.grafana-version }} + UV_SYSTEM_PYTHON: true name: Python ${{ matrix.python-version }}, Grafana ${{ matrix.grafana-version }} steps: @@ -40,7 +41,7 @@ jobs: - name: Acquire sources uses: actions/checkout@v4 - - name: Setup Python + - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -48,10 +49,18 @@ jobs: cache: 'pip' cache-dependency-path: 'setup.py' - - name: Setup Project + - name: Set up uv + uses: astral-sh/setup-uv@v4 + with: + cache-dependency-glob: | + setup.py + cache-suffix: ${{ matrix.python-version }} + enable-cache: true + version: "latest" + + - name: Set up project run: | - pip install pip 'setuptools>=64' --upgrade - pip install --editable='.[test]' + uv pip install --editable='.[test]' - name: Run tests run: | diff --git a/.gitignore b/.gitignore index c5d3f39..2fa4dee 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /.idea /.venv* /var +/build /dist .coverage coverage.xml diff --git a/Dockerfile b/Dockerfile index 9cccc6e..f9a4fed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,42 @@ -FROM python:3.11-slim-bullseye +# ----- +# Build +# ----- +FROM python:3.13-bookworm AS build +# For more verbose output, use: +# export BUILDKIT_PROGRESS=plain + +# Configure operating system ENV DEBIAN_FRONTEND=noninteractive ENV TERM=linux -# Install prerequisites -RUN apt-get update -RUN apt-get --yes install jq +# Configure build environment +ENV PIP_ROOT_USER_ACTION=ignore +ENV UV_COMPILE_BYTECODE=true +ENV UV_LINK_MODE=copy +ENV UV_PYTHON_DOWNLOADS=never + +# Provide package sources +COPY . /src + +# Install package and dependencies +RUN \ + --mount=type=cache,id=pip,target=/root/.cache/pip \ + --mount=type=cache,id=uv,target=/root/.cache/uv \ + true \ + && pip install uv \ + && uv venv --no-project --relocatable /app \ + && uv pip install --directory=/app /src + +# Install optional software +RUN wget --quiet --output-document=/tmp/jq "https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64" +RUN chmod +x /tmp/jq -# Provide sources -COPY . /app -# Install package -WORKDIR /app -RUN pip install --prefer-binary . +# ------------ +# Distribution +# ------------ +FROM python:3.13-slim-bookworm +COPY --from=build /app /opt/grafana-wtf +COPY --from=build /tmp/jq /usr/local/bin/jq +ENV PATH="$PATH:/opt/grafana-wtf/bin" diff --git a/README.rst b/README.rst index 0d5f1f7..43f4fc7 100644 --- a/README.rst +++ b/README.rst @@ -41,9 +41,8 @@ grafana-wtf ***** About ***** -grafana-wtf - grep through all Grafana entities in the spirit of `git-wtf`_. - -.. _git-wtf: http://thrawn01.org/posts/2014/03/03/git-wtf/ +grafana-wtf - grep through all Grafana entities in the spirit of `git-wtf`_, +see also `Introduction to GIT WTF`_. .. attention:: @@ -112,7 +111,7 @@ Install ``grafana-wtf`` ======================= :: - pip install grafana-wtf + pipx install grafana-wtf Configure Grafana @@ -277,4 +276,6 @@ Development pytest --keepalive -vvv -k test_find_textual +.. _git-wtf: https://github.com/DanielVartanov/willgit/blob/master/bin/git-wtf .. _grafana-wtf examples: https://github.com/grafana-toolbox/grafana-wtf/blob/main/doc/examples.rst +.. _Introduction to GIT WTF: https://web.archive.org/web/20230921074244/https://thrawn01.org/posts/2014/03/03/git-wtf/