Unverified Commit b273b71a authored by github-actions[bot]'s avatar github-actions[bot] Committed by GitHub
Browse files

Pin uv 0.10.0, add Taskfile and pre-push hook, improve tests (#192)



* Pin uv 0.10.0, add Taskfile and pre-push hook, improve tests

- Pin uv version to 0.10.0 instead of latest
- Add Taskfile.yml with build/test/setup tasks
- Add .githooks/pre-push to run tests before push
- Rewrite test/main.py: remove flaky network calls, add assertions,
  use Flask test client, exit with non-zero code on failure

Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>

* Use Taskfile in CI for Linux image tests

Replace build-and-test.sh with task test:linux/test:linux-slim in CI
workflow. This adds binary verification and keeps CI in sync with
local pre-push hook.

Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>

* Remove build-and-test.sh, use Taskfile for all CI tests

- Add build:windows and test:windows tasks to Taskfile
- Migrate windows CI job to use task test:windows
- Update commented-out osx CI job to reference Taskfile
- Include windows in `task test` (all images)
- Delete build-and-test.sh

Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>

* Fix multi-platform builds: uv on amd64/arm64, pip fallback on others

COPY --from=ghcr.io/astral-sh/uv fails on platforms not in the uv manifest
(386, arm/v5, arm/v7, s390x, ppc64le, riscv64). Replace with conditional
install via TARGETARCH: pip-install uv on amd64/arm64, plain pip elsewhere.
Entrypoint detects uv at runtime for requirements and PyPI mirror config.

Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>

* Pin arduino/setup-task to full commit SHA for Sonar S7637

Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: default avatarФедор Батоногов <fekinos@me.com>
Co-authored-by: default avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 40922c11
Loading
Loading
Loading
Loading

.githooks/pre-push

0 → 100755
+15 −0
Original line number Diff line number Diff line
#!/bin/bash

set -e

echo "Running Docker build & test before push..."

if ! command -v task &>/dev/null; then
    echo "Error: 'task' (go-task) is not installed. Skipping tests."
    echo "Install: https://taskfile.dev/installation/"
    exit 0
fi

task test

echo "All tests passed."
+20 −12
Original line number Diff line number Diff line
@@ -12,37 +12,45 @@ jobs:
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v6.0.2
      - name: Install Task
        uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
        with:
          version: 3.x
      - name: Run Tests
        run: |
          echo "Building image to test"
          ./build-and-test.sh Dockerfile-py3-windows
        run: task test:windows

  linux:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v6.0.2
      - name: Install Task
        uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
        with:
          version: 3.x
      - name: Run Tests
        run: |
          echo "Building image to test"
          ./build-and-test.sh Dockerfile-py3-linux
        run: task test:linux

  linux-slim:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v6.0.2
      - name: Install Task
        uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
        with:
          version: 3.x
      - name: Run Tests
        run: |
          echo "Building image to test"
          ./build-and-test.sh Dockerfile-py3-linux-slim
        run: task test:linux-slim

  # osx:
  #   runs-on: ubuntu-latest
  #   steps:
  #     - name: Checkout Repo
  #       uses: actions/checkout@v6.0.2
  #     - name: Install Task
  #       uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
  #       with:
  #         version: 3.x
  #     - name: Run Tests
  #       run: |
  #         echo "Building image to test"
  #         ./build-and-test.sh Dockerfile-py3-osx
  #       run: task test:osx
+9 −6
Original line number Diff line number Diff line
@@ -15,12 +15,15 @@ ENV PYTHONUNBUFFERED=1
# Copy the entrypoint script
COPY entrypoint-linux.sh /entrypoint.sh

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/

# Install dependencies, PyInstaller, and set execute permissions for the entrypoint
RUN uv pip install --system --no-cache pyinstaller==$PYINSTALLER_VERSION \
    && chmod +x /entrypoint.sh
# Install PyInstaller (use uv on amd64/arm64, pip on other platforms)
ARG TARGETARCH
RUN if [ "$TARGETARCH" = "amd64" ] || [ "$TARGETARCH" = "arm64" ]; then \
        pip install --no-cache-dir uv==0.10.0 && \
        uv pip install --system --no-cache pyinstaller==$PYINSTALLER_VERSION; \
    else \
        pip install --no-cache-dir pyinstaller==$PYINSTALLER_VERSION; \
    fi && \
    chmod +x /entrypoint.sh

# Set the working directory and mount the volume
VOLUME /src/
+7 −4
Original line number Diff line number Diff line
@@ -17,17 +17,20 @@ ENV PYTHONUNBUFFERED=1
# Copy entrypoint script early to ensure it's available before dependency installation
COPY entrypoint-linux.sh /entrypoint.sh

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/

# Install dependencies and PyInstaller in a single RUN command to reduce image layers
ARG TARGETARCH
RUN apt update && \
    apt install --no-install-recommends -y \
        binutils \
        gcc \
        zlib1g-dev && \
    rm -rf /var/lib/apt/lists/* && \
    uv pip install --system --no-cache pyinstaller==$PYINSTALLER_VERSION && \
    if [ "$TARGETARCH" = "amd64" ] || [ "$TARGETARCH" = "arm64" ]; then \
        pip install --no-cache-dir uv==0.10.0 && \
        uv pip install --system --no-cache pyinstaller==$PYINSTALLER_VERSION; \
    else \
        pip install --no-cache-dir pyinstaller==$PYINSTALLER_VERSION; \
    fi && \
    chmod +x /entrypoint.sh

# Set the working directory and create a volume for source code

Taskfile.yml

0 → 100644
+53 −0
Original line number Diff line number Diff line
version: '3'

vars:
  TEST_DIR: ./test
  IMAGE_PREFIX: pyinstaller-test

tasks:
  build:windows:
    desc: Build Windows image
    cmds:
      - docker build -f Dockerfile-py3-windows -t {{.IMAGE_PREFIX}}-windows .

  build:linux:
    desc: Build Linux image
    cmds:
      - docker build -f Dockerfile-py3-linux -t {{.IMAGE_PREFIX}}-linux .

  build:linux-slim:
    desc: Build Linux slim image
    cmds:
      - docker build -f Dockerfile-py3-linux-slim -t {{.IMAGE_PREFIX}}-linux-slim .

  test:windows:
    desc: Build and test Windows image
    cmds:
      - task: build:windows
      - docker run --rm -v "$(pwd)/{{.TEST_DIR}}:/src/" {{.IMAGE_PREFIX}}-windows "pyinstaller main.py --onefile"

  test:linux:
    desc: Build and test Linux image
    cmds:
      - task: build:linux
      - docker run --rm -v "$(pwd)/{{.TEST_DIR}}:/src/" {{.IMAGE_PREFIX}}-linux "pyinstaller main.py --onefile"
      - docker run --rm -v "$(pwd)/{{.TEST_DIR}}:/src/" {{.IMAGE_PREFIX}}-linux ./dist/main

  test:linux-slim:
    desc: Build and test Linux slim image
    cmds:
      - task: build:linux-slim
      - docker run --rm -v "$(pwd)/{{.TEST_DIR}}:/src/" {{.IMAGE_PREFIX}}-linux-slim "pyinstaller main.py --onefile"
      - docker run --rm -v "$(pwd)/{{.TEST_DIR}}:/src/" {{.IMAGE_PREFIX}}-linux-slim ./dist/main

  test:
    desc: Build and test all images
    cmds:
      - task: test:windows
      - task: test:linux
      - task: test:linux-slim

  setup:
    desc: Configure git hooks
    cmds:
      - git config core.hooksPath .githooks
Loading