mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
stubtest_third_party.py: Allow running non-listed platforms locally (#9173)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
4
.github/workflows/daily.yml
vendored
4
.github/workflows/daily.yml
vendored
@@ -73,9 +73,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:
|
||||
|
||||
6
.github/workflows/stubtest_third_party.yml
vendored
6
.github/workflows/stubtest_third_party.yml
vendored
@@ -63,17 +63,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"
|
||||
|
||||
@@ -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()))
|
||||
|
||||
@@ -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 (platform not specified in METADATA.toml)", "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)
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user