Unverified Commit 54677cb4 authored by Федор Батоногов's avatar Федор Батоногов Committed by GitHub
Browse files

Update VC++ Redistributable to latest VS 2015-2022 (#199)

* Update VC++ Redistributable to latest VS 2015-2022 version

Replace the hardcoded VS 2017 download URL with the official
aka.ms permalink that always points to the latest release.

Closes #11

* 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

* Fix VC++ Redist extraction for newer versions and pin action SHAs

- Extract all cab files dynamically instead of hardcoding a10/a11
- Pin actions/checkout, docker/setup-buildx-action, docker/build-push-action to full SHA

* Fix VC++ Redist DLL extraction: recursive cab extraction and deep DLL search

* Fix SonarQube code smells: replace identity checks with meaningful assertions

* Fix undefined $0 in W_TMP, pin first-interaction SHA, add DLL extraction guard
parent 08d2c056
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -9,8 +9,8 @@ jobs:
      issues: write
      pull-requests: write
    steps:
      - uses: actions/first-interaction@v3.1.0
      - uses: actions/first-interaction@1c4688942c71f71d4f5502a26ea67c331730fa4d # 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.
+84 −30
Original line number Diff line number Diff line
@@ -5,52 +5,106 @@ on:
    branches:
      - '*'
      - '!main'
  pull_request:
    branches:
      - main

jobs:
  windows:
    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
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0

      - name: Build Windows image
        uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
        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
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0

      - name: Build Linux image
        uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
        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
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0

      - name: Build Linux slim image
        uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
        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
+12 −10
Original line number Diff line number Diff line
@@ -70,18 +70,20 @@ RUN set -x \
ENV W_DRIVE_C=/wine/drive_c
ENV W_WINDIR_UNIX="$W_DRIVE_C/windows"
ENV W_SYSTEM64_DLLS="$W_WINDIR_UNIX/system32"
ENV W_TMP="$W_DRIVE_C/windows/temp/_$0"
ENV W_TMP="$W_DRIVE_C/windows/temp/_vcredist"

# install Microsoft Visual C++ Redistributable for Visual Studio 2017 dll files
# install Microsoft Visual C++ Redistributable for Visual Studio 2015-2022 dll files
RUN set -x \
    && rm -f "$W_TMP"/* \
    && wget -P "$W_TMP" https://download.visualstudio.microsoft.com/download/pr/11100230/15ccb3f02745c7b206ad10373cbca89b/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" \
    && rename 's/_/\-/g' *.dll \
    && cp "$W_TMP"/*.dll "$W_SYSTEM64_DLLS"/
    && rm -rf "$W_TMP" && mkdir -p "$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 \
    # extract nested cab archives from the redistributable
    && for f in "$W_TMP"/*; do cabextract -q --directory="$W_TMP" "$f" 2>/dev/null || true; done \
    # second pass: extract DLLs from the inner cab files
    && for f in "$W_TMP"/*; do cabextract -q --directory="$W_TMP" "$f" 2>/dev/null || true; done \
    && find "$W_TMP" -name '*.dll' | grep -q . || { echo "ERROR: no DLLs extracted from VC++ Redist"; exit 1; } \
    && find "$W_TMP" -name '*.dll' -exec sh -c 'rename "s/_/-/g" "$@"' _ {} + \
    && find "$W_TMP" -name '*.dll' -exec cp {} "$W_SYSTEM64_DLLS"/ \;

# install pyinstaller
RUN /usr/bin/pip install --no-cache-dir pyinstaller==$PYINSTALLER_VERSION
+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 > 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 isinstance(session, requests.Session)
    adapter = session.get_adapter("https://")
    assert isinstance(adapter, requests.adapters.HTTPAdapter)
    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