Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,26 @@
name: Linters
jobs:
lint:
runs-on: ubuntu-latest
runs-on: ubuntu-26.04
timeout-minutes: 10
steps:
- name: Check out repository code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Run linters
uses: PiwikPRO/actions/python/lint@master
- name: Install uv
uses: astral-sh/setup-uv@eb1897b8dc4b5d5bfe39a428a8f2304605e0983c
with:
use-black: true
use-flake: true
use-isort: true
version: "latest"
enable-cache: true
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Sync dev dependencies
run: uv sync --frozen --group dev-local

- name: Run ruff linting
run: uv run ruff check . --config pyproject.toml

- name: Check ruff formatting
run: uv run ruff format --check . --config pyproject.toml
28 changes: 15 additions & 13 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
name: Build package using various python versions
on:
pull_request:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-26.04
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
name: Tests (Python ${{ matrix.python-version }})
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@eb1897b8dc4b5d5bfe39a428a8f2304605e0983c
with:
version: "latest"
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install poetry
uses: abatilo/actions-poetry@c1aba0c402ae0d96fbb6d94050592a56b202009f
- name: Build and install poetry package
run: poetry build && poetry install
- name: Verify, that import_logs is properly called
run: poetry run piwik_pro_log_analytics --help
enable-cache: true
cache-dependency-glob: |
pyproject.toml
uv.lock
- name: Sync environment and build package
run: uv sync --frozen --no-dev && uv build
- name: Verify import_logs CLI
run: uv run piwik_pro_log_analytics --help
timeout-minutes: 30
116 changes: 61 additions & 55 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,70 +1,76 @@
---
"on":
pull_request:
push:
tags: ["**"]

pull_request:
push:
tags: ["**"]

name: Release
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v2
docker:
runs-on: ubuntu-26.04
permissions:
contents: read
packages: write
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@f211e3e9ded2d9377c8cadc4489a4e38014bc4c9
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@f211e3e9ded2d9377c8cadc4489a4e38014bc4c9

- name: Login to Github Packages
uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Github Packages
uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get docker metadata
id: meta
uses: docker/metadata-action@9be43f076db7f0f4ac30d81183fc9d956b9e9eb6
with:
images: ghcr.io/PiwikPRO/log-analytics
- name: Get docker metadata
id: meta
uses: docker/metadata-action@9be43f076db7f0f4ac30d81183fc9d956b9e9eb6
with:
images: ghcr.io/PiwikPRO/log-analytics

- name: Build image and push to GCR
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build image and push to GCR
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

pypi:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out repository code
uses: actions/checkout@v2
pypi:
runs-on: ubuntu-26.04
timeout-minutes: 20
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
architecture: x64

- name: Install poetry
uses: abatilo/actions-poetry@c1aba0c402ae0d96fbb6d94050592a56b202009f
- name: Install uv
uses: astral-sh/setup-uv@eb1897b8dc4b5d5bfe39a428a8f2304605e0983c
with:
version: "latest"
python-version: "3.12"
enable-cache: true
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Update package version to current tag
if: ${{ github.ref_type == 'tag' }}
run: sed -i -e '/version =/ s/= .*/= "${{ github.ref_name }}"/' pyproject.toml
- name: Update package version to current tag
if: ${{ github.ref_type == 'tag' }}
run: sed -i -e '/^version =/ s/= .*/= "${{ github.ref_name }}"/' pyproject.toml

- name: Build and install poetry package
run: poetry build && poetry install
- name: Build distributions
run: uv build

- name: Push the package to PyPi
if: ${{ github.ref_type == 'tag' }}
run: poetry publish --username __token__ --password ${{ secrets.PYPI_TOKEN }}
- name: Push the package to PyPI
if: ${{ github.ref_type == 'tag' }}
run: uv publish --token ${{ secrets.PYPI_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-26.04
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
name: Tests (Python ${{ matrix.python-version }})
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Unreleased]

- PPPSYS-56851 Require Python 3.10 or newer (3.9 and older are end-of-life); CI tests 3.10 through 3.14
- PPPSYS-56851 Migrated packaging and CI from Poetry to uv (PEP 621, setuptools, committed `uv.lock`); PyPI releases use `uv publish`.
- PPPSYS-56851 Added local multi-version testing with tox (`tox.ini`, environments `py310`–`py314` aligned with CI); optional `dev-local` uv dependency group installs tox and tox-uv (see README).
- PPPSYS-56851 Replaced legacy Black/Flake8/isort GitHub Action with **Ruff** (`ruff check` / `ruff format --check` in CI; configuration in `pyproject.toml`).

## [5.2.1] - 2023-11-09

- PPPSYS-44518 Converted int values like `gt_ms` to strings
Expand Down
30 changes: 25 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
FROM ubuntu:focal
FROM ubuntu:26.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y python3.8 wget fuse libcurl3-gnutls vim sleepenh
&& apt-get install -y --no-install-recommends \
python3 \
python3-minimal \
wget \
ca-certificates \
vim \
sleepenh \
&& rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/python3.8 /usr/bin/python \
RUN ln -sf /usr/bin/python3 /usr/bin/python \
&& mkdir /tmp/blobfuse /tmp/blobfusetmp

RUN wget https://github.com/Azure/azure-storage-fuse/releases/download/blobfuse-1.4.1/blobfuse-1.4.1-ubuntu-20.04-x86_64.deb \
&& dpkg -i blobfuse-1.4.1-ubuntu-20.04-x86_64.deb
ARG BLOBFUSE2_VERSION=2.5.3
RUN set -eux; \
arch="$(dpkg --print-architecture)"; \
case "$arch" in \
amd64) bf_arch=x86_64 ;; \
arm64) bf_arch=arm64 ;; \
*) echo "unsupported architecture: $arch" >&2; exit 1 ;; \
esac; \
wget -q "https://github.com/Azure/azure-storage-fuse/releases/download/blobfuse2-${BLOBFUSE2_VERSION}/blobfuse2-${BLOBFUSE2_VERSION}-Ubuntu-22.04.${bf_arch}.deb" -O /tmp/blobfuse2.deb; \
apt-get update; \
apt-get install -y --no-install-recommends /tmp/blobfuse2.deb; \
rm -f /tmp/blobfuse2.deb; \
rm -rf /var/lib/apt/lists/*

ADD piwik_pro_log_analytics/import_logs.py /usr/local/bin
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Keep tests out of the source distribution (setuptools otherwise picks them up).
prune tests
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@ Import your web server logs to Piwik PRO.

## Requirements

* Python 3.6+.
* Python 3.10 or newer (3.9 and older are end-of-life).
* Piwik PRO >= 16+, all the versions, including Cloud, Core and On-Premises are supported

## Local tests

The **`dev-local`** dependency group installs [tox](https://tox.wiki/), [pytest](https://docs.pytest.org/), and [tox-uv](https://github.com/tox-dev/tox-uv) so tox creates each Python environment with **uv** (this avoids broken venvs when a uv-managed CPython is first on `PATH`). **Tox** runs the suite under **Python 3.10–3.14** per `tox.ini` (`py310` … `py314`). There is **no committed `.python-version`** pin; **uv** picks a compatible interpreter for the project `.venv`, and you can add a **local** `.python-version` if you want (the file is **gitignored**).

```bash
uv sync --group dev-local
uv run tox
```

Use `uv run tox -e py312` for one version, or `uv run tox -- test_main.py -q` to forward arguments to pytest (paths are relative to `tests/`, same as `./run_tests.sh`). To call pytest without tox: `cd tests && PYTEST_SESSION=1 uv run pytest` (from the repo root, so log fixtures resolve).

If you skip `dev-local`, use `uvx tox` or a globally installed `tox` against this `tox.ini` (install **tox-uv** alongside tox if your default interpreter comes from uv and tox envs fail to start).

Lint and format with [Ruff](https://docs.astral.sh/ruff/) (same style as the Piwik PRO MCP repo): `uv run ruff check .` and `uv run ruff format .` (CI runs `ruff format --check`).

## Getting started

Expand Down
4 changes: 2 additions & 2 deletions piwik_pro_log_analytics/import_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

import sys

if sys.version_info[0] != 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 6):
if sys.version_info[0] != 3 or sys.version_info < (3, 10):
print("The log importer does not support older python versions.")
print("Please use Python 3.6+")
print("Please use Python 3.10 or newer")
sys.exit(1)

import argparse
Expand Down
8 changes: 0 additions & 8 deletions poetry.lock

This file was deleted.

63 changes: 50 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,56 @@
[tool.poetry]
name = "piwik_pro_log_analytics"
readme = "README.md"
# This is managed by Github Actions
[project]
name = "piwik-pro-log-analytics"
# Version is set from the git tag in the release workflow when publishing.
version = "0.0.1"
description = "Allows importing common web server log formats (nginx, apache, iss and more) directly to Piwik PRO. It's Free Software available under GPLv3 license, available on GitHub"
authors = ["Piwik PRO <kosto@piwik.pro>"]
license = "GPL-3.0-or-later"

[tool.poetry.dependencies]
python = ">=3.6"
readme = "README.md"
requires-python = ">=3.10"
license = { text = "GPL-3.0-or-later" }
authors = [{ name = "Piwik PRO", email = "kosto@piwik.pro" }]

[project.scripts]
piwik_pro_log_analytics = "piwik_pro_log_analytics.import_logs:main"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.poetry.scripts]
piwik_pro_log_analytics = "piwik_pro_log_analytics.import_logs:main"
[tool.setuptools]
packages = ["piwik_pro_log_analytics"]

[tool.uv]
package = true

[tool.ruff]
line-length = 120
target-version = "py310"
src = ["piwik_pro_log_analytics", "tests"]

[tool.ruff.lint]
select = [
"E",
"F",
"W",
"I",
"A",
"ERA",
"PL",
"UP",
]
ignore = [
"PLR2004",
"PLR0913",
]

# Legacy importer and tests predate stricter pylint-style and pyupgrade rules.
[tool.ruff.lint.per-file-ignores]
"piwik_pro_log_analytics/import_logs.py" = ["A", "ERA", "PL", "UP"]
"tests/**" = ["A", "ERA", "PL", "UP"]

[dependency-groups]
dev-local = [
"tox>=4.21",
"pytest>=7",
"tox-uv>=1.33.4",
"ruff>=0.12.7",
]
Loading
Loading