Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ jobs:
sudo apt update
sudo apt install -y $(python tests/get_packages.py)

xvfb-run python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }}
xvfb-run python tests/stubtest_third_party.py --specified-stubs-only --num-shards 4 --shard-index ${{ matrix.shard-index }}
else
python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }}
python tests/stubtest_third_party.py --specified-stubs-only --num-shards 4 --shard-index ${{ matrix.shard-index }}
fi

stub-uploader:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/stubtest_third_party.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ jobs:
echo "Installing apt packages: $PACKAGES"
sudo apt update && sudo apt install -y $PACKAGES
fi
xvfb-run python tests/stubtest_third_party.py $STUBS
xvfb-run python tests/stubtest_third_party.py --specified-stubs-only $STUBS
fi

if [ "${{ matrix.os }}" = "macos-latest" ]; then
# Could install brew packages here if we run into stubs that need it
python tests/stubtest_third_party.py $STUBS
python tests/stubtest_third_party.py --specified-stubs-only $STUBS
fi

if [ "${{ matrix.os }}" = "windows-latest" ]; then
# Could install choco packages here if we run into stubs that need it
python tests/stubtest_third_party.py $STUBS
python tests/stubtest_third_party.py --specified-stubs-only $STUBS
fi
else
echo "Nothing to test"
Expand Down
15 changes: 11 additions & 4 deletions tests/stubtest_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_mypy_req() -> str:
return next(line.strip() for line in f if "mypy" in line)


def run_stubtest(dist: Path, *, verbose: bool = False) -> bool:
def run_stubtest(dist: Path, *, verbose: bool = False, specified_stubs_only: bool = False) -> bool:
with open(dist / "METADATA.toml", encoding="UTF-8") as f:
metadata = dict(tomli.loads(f.read()))

Expand All @@ -36,8 +36,10 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool:

platforms_to_test = stubtest_meta.get("platforms", ["linux"])
if sys.platform not in platforms_to_test:
print(colored(f"skipping, unsupported platform: {sys.platform}, supported: {platforms_to_test}", "yellow"))
return True
if specified_stubs_only:
print(colored("skipping (unspecified platform)", "yellow"))
return True
print(colored(f"Note: {dist.name} is not currently tested on {sys.platform} in typeshed's CI.", "yellow"))

with tempfile.TemporaryDirectory() as tmp:
venv_dir = Path(tmp)
Expand Down Expand Up @@ -167,6 +169,11 @@ def main() -> NoReturn:
parser.add_argument("-v", "--verbose", action="store_true", help="verbose output")
parser.add_argument("--num-shards", type=int, default=1)
parser.add_argument("--shard-index", type=int, default=0)
parser.add_argument(
"--specified-stubs-only",
action="store_true",
help="skip the test if the current platform is not specified in METADATA.toml/tool.stubtest.platforms",
)
parser.add_argument("dists", metavar="DISTRIBUTION", type=str, nargs=argparse.ZERO_OR_MORE)
args = parser.parse_args()

Expand All @@ -180,7 +187,7 @@ def main() -> NoReturn:
for i, dist in enumerate(dists):
if i % args.num_shards != args.shard_index:
continue
if not run_stubtest(dist, verbose=args.verbose):
if not run_stubtest(dist, verbose=args.verbose, specified_stubs_only=args.specified_stubs_only):
result = 1
sys.exit(result)

Expand Down