Skip to content

Commit

Permalink
chore(cibw): also test sdist/gen wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
vytas7 committed Aug 30, 2024
1 parent fc9943a commit a216710
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/cibuildwheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ jobs:
run: |
tools/check_dist.py ${{ github.event_name == 'release' && format('-r {0}', github.ref) || '' }}
- name: Test sdist
run: |
tools/test_dist.py dist/*.tar.gz
- name: Test pure-Python wheel
run: |
tools/test_dist.py dist/*.whl
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
50 changes: 50 additions & 0 deletions tools/test_dist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python

import argparse
import logging
import pathlib
import subprocess
import sys
import tempfile

logging.basicConfig(
format='[test_dist.py] %(asctime)s [%(levelname)s] %(message)s', level=logging.INFO
)

FALCON_ROOT = pathlib.Path(__file__).resolve().parent.parent
REQUIREMENTS = FALCON_ROOT / 'requirements' / 'cibwtest'
TESTS = FALCON_ROOT / 'tests'


def test_package(package):
with tempfile.TemporaryDirectory() as tmpdir:
venv = pathlib.Path(tmpdir) / 'venv'
subprocess.check_call((sys.executable, '-m', 'venv', venv))
logging.info(f'Created a temporary venv in {venv}.')

subprocess.check_call((venv / 'bin' / 'pip', 'install', '--upgrade', 'pip'))
subprocess.check_call((venv / 'bin' / 'pip', 'install', '-r', REQUIREMENTS))
logging.info(f'Installed test requirements in {venv}.')
subprocess.check_call(
(venv / 'bin' / 'pip', 'install', package),
)
logging.info(f'Installed {package} into {venv}.')

subprocess.check_call((venv / 'bin' / 'pytest', TESTS), cwd=venv)
logging.info(f'{package} passes tests.')


def main():
description = 'Test Falcon packages (sdist or generic wheel).'
parser = argparse.ArgumentParser(description=description)
parser.add_argument(
'package', metavar='PACKAGE', nargs='+', help='sdist/wheel(s) to test'
)
args = parser.parse_args()

for package in args.package:
test_package(package)


if __name__ == '__main__':
main()

0 comments on commit a216710

Please sign in to comment.