8000 Run stubtest on stubs on different platforms by sobolevn · Pull Request #8923 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Run stubtest on stubs on different platforms #8923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
61deba6
Run stubtest on stubs on different platforms
sobolevn Oct 18, 2022
0a96d99
Fix CI
sobolevn Oct 18, 2022
8149e3c
Fix CI
sobolevn Oct 18, 2022
7d364f7
Fix CI
sobolevn Oct 18, 2022
1a9af3a
Address review
sobolevn Oct 19, 2022
f00714a
Run daily on differeny platforms
sobolevn Oct 19, 2022
3f31bed
Fix daily run
sobolevn Oct 19, 2022
8eb0c83
Merge branch 'master' into run-stubs-on-different-platforms
AlexWaygood Oct 19, 2022
c8650b3
Rename `stubtest` files
sobolevn Oct 19, 2022
770c5aa
Merge branch 'run-stubs-on-different-platforms' of https://github.com…
sobolevn Oct 19, 2022
fdf13bb
Add platform-specific allowlists for stubs
sobolevn Oct 19, 2022
c84fe27
Fix CI
sobolevn Oct 19, 2022
40a4c50
Fix CI
sobolevn Oct 19, 2022
025568b
Try `Pillow~=7.1.2`
sobolevn Oct 19, 2022
c8b6472
Skip `D3DShot`
sobolevn Oct 19, 2022
21eb994
Revert `win32` change
sobolevn Oct 19, 2022
ac06a7c
Fix CI
sobolevn Oct 24, 2022
081ebba
Merge branch 'master' into run-stubs-on-different-platforms
sobolevn Oct 24, 2022
0be8c9b
Address review
sobolevn Oct 25, 2022
ec000eb
Merge branch 'run-stubs-on-different-platforms' of https://github.com…
sobolevn Oct 25, 2022
3bb8296
Update CONTRIBUTING.md
sobolevn Oct 26, 2022
870daa6
Merge main
sobolevn Nov 9, 2022
c4f86da
Fix allowlist of win32
sobolevn Nov 9, 2022
183ea56
Merge branch 'main' into run-stubs-on-different-platforms
AlexWaygood Nov 9, 2022
a6b1cab
Update stubtest_allowlist_win32.txt
sobolevn Nov 9, 2022
bf2f10e
Update tests/get_packages.py
sobolevn Nov 9, 2022
578f619
Merge remote-tracking branch 'origin/main' into run-stubs-on-differen…
AlexWaygood Nov 11, 2022
7df5a1f
Delete unused allowlist entries
AlexWaygood Nov 11, 2022
949bf46
Update CONTRIBUTING.md
sobolevn Nov 11, 2022
faac1be
Apply suggestions from code review
sobolevn Nov 11, 2022
9464335
Add TODO comment back
AlexWaygood Nov 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Run stubtest on stubs on different platforms
  • Loading branch information
sobolevn committed Oct 18, 2022
commit 61deba65bf47cb5dd7cb6939878b962036eb6cd1
2 changes: 1 addition & 1 deletion .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Install apt packages
run: |
sudo apt update
sudo apt install -y $(python tests/get_apt_packages.py)
sudo apt install -y $(python tests/get_packages.py)
- name: Run stubtest
run: xvfb-run python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }}

Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/stubtest_stubs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Test

on:
pull_request:
paths-ignore:
- '**/*.md'
- 'scripts/**'

permissions:
contents: read

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
stubtest-third-party:
name: Check third party stubs with stubtest

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
fail-fast: false

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install dependencies
run: pip install -r requirements-tests.txt
- name: Run stubtest
run: |
STUBS=$(
git diff --name-only origin/${{ github.base_ref }} HEAD |
# Uncomment the following to (very slowly) run on all third party stubs:
# git ls-files |
egrep ^stubs/ | cut -d "/" -f 2 | sort -u | (while read stub; do [ -d stubs/$stub ] && echo $stub || true; done)
)
if test -n "$STUBS"; then
echo "Testing $STUBS..."
PACKAGES=$(python tests/get_packages.py $STUBS)

if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
if test -n "$PACKAGES"; then
echo "Installing apt packages: $PACKAGES"
sudo apt update && sudo apt install -y $PACKAGES
fi
xvfb-run python tests/stubtest_third_party.py $STUBS
fi

if [ "${{ matrix.os }}" = "macos-latest" ]; then
# TODO: install brew packages
python tests/stubtest_third_party.py $STUBS
fi

if [ "${{ matrix.os }}" = "windows-latest" ]; then
# TODO: support windows
python tests/stubtest_third_party.py $STUBS
fi
else
echo "Nothing to test"
fi
10000
33 changes: 0 additions & 33 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,36 +147,3 @@ jobs:
cd stub_uploader
pip install -r requirements.txt
python -m pytest tests

stubtest-third-party:
name: Check third party stubs with stubtest
runs-on: ubuntu-20.04
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install dependencies
run: pip install -r requirements-tests.txt
- name: Run stubtest
run: |
STUBS=$(
git diff --name-only origin/${{ github.base_ref }} HEAD |
# Uncomment the following to (very slowly) run on all third party stubs:
# git ls-files |
egrep ^stubs/ | cut -d "/" -f 2 | sort -u | (while read stub; do [ -d stubs/$stub ] && echo $stub || true; done)
)
if test -n "$STUBS"; then
echo "Testing $STUBS..."
APT_PACKAGES=$(python tests/get_apt_packages.py $STUBS)
if test -n "$APT_PACKAGES"; then
echo "Installing apt packages: $APT_PACKAGES"
sudo apt update && sudo apt install -y $APT_PACKAGES
fi
xvfb-run python tests/stubtest_third_party.py $STUBS
else
echo "Nothing to test"
fi
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ This has the following keys:
* `apt_dependencies` (default: `[]`): A list of Ubuntu APT packages
that need to be installed for stubtest to run successfully. These are
usually packages needed to pip install the implementation distribution.
* `platform` (default: `None`): A list of supported OSes.
Can contain `win32`, `linux`, and `darwin` values.
If not specified, all platforms are considered supported.

The format of all `METADATA.toml` files can be checked by running
`python3 ./tests/check_consistent.py`.
Expand Down
1 change: 1 addition & 0 deletions stubs/JACK-Client/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = "0.5.*"

[tool.stubtest]
platform = ["linux"]
apt_dependencies = ["libjack-dev"]
1 change: 1 addition & 0 deletions stubs/pyaudio/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = "0.2.*"

[tool.stubtest]
platform = ["linux"]
apt_dependencies = ["portaudio19-dev"]
1 change: 1 addition & 0 deletions stubs/pycurl/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = "7.45.*"

[tool.stubtest]
platform = ["linux"]
apt_dependencies = ["libcurl4-openssl-dev"]
14 changes: 0 additions & 14 deletions tests/get_apt_packages.py

This file was deleted.

23 changes: 23 additions & 0 deletions tests/get_packages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
import os
import sys

import tomli

platform = sys.platform
distributions = sys.argv[1:]
if not distributions:
distributions = os.listdir("stubs")

metadata_mapping = {
"linux": "apt_dependencies",
# TODO: support others:
# "darwin": "brew_dependencies",
# "win32": "choco_dependencies",
}

if platform in metadata_mapping:
for distribution in distributions:
with open(f"stubs/{distribution}/METADATA.toml", "rb") as file:
for package in tomli.load(file).get("tool", {}).get("stubtest", {}).get(metadata_mapping[platform], []):
print(package)
5 changes: 5 additions & 0 deletions tests/stubtest_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool:
print(colored("skipping", "yellow"))
return True

platform = metadata.get("tool", {}).get("plaform", None)
if platform is not None and sys.platform not in platform:
print(colored(f"skipping, unsupported platform: {sys.platform}, supported: {platform}", "yellow"))
return True

with tempfile.TemporaryDirectory() as tmp:
venv_dir = Path(tmp)
venv.create(venv_dir, with_pip=True, clear=True)
Expand Down
0