Skip to content

Add support to decompress zstd #2628

Add support to decompress zstd

Add support to decompress zstd #2628

Workflow file for this run

name: CI
run-name: "${{ github.event_name == 'workflow_dispatch' && format('CI: {0}', github.ref_name) || '' }}"
on:
push:
branches:
- dev
pull_request:
release:
types: [published]
workflow_dispatch:
env:
ADDITIONAL_PYTHON_VERSIONS: "[]"
concurrency:
group: ${{ github.workflow }}-${{ (github.event_name == 'release' && github.run_id) || github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
info:
name: Collect information & prepare
outputs:
default_python_version: ${{ steps.info.outputs.default_python_version }}
python_versions: ${{ steps.info.outputs.python_versions }}
runs-on: ubuntu-latest
steps:
- name: ‡️ Check out code from GitHub
uses: actions/[email protected]
- name: Collect information
id: info
run: |
default_python_version=$(cat .python-version)
echo "default python version: ${default_python_version}"
echo "default_python_version=${default_python_version}" >> $GITHUB_OUTPUT
# Ensure ADDITIONAL_PYTHON_VERSIONS is properly initialized
ADDITIONAL_PYTHON_VERSIONS=${ADDITIONAL_PYTHON_VERSIONS:-"[]"}
# Check if ADDITIONAL_PYTHON_VERSIONS contains default_python_version
if [[ ! ${ADDITIONAL_PYTHON_VERSIONS} == *"${default_python_version}"* ]]; then
# Handle empty or "[]" case properly
if [[ ${ADDITIONAL_PYTHON_VERSIONS} == "[]" ]]; then
all_python_versions="['${default_python_version}']"
elif [[ -z ${ADDITIONAL_PYTHON_VERSIONS} ]]; then
all_python_versions="['${default_python_version}']"
else
all_python_versions="[${ADDITIONAL_PYTHON_VERSIONS:1:-1}, '${default_python_version}']"
fi
else
all_python_versions="${ADDITIONAL_PYTHON_VERSIONS}"
fi
echo "python_versions: ${all_python_versions}"
echo "python_versions=${all_python_versions}" >> $GITHUB_OUTPUT
- name: πŸ— Install uv
uses: astral-sh/setup-uv@v5
- name: Generate requirements files
run: |
uv export --no-hashes --no-dev --group test --no-emit-project > requirements-test.txt
uv export --no-hashes --group dev --no-emit-project > requirements-dev.txt
- name: Upload requirements-test.txt
uses: actions/upload-artifact@v4
with:
name: requirements-test.txt
path: requirements-test.txt
- name: Upload requirements-dev.txt
uses: actions/upload-artifact@v4
with:
name: requirements-dev.txt
path: requirements-dev.txt
python-code-quality:
runs-on: "ubuntu-latest"
name: Check Python code quality
steps:
- name: ‡️ Checkout repository
uses: actions/checkout@v4
- name: πŸ— Install uv and Python
uses: astral-sh/setup-uv@v5
- name: πŸ— Install the project
run: uv sync --locked --group lint
# Following steps cannot run by pre-commit.ci as repo = local
- name: Run mypy
run: uv run --frozen mypy deebot_client/
- name: Pylint review
run: uv run --frozen pylint deebot_client/**/*.py
- name: Verify no getLogger usages
run: scripts/check_getLogger.sh
rust-code-quality:
runs-on: "ubuntu-latest"
name: Check Rust code quality
env:
RUSTFLAGS: "-Dwarnings"
steps:
- name: ‡️ Checkout repository
uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt,clippy
- name: Rust format
uses: actions-rust-lang/rustfmt@v1
- uses: clechasseur/rs-clippy-check@v4
with:
args: --all-features
tests:
name: Execute tests
runs-on: ubuntu-latest
needs:
- info
- python-code-quality
- rust-code-quality
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(needs.info.outputs.python_versions) }}
steps:
- name: ‡️ Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: πŸ— Install uv and Python
uses: astral-sh/setup-uv@v5
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
override: true
components: llvm-tools
cache-key: ${{ matrix.python-version }}
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: Download requirements-dev.txt
uses: actions/download-artifact@v4
with:
name: requirements-dev.txt
- name: Prepare env and install requirements
shell: bash
run: |
uv venv -p ${{ matrix.python-version }}
uv pip install --system -r requirements-dev.txt
- name: Execute tests
id: tests
run: |
source .venv/bin/activate
source <(cargo llvm-cov show-env --export-prefix)
export CARGO_TARGET_DIR=$CARGO_LLVM_COV_TARGET_DIR
export CARGO_INCREMENTAL=1
cargo llvm-cov clean --workspace
cargo test
maturin develop --uv
pytest tests --cov=deebot_client --cov-report xml --junitxml=junit.xml -o junit_family=legacy -v
cargo llvm-cov --no-run --lcov --output-path coverage.lcov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
disable_telem: true
files: coverage.lcov,coverage.xml
- name: Upload test results to Codecov
if: ${{ !cancelled() && steps.tests.outcome == 'success' }}
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true
verbose: true
build-test-native:
name: ${{ matrix.platform.name }} ${{ matrix.platform.target }} ${{ matrix.python-version }}
runs-on: ${{ matrix.platform.runner }}
needs:
- info
- tests
strategy:
fail-fast: false
matrix:
include:
- name: Linux
manylinux: manylinux_2_34
- name: Macos
pytest_args: -m "not docker"
platform:
- name: Linux
runner: ubuntu-latest
target: x86_64
- name: Linux
runner: ubuntu-24.04-arm
target: aarch64
- name: Windows
runner: windows-latest
target: x64
- name: Macos
runner: macos-13
target: x86_64
- name: Macos
runner: macos-14
target: aarch64
python-version: ${{ fromJSON(needs.info.outputs.python_versions) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ (matrix.platform.name == 'Windows') && matrix.platform.target || '' }}
- name: πŸ— Set package version
if: ${{ matrix.platform.name != 'Windows' && github.event_name == 'release' }}
run: |
sed -i.bak "s/^version = \".*\"/version = \"${{ github.event.release.tag_name }}\"/" pyproject.toml && rm pyproject.toml.bak
- name: πŸ— Set package version (Windows)
if: ${{ matrix.platform.name == 'Windows' && github.event_name == 'release' }}
run: |
(Get-Content pyproject.toml) -replace 'version = ".*"', 'version = "${{ github.event.release.tag_name }}"' | Set-Content pyproject.toml
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --strip --out dist -i python${{ matrix.python-version }}
sccache: "false"
manylinux: ${{ matrix.manylinux }}
before-script-linux: python3 -m ensurepip
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform.name }}-${{ matrix.platform.target }}-${{ matrix.python-version }}
path: dist
- name: πŸ— Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Download requirements-test.txt
uses: actions/download-artifact@v4
with:
name: requirements-test.txt
- name: Prepare env and install wheel
shell: bash
run: |
# Remove sources otherwise pytest will complain about missing rust files
rm -rf deebot_client
uv venv -p ${{ matrix.python-version }}
uv pip install -r requirements-test.txt
uv pip install --force-reinstall dist/deebot_client-*.whl
- name: Run pytest
if: ${{ matrix.platform.name != 'Windows' }}
id: pytest
run: |
source .venv/bin/activate
pytest tests -v ${{ matrix.pytest_args || ''}}
- name: Run pytest (windows)
if: ${{ matrix.platform.name == 'Windows' }}
id: pytest_windows
run: |
.venv/Scripts/activate
pytest tests -v -m "not docker"
build-test-musl:
name: Musllinux ${{ matrix.platform.target }} ${{ matrix.python-version }}
runs-on: ${{ matrix.platform.os || 'ubuntu-latest' }}
needs:
- info
- tests
strategy:
fail-fast: false
matrix:
platform:
- target: x86_64
docker_arch: amd64
- target: aarch64
docker_arch: arm64
os: ubuntu-24.04-arm
- target: armv7
docker_arch: arm/v7
os: ubuntu-24.04-arm
qemu: true
- target: x86
docker_arch: 386
qemu: true
python-version: ${{ fromJSON(needs.info.outputs.python_versions) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: πŸ— Set package version
if: ${{ github.event_name == 'release' }}
run: |
sed -i "s/^version = \".*\"/version = \"${{ github.event.release.tag_name }}\"/" pyproject.toml
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --strip --out dist -i python${{ matrix.python-version }}
sccache: "false"
manylinux: musllinux_1_2
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-musllinux-${{ matrix.platform.target }}-${{ matrix.python-version }}
path: dist
- name: Download requirements-test.txt
uses: actions/download-artifact@v4
with:
name: requirements-test.txt
- name: Install Qemu
if: ${{ matrix.platform.qemu || false }}
uses: docker/setup-qemu-action@v3
- name: Install Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
file: ci/Dockerfile.alpine
platforms: linux/${{ matrix.platform.docker_arch }}
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
tags: deebot_client:${{ matrix.platform.target }}-${{ matrix.python-version }}
- name: Pytest in docker
id: pytest
run: |
docker run --rm -v ${{ github.workspace }}:/github/workspace --platform linux/${{ matrix.platform.docker_arch }} deebot_client:${{ matrix.platform.target }}-${{ matrix.python-version }}
benchmarks:
runs-on: "ubuntu-latest"
name: Run benchmarks
if: ${{ github.event_name != 'release' }}
needs:
- build-test-native
- build-test-musl
- sdist
steps:
- name: ‡️ Checkout repository
uses: actions/checkout@v4
- name: πŸ— Install uv
uses: astral-sh/setup-uv@v5
- name: πŸ— Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ needs.info.outputs.default_python_version }}
- name: Download requirements-test.txt
uses: actions/download-artifact@v4
with:
name: requirements-test.txt
- name: πŸ— Install the project
run: |
uv pip install -e . --system -r requirements-test.txt
- name: Run benchmarks
uses: CodSpeedHQ/action@main
with:
run: pytest tests/ --codspeed
token: ${{ secrets.CODSPEED_TOKEN }}
sdist:
name: Create source distribution
runs-on: ubuntu-latest
needs: tests
steps:
- name: ‡️ Check out code from GitHub
uses: actions/[email protected]
- name: πŸ— Set up uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: πŸ— Set package version
if: ${{ github.event_name == 'release' }}
run: |
sed -i "s/^version = \".*\"/version = \"${{ github.event.release.tag_name }}\"/" pyproject.toml
- name: πŸ“¦ Build source package
run: uv build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist
release:
name: Releasing to PyPi
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
needs:
- build-test-native
- build-test-musl
- sdist
environment:
name: release
url: https://pypi.org/p/deebot-client
permissions:
contents: write
id-token: write
steps:
- name: ‡️ Check out code from GitHub
uses: actions/[email protected]
- name: ⬇️ Download wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: πŸš€ Publish to PyPi
uses: pypa/[email protected]
with:
verbose: true
print-hash: true
- name: ✍️ Sign published artifacts
uses: sigstore/[email protected]
with:
inputs: ./dist/*.tar.gz ./dist/*.whl
release-signing-artifacts: true