Skip to content

Commit

Permalink
Always run the test suite when building the wheel
Browse files Browse the repository at this point in the history
Unfortunately there's no Python-wide way of saying "this is how you run
tests", and no Python-wide way of saying "please run the tests when
building the wheel". If you ask me, this is obviously wrong because
tests are usually written for a reason, and not just for the lulz, and
it is a good thing to know that the build did not produce utter crap.

Since there's no Python-ish way of achieving this, let's give up and
hardcode everything. That way the test suite will be run as a part of
each build.

In the CI we're still taking the wheel in another VM and executing the
test suite again to make sure that whatever wheel magic which had to
happen happened correctly. That, however, is a different test from "is
the build OK" (e.g., `auditwheel repair`), and there's still point in
having an "early warning" should the build produce a non-working result.
Also, it (neatly) prevents a possible scenario where a wheel was left
unchecked by a second, testing CI job.

Bug: pypa/setuptools#1684
  • Loading branch information
jktjkt committed Feb 4, 2023
1 parent be91780 commit bd00633
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 40 deletions.
40 changes: 1 addition & 39 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,46 +308,8 @@ jobs:
working-directory: '${{ github.workspace }}/../build-libyang-cpp'
run: cmake --install . --strip

- name: quick install pytest for the test suite
if: startsWith(matrix.os, 'ubuntu-22')
run: pip install pytest

- name: quick configure oopt-gnpy-libyang
if: startsWith(matrix.os, 'ubuntu-22')
shell: bash
run: |
set -ex
cmake \
-DSHOW_SO_DEPENDENCIES=ON \
-DDONT_WARN_ABOUT_SETUP_PY=ON \
-S '${{ github.workspace }}/' \
-B '${{ github.workspace }}/'../build-oopt-gnpy-libyang \
-G '${{ matrix.generators }}' \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
${EXTRA_VCPKG_TARGET_TRIPLET:+${EXTRA_VCPKG_TARGET_TRIPLET}} \
${EXTRA_CMAKE_TOOLCHAIN_FILE:+${EXTRA_CMAKE_TOOLCHAIN_FILE}} \
${EXTRA_OSX_ARCH:+${EXTRA_OSX_ARCH}} \
${EXTRA_PKG_CONFIG_EXECUTABLE:+${EXTRA_PKG_CONFIG_EXECUTABLE}} \
-DCMAKE_PREFIX_PATH:PATH=${GITHUB_WORKSPACE//\\//}/../target \
-DCMAKE_INSTALL_PREFIX:PATH='${{ github.workspace }}/'../target
- name: quick build oopt-gnpy-libyang
if: startsWith(matrix.os, 'ubuntu-22')
working-directory: '${{ github.workspace }}/../build-oopt-gnpy-libyang'
run: cmake --build . -j${{ steps.cpu-cores.outputs.count }} --config ${{ matrix.build_type }}

- name: quick install oopt-gnpy-libyang
if: startsWith(matrix.os, 'ubuntu-22')
working-directory: '${{ github.workspace }}/../build-oopt-gnpy-libyang'
run: cmake --install . --strip

- name: quick test oopt-gnpy-libyang
if: startsWith(matrix.os, 'ubuntu-22')
working-directory: '${{ github.workspace }}/../build-oopt-gnpy-libyang'
run: ctest --output-on-failure -j${{ steps.cpu-cores.outputs.count }} --build-config ${{ matrix.build_type }}

- name: prepare wheel building
run: pip install wheel setuptools build setuptools_scm[toml]
run: pip install wheel setuptools build setuptools_scm[toml] pytest

- name: show Python version
run: python --version
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ requires = [
"ninja",
"cmake>=3.21",
"setuptools_scm[toml]>=6.4.2",
"pytest>=6.0",
]
build-backend = "setuptools.build_meta"

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def build_extension(self, ext):

subprocess.check_call(["cmake", ext.sourcedir] + cmake_args, cwd=build_temp)
subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=build_temp)
subprocess.check_call(["ctest", "--output-on-failure"] + build_args, cwd=build_temp)


# The information here can also be placed in setup.cfg - better separation of
Expand All @@ -128,7 +129,6 @@ def build_extension(self, ext):
ext_modules=[CMakeExtension("oopt_gnpy_libyang")],
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
extras_require={"test": ["pytest>=6.0"]},
python_requires=">=3.8",
license='BSD-3-Clause',
download_url='https://pypi.org/project/oopt-gnpy-libyang/',
Expand Down

0 comments on commit bd00633

Please sign in to comment.