Commit 88f86c0f authored by Fedor Batonogov's avatar Fedor Batonogov
Browse files

Improve test infrastructure and fix CI issues

- Fix VC++ Redist filename case mismatch in Dockerfile (VC_redist → vc_redist)
- Fix greetings workflow input names for first-interaction v3.1.0
- Rework test workflow: Docker Buildx with GHA cache, pull_request trigger, binary verification
- Add psutil and requests checks to test suite
- Add Windows binary verification via Wine in Taskfile
parent 011aa18b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -11,6 +11,6 @@ jobs:
    steps:
      - uses: actions/first-interaction@v3.1.0
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          issue-message: 🎉 Thank you for your first issue! We will look into it soon.
          pr-message: 🚀 Thank you for your first pull request! It helps improve our project.
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          issue_message: 🎉 Thank you for your first issue! We will look into it soon.
          pr_message: 🚀 Thank you for your first pull request! It helps improve our project.
+81 −27
Original line number Diff line number Diff line
@@ -5,6 +5,9 @@ on:
    branches:
      - '*'
      - '!main'
  pull_request:
    branches:
      - main

jobs:
  windows:
@@ -12,45 +15,96 @@ jobs:
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v6.0.2
      - name: Install Task
        uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0

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

      - name: Build Windows image
        uses: docker/build-push-action@v6
        with:
          version: 3.x
      - name: Run Tests
        run: task test:windows
          context: .
          file: Dockerfile-py3-windows
          tags: pyinstaller-test-windows:latest
          load: true
          cache-from: type=gha,scope=windows
          cache-to: type=gha,mode=max,scope=windows

      - name: Build binary with PyInstaller
        run: >
          docker run --rm
          -v "$(pwd)/test:/src/"
          pyinstaller-test-windows:latest
          "pyinstaller main.py --onefile"

      - name: Verify Windows binary with Wine
        run: >
          docker run --rm
          -v "$(pwd)/test:/src/"
          pyinstaller-test-windows:latest
          "wine C:/src/dist/main.exe"

  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

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

      - name: Build Linux image
        uses: docker/build-push-action@v6
        with:
          version: 3.x
      - name: Run Tests
        run: task test:linux
          context: .
          file: Dockerfile-py3-linux
          tags: pyinstaller-test-linux:latest
          load: true
          cache-from: type=gha,scope=linux
          cache-to: type=gha,mode=max,scope=linux

      - name: Build binary with PyInstaller
        run: >
          docker run --rm
          -v "$(pwd)/test:/src/"
          pyinstaller-test-linux:latest
          "pyinstaller main.py --onefile"

      - name: Verify Linux binary
        run: >
          docker run --rm
          -v "$(pwd)/test:/src/"
          pyinstaller-test-linux:latest
          ./dist/main

  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

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

      - name: Build Linux slim image
        uses: docker/build-push-action@v6
        with:
          version: 3.x
      - name: Run Tests
        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: task test:osx
          context: .
          file: Dockerfile-py3-linux-slim
          tags: pyinstaller-test-linux-slim:latest
          load: true
          cache-from: type=gha,scope=linux-slim
          cache-to: type=gha,mode=max,scope=linux-slim

      - name: Build binary with PyInstaller
        run: >
          docker run --rm
          -v "$(pwd)/test:/src/"
          pyinstaller-test-linux-slim:latest
          "pyinstaller main.py --onefile"

      - name: Verify Linux slim binary
        run: >
          docker run --rm
          -v "$(pwd)/test:/src/"
          pyinstaller-test-linux-slim:latest
          ./dist/main
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ ENV W_TMP="$W_DRIVE_C/windows/temp/_$0"
RUN set -x \
    && rm -f "$W_TMP"/* \
    && wget -P "$W_TMP" https://aka.ms/vs/17/release/vc_redist.x64.exe \
    && cabextract -q --directory="$W_TMP" "$W_TMP"/VC_redist.x64.exe \
    && cabextract -q --directory="$W_TMP" "$W_TMP"/vc_redist.x64.exe \
    && cabextract -q --directory="$W_TMP" "$W_TMP/a10" \
    && cabextract -q --directory="$W_TMP" "$W_TMP/a11" \
    && cd "$W_TMP" \
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ tasks:
    cmds:
      - task: build:windows
      - docker run --rm -v "$(pwd)/{{.TEST_DIR}}:/src/" {{.IMAGE_PREFIX}}-windows "pyinstaller main.py --onefile"
      - docker run --rm -v "$(pwd)/{{.TEST_DIR}}:/src/" {{.IMAGE_PREFIX}}-windows "wine C:/src/dist/main.exe"

  test:linux:
    desc: Build and test Linux image
+20 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@ import sys

import numpy as np
import pandas as pd
import psutil
import requests
from flask import Flask, jsonify
from flask_wtf.csrf import CSRFProtect
from sqlalchemy import create_engine, text
@@ -36,6 +38,22 @@ def check_flask():
    print("Flask OK")


def check_psutil():
    cpu = psutil.cpu_count()
    mem = psutil.virtual_memory()
    assert cpu is not None and cpu > 0, f"Unexpected cpu_count: {cpu}"
    assert mem.total > 0, f"Unexpected virtual_memory total: {mem.total}"
    print(f"psutil OK: {cpu} CPUs, {mem.total // (1024**2)} MB RAM")


def check_requests():
    session = requests.Session()
    assert session is not None
    adapter = session.get_adapter("https://")
    assert adapter is not None
    print("requests OK: Session created")


def check_sqlalchemy():
    engine = create_engine("sqlite:///:memory:")
    with engine.connect() as connection:
@@ -50,6 +68,8 @@ def main():
    check_platform()
    check_numpy_pandas()
    check_flask()
    check_psutil()
    check_requests()
    check_sqlalchemy()
    print("All checks passed")

Loading