Skip to content

Commit

Permalink
CI: test the build and add some mingw specific tests
Browse files Browse the repository at this point in the history
- Use actions/setup-python for setting up correct version in cross build
- CI: add cross llvm-mingw jobs
- CI: fix sed pattern for python-config.py shebang
  The shebang (`#!`) does not include `${pkgdir}` so this sed did nothing
- CI: remove --without-c-locale-coercion
  No longer needed since the default now works on Windows
- Make sure we always use the stdlib distutils
- CI: update actions and images
  ubuntu-18.04 is gone now
- CI: updates for mstorsjo/llvm-mingw moving to 20.04
- CI: 3.10 -> 3.11
  • Loading branch information
naveen521kk authored and lazka committed Aug 25, 2023
1 parent 4c83626 commit c04f4f7
Show file tree
Hide file tree
Showing 3 changed files with 641 additions and 0 deletions.
294 changes: 294 additions & 0 deletions .github/workflows/mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
name: Build
on: [push, pull_request, workflow_dispatch]

jobs:
build:
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
msystem: ['MINGW64','MINGW32','UCRT64','CLANG64','CLANG32']
include:
- msystem: MINGW64
prefix: mingw-w64-x86_64
- msystem: MINGW32
prefix: mingw-w64-i686
- msystem: UCRT64
prefix: mingw-w64-ucrt-x86_64
- msystem: CLANG64
prefix: mingw-w64-clang-x86_64
- msystem: CLANG32
prefix: mingw-w64-clang-i686
steps:
- name: Setup git
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v3
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
release: false
update: true
install: >-
make
binutils
autoconf
autoconf-archive
automake-wrapper
tar
gzip
${{ matrix.prefix }}-toolchain
${{ matrix.prefix }}-expat
${{ matrix.prefix }}-bzip2
${{ matrix.prefix }}-libffi
${{ matrix.prefix }}-mpdecimal
${{ matrix.prefix }}-ncurses
${{ matrix.prefix }}-openssl
${{ matrix.prefix }}-sqlite3
${{ matrix.prefix }}-tcl
${{ matrix.prefix }}-tk
${{ matrix.prefix }}-zlib
${{ matrix.prefix }}-xz
${{ matrix.prefix }}-tzdata
- name: Build Python
shell: msys2 {0}
run: |
set -ex
if [[ "${{ matrix.msystem }}" == "CLANG64" ]] || [[ "${{ matrix.msystem }}" == "CLANG32" ]]; then
export CC=clang
export CXX=clang++
fi
autoreconf -vfi
rm -Rf _build && mkdir _build && cd _build
../configure \
--prefix=${MINGW_PREFIX} \
--host=${MINGW_CHOST} \
--build=${MINGW_CHOST} \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--with-system-libmpdec \
--without-ensurepip \
--enable-loadable-sqlite-extensions \
--with-tzpath=${MINGW_PREFIX}/share/zoneinfo \
--enable-optimizations
make -j8
- name: Run Smoke Test (build)
shell: msys2 {0}
run: |
export SETUPTOOLS_USE_DISTUTILS=stdlib
SMOKETESTS="$(pwd)/mingw_smoketests.py"
cd _build
./python.exe "$SMOKETESTS"
MSYSTEM= ./python.exe "$SMOKETESTS"
- name: Run tests
shell: msys2 {0}
run: |
export SETUPTOOLS_USE_DISTUTILS=stdlib
IGNOREFILE="$(pwd)/mingw_ignorefile.txt"
cd _build
MSYSTEM= ./python.exe -m test -j8 --ignorefile "$IGNOREFILE" -W
- name: Run broken tests
continue-on-error: true
shell: msys2 {0}
run: |
export SETUPTOOLS_USE_DISTUTILS=stdlib
IGNOREFILE="$(pwd)/mingw_ignorefile.txt"
cd _build
MSYSTEM= ./python.exe -m test -j8 --matchfile "$IGNOREFILE" -W
- name: Install
shell: msys2 {0}
run: |
set -ex
cd _build
pkgdir=python_pkgdir
make -j1 install DESTDIR="${pkgdir}"
# Fix shebangs
_pybasever=$(./python.exe -c "import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}');")
for fscripts in 2to3 2to3-${_pybasever} idle3 idle${_pybasever} pydoc3 pydoc${_pybasever}; do
sed -i "s|$(cygpath -w ${MINGW_PREFIX} | sed 's|\\|\\\\|g')/bin/python${_pybasever}.exe|/usr/bin/env python${_pybasever}.exe|g" "${pkgdir}${MINGW_PREFIX}"/bin/${fscripts}
done
sed -i "s|#!${MINGW_PREFIX}/bin/python${_pybasever}.exe|#!/usr/bin/env python${_pybasever}.exe|" "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${_pybasever}/python-config.py
# Create version-less aliases
cp "${pkgdir}${MINGW_PREFIX}"/bin/python3.exe "${pkgdir}${MINGW_PREFIX}"/bin/python.exe
cp "${pkgdir}${MINGW_PREFIX}"/bin/python3w.exe "${pkgdir}${MINGW_PREFIX}"/bin/pythonw.exe
cp "${pkgdir}${MINGW_PREFIX}"/bin/python3-config "${pkgdir}${MINGW_PREFIX}"/bin/python-config
cp "${pkgdir}${MINGW_PREFIX}"/bin/idle3 "${pkgdir}${MINGW_PREFIX}"/bin/idle
cp "${pkgdir}${MINGW_PREFIX}"/bin/pydoc3 "${pkgdir}${MINGW_PREFIX}"/bin/pydoc
- name: Run Smoke Test (installed)
shell: msys2 {0}
run: |
export SETUPTOOLS_USE_DISTUTILS=stdlib
export PYTHONTZPATH="${MINGW_PREFIX}/share/zoneinfo"
SMOKETESTS="$(pwd)/mingw_smoketests.py"
cd _build
cd python_pkgdir/${MINGW_PREFIX}/bin
./python.exe "$SMOKETESTS"
MSYSTEM= ./python.exe "$SMOKETESTS"
- name: Compress
if: always()
shell: msys2 {0}
run: |
cd _build
tar -zcf python.tar.gz python_pkgdir/
- name: Upload
uses: actions/upload-artifact@v3
if: always()
with:
name: build-${{ matrix.msystem }}
path: _build/python.tar.gz

cross-gcc-x86_64:
runs-on: ubuntu-latest
container:
image: archlinux:base-devel
steps:
- uses: actions/checkout@v3
- name: Install deps
run: |
pacman --noconfirm -Suuy
pacman --needed --noconfirm -S mingw-w64-gcc autoconf-archive autoconf automake zip
- uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Check Python Version
run: |
which python
python --version
- name: Build
run: |
autoreconf -vfi
mkdir _build && cd _build
../configure \
--host=x86_64-w64-mingw32 \
--build=x86_64-pc-linux-gnu \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--with-system-libmpdec \
--without-ensurepip \
--enable-loadable-sqlite-extensions \
--with-build-python=python3.11
make -j8
make install DESTDIR="$(pwd)/install"
- name: 'Zip files'
run: |
zip -r install.zip _build/install
- name: Upload
uses: actions/upload-artifact@v3
with:
name: build-cross-gcc-x86_64
path: install.zip

cross-gcc-x86_64-test:
needs: [cross-gcc-x86_64]
runs-on: windows-latest
steps:
- uses: actions/download-artifact@v3
with:
name: build-cross-gcc-x86_64

- name: 'Run tests'
run: |
7z x install.zip
./_build/install/usr/local/bin/python3.exe -c "import sysconfig, pprint; pprint.pprint(sysconfig.get_config_vars())"
cross-llvm-mingw:
runs-on: ubuntu-latest
container:
image: mstorsjo/llvm-mingw:latest
strategy:
fail-fast: false
matrix:
arch: ['x86_64', 'i686', 'aarch64', 'armv7']
steps:
- uses: actions/checkout@v3

- name: Install deps
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -qqy software-properties-common
add-apt-repository --yes ppa:deadsnakes/ppa
apt-get update -qq
apt-get install -qqy autoconf-archive python3.11-dev python3.11
- name: Build
run: |
autoreconf -vfi
mkdir _build && cd _build
export CC=${{ matrix.arch }}-w64-mingw32-clang
export CXX=${CC}++
../configure \
--host=${{ matrix.arch }}-w64-mingw32 \
--build=x86_64-pc-linux-gnu \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--with-system-libmpdec \
--without-ensurepip \
--without-c-locale-coercion \
--enable-loadable-sqlite-extensions \
--with-build-python=python3.11
make -j8
make install DESTDIR="$(pwd)/install"
- name: 'Zip files'
run: |
zip -r install.zip _build/install
- name: Upload
uses: actions/upload-artifact@v3
with:
name: build-cross-llvm-mingw-${{ matrix.arch }}
path: install.zip

cross-llvm-mingw-test:
needs: [cross-llvm-mingw]
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch: ['x86_64', 'i686']
steps:
- uses: actions/download-artifact@v3
with:
name: build-cross-llvm-mingw-${{ matrix.arch }}

- name: 'Run tests'
run: |
7z x install.zip
./_build/install/usr/local/bin/python3.exe -c "import sysconfig, pprint; pprint.pprint(sysconfig.get_config_vars())"
34 changes: 34 additions & 0 deletions mingw_ignorefile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ctypes.test.test_loading.LoaderTest.test_load_dll_with_flags
distutils.tests.test_bdist_dumb.BuildDumbTestCase.test_simple_built
distutils.tests.test_cygwinccompiler.CygwinCCompilerTestCase.test_get_versions
distutils.tests.test_util.UtilTestCase.test_change_root
test.datetimetester.TestLocalTimeDisambiguation_Fast.*
test.datetimetester.TestLocalTimeDisambiguation_Pure.*
test.test_cmath.CMathTests.test_specific_values
test.test_cmd_line_script.CmdLineTest.test_consistent_sys_path_for_direct_execution
test.test_compileall.CommandLineTestsNoSourceEpoch.*
test.test_compileall.CommandLineTestsWithSourceEpoch.*
test.test_compileall.CompileallTestsWithoutSourceEpoch.*
test.test_compileall.CompileallTestsWithSourceEpoch.*
test.test_import.ImportTests.test_dll_dependency_import
test.test_math.MathTests.*
test.test_ntpath.NtCommonTest.test_import
test.test_os.StatAttributeTests.test_stat_block_device
test.test_os.TestScandir.test_attributes
test.test_os.UtimeTests.test_large_time
test.test_platform.PlatformTest.test_architecture_via_symlink
test.test_regrtest.ProgramsTestCase.test_pcbuild_rt
test.test_regrtest.ProgramsTestCase.test_tools_buildbot_test
test.test_site._pthFileTests.*
test.test_site.HelperFunctionsTests.*
test.test_site.StartupImportTests.*
test.test_ssl.*
test.test_strptime.CalculationTests.*
test.test_strptime.StrptimeTests.test_weekday
test.test_strptime.TimeRETests.test_compile
test.test_tools.test_i18n.Test_pygettext.test_POT_Creation_Date
test.test_venv.BasicTest.*
test.test_venv.EnsurePipTest.*
# flaky
test.test__xxsubinterpreters.*
test.test_asyncio.test_subprocess.SubprocessProactorTests.test_stdin_broken_pipe
Loading

0 comments on commit c04f4f7

Please sign in to comment.