From 2fd70e8ea00e6a70424fdc8183b251b9893b9d5d Mon Sep 17 00:00:00 2001 From: Kesara Rathnayake Date: Sat, 26 Oct 2024 12:49:37 +1300 Subject: [PATCH] ci: Enable tests on Windows OS (#1177) * ci: Enable tests on Windows OS * ci: Install fonts on windows with font-install * test: Skip PDF tests on Windows OS * ci: Run only pytests on Windows --- .github/workflows/checks.yml | 78 +++++++++++++++--------------------- test.py | 2 + 2 files changed, 34 insertions(+), 46 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 4df25b26..4c1456ec 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -149,49 +149,35 @@ jobs: run: | echo "/usr/local/opt/make/libexec/gnubin" >> $GITHUB_PATH tox - -# tests-windows: -# name: Unit Tests (Windows) -# runs-on: windows-latest -# if: github.event_name == 'pull_request' - -# strategy: -# matrix: -# python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] - -# steps: -# - name: Checkout repository -# uses: actions/checkout@v4 - -# - name: Setup Python ${{ matrix.python-version }} -# uses: actions/setup-python@v5 -# with: -# python-version: ${{ matrix.python-version }} - -# - name: Install Fonts -# shell: pwsh -# working-directory: .github/scripts -# run: | -# Invoke-WebRequest -Uri 'https://github.com/ietf-tools/common/raw/main/scripts/font-install/font-install.exe' -OutFile font-install.exe -# & ./font-install.exe -debug https://fonts.google.com/download?family=Roboto%20Mono -# & ./font-install.exe -debug https://noto-website-2.storage.googleapis.com/pkgs/Noto-unhinted.zip - -# - name: Install dependencies -# shell: pwsh -# run: | -# Invoke-WebRequest -Uri 'https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases/download/2022-01-04/gtk3-runtime-3.24.31-2022-01-04-ts-win64.exe' -OutFile gtk.exe -# & ./gtk.exe /S -# choco install make -# echo "Installing pip + wheel..." -# python -m pip install --upgrade pip wheel -# echo "Installing requirements.txt + test dependencies..." -# python -m pip install -r requirements.txt tox tox-gh-actions certifi decorator dict2xml pyflakes "pypdf>=4.1.0" "weasyprint==61.2" "pydyf<0.10.0" -# - name: Generate Valid Tests -# run: | -# make yestests || true -# cp tests/out/. tests/valid - -# - name: Test with tox -# env: -# PLATFORM: windows-latest -# run: tox + + tests-windows: + name: Unit Tests (Windows) + runs-on: windows-latest + if: github.event_name == 'pull_request' + + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Python dependencies + shell: pwsh + run: | + echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH + echo "Installing pip + wheel..." + python -m pip install --upgrade pip wheel + echo "Installing requirements.txt + test dependencies..." + python -m pip install -r requirements.txt tox tox-gh-actions certifi decorator dict2xml pyflakes "pypdf>=4.10" + + - name: Run pytests + env: + PLATFORM: windows-latest + run: tox -- pytests diff --git a/test.py b/test.py index 3c2dd5d5..c039687d 100644 --- a/test.py +++ b/test.py @@ -4,6 +4,7 @@ import difflib import lxml import re +import sys import unittest import xml2rfc import xml2rfc.utils @@ -468,6 +469,7 @@ def test_status_independent_exp(self): return self.status_test() +@unittest.skipIf(sys.platform.startswith("win"), "Test skipped on Windows OS") class PdfWriterTests(unittest.TestCase): elements_root = None elements_pdfxml = None