From dce608c7fc761786d0eda7689ecb78f7ec58f3bb Mon Sep 17 00:00:00 2001 From: sparklelcm333 Date: Sat, 15 Aug 2026 22:49:44 +0800 Subject: [PATCH] fix(ci): fix skipped pytest --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++---- test/test_crypto_rsa.py | 3 ++- test/test_rsa_crypto_errors.py | 5 ++-- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93e8366..549a921 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,12 +56,48 @@ jobs: runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - - uses: actions/checkout@v6.0.2 - - uses: astral-sh/setup-uv@v8.1.0 + - name: Checkout code + uses: actions/checkout@v6.0.2 + - name: Setup uv + uses: astral-sh/setup-uv@v8.1.0 with: python-version: ${{ matrix.python-version }} - - run: uv sync --group dev - - run: uv run pytest + + - name: Install Linux deps + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y cmake libssl-dev build-essential + - name: Setup Windows toolchain + if: runner.os == 'Windows' + uses: step-security/msvc-dev-cmd@v1 + - name: Install CMake (Win) + if: runner.os == 'Windows' + uses: step-security/get-cmake@v4 + + - name: Cache C build + id: cache-build + uses: actions/cache@v6 + with: + path: build + key: ${{ runner.os }}-build-${{ hashFiles('CMakeLists.txt', 'PyFlow/crypto_api/**/*.c', 'PyFlow/crypto_api/include/**/*.h') }} + - name: Build C lib + if: steps.cache-build.outputs.cache-hit != 'true' + shell: bash + run: | + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCRYPTO_API_BUILD_TESTS=OFF + cmake --build build --config Release --parallel + + - name: Copy OpenSSL DLLs (Windows) + if: runner.os == 'Windows' + shell: cmd + run: | + for /r "C:\Program Files\OpenSSL" %%f in (libcrypto*.dll) do copy "%%f" build\Release\ + + - name: Install Python deps + run: uv sync --group dev + - name: Run pytest + run: uv run pytest coverage: runs-on: ubuntu-latest diff --git a/test/test_crypto_rsa.py b/test/test_crypto_rsa.py index ac59bbe..54b6ee4 100644 --- a/test/test_crypto_rsa.py +++ b/test/test_crypto_rsa.py @@ -71,7 +71,8 @@ def test_generated_keys_land_in_pvt_key(crypto): assert os.path.exists(crypto.pub_path) assert crypto.priv_path.startswith(crypto.pvt_key_dir) assert os.path.dirname(crypto.priv_path) == crypto.pvt_key_dir - assert os.stat(crypto.priv_path).st_mode & 0o077 == 0 # generated private keys must not be world-readable + if sys.platform != "win32": + assert os.stat(crypto.priv_path).st_mode & 0o077 == 0 # generated private keys must not be world-readable def test_ssh_key_is_reused_when_present(tmp_path): diff --git a/test/test_rsa_crypto_errors.py b/test/test_rsa_crypto_errors.py index 62ab80e..59fcb16 100644 --- a/test/test_rsa_crypto_errors.py +++ b/test/test_rsa_crypto_errors.py @@ -160,5 +160,6 @@ def test_save_registry_raises_on_unwritable_dir(tmp_path): os.chmod(ro, 0o500) crypto.pub_key_dir = str(ro) crypto.registry_path = str(ro / "pub_key.json") - with pytest.raises(OSError): - crypto._save_registry({}) + if sys.platform != "win32": + with pytest.raises(OSError): + crypto._save_registry({})