8000 stubtest_third_party.py: Allow running non-listed platforms locally (… · python/typeshed@72d1597 · GitHub
[go: up one dir, main page]

Skip to content

Commit 72d1597

Browse files
AvasamAlexWaygood
andauthored
stubtest_third_party.py: Allow running non-listed platforms locally (#9173)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent cfed3e1 commit 72d1597

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

.github/workflows/daily.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ jobs:
7373
sudo apt update
7474
sudo apt install -y $(python tests/get_packages.py)
7575
76-
xvfb-run python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }}
76+
xvfb-run python tests/stubtest_third_party.py --specified-stubs-only --num-shards 4 --shard-index ${{ matrix.shard-index }}
7777
else
78-
python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }}
78+
python tests/stubtest_third_party.py --specified-stubs-only --num-shards 4 --shard-index ${{ matrix.shard-index }}
7979
fi
8080
8181
stub-uploader:

.github/workflows/stubtest_third_party.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ jobs:
6363
echo "Installing apt packages: $PACKAGES"
6464
sudo apt update && sudo apt install -y $PACKAGES
6565
fi
66-
xvfb-run python tests/stubtest_third_party.py $STUBS
66+
xvfb-run python tests/stubtest_third_party.py --specified-stubs-only $STUBS
6767
fi
6868
6969
if [ "${{ matrix.os }}" = "macos-latest" ]; then
7070
# Could install brew packages here if we run into stubs that need it
71-
python tests/stubtest_third_party.py $STUBS
71+
python tests/stubtest_third_party.py --specified-stubs-only $STUBS
7272
fi
7373
7474
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7575
# Could install choco packages here if we run into stubs that need it
76-
python tests/stubtest_third_party.py $STUBS
76+
python tests/stubtest_third_party.py --specified-stubs-only $STUBS
7777
fi
7878
else
7979
echo "Nothing to test"

tests/stubtest_third_party.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_mypy_req() -> str:
2323
return next(line.strip() for line in f if "mypy" in line)
2424

2525

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

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

3737
platforms_to_test = stubtest_meta.get("platforms", ["linux"])
3838
if sys.platform not in platforms_to_test:
39-
print(colored(f"skipping, unsupported platform: {sys.platform}, supported: {platforms_to_test}", "yellow"))
40-
return True
39+
if specified_stubs_only:
40+
print(colored("skipping (platform not specified in METADATA.toml)", "yellow"))
41+
return True
42+
print(colored(f"Note: {dist.name} is not currently tested on {sys.platform} in typeshed's CI.", "yellow"))
4143

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

@@ -180,7 +187,7 @@ def main() -> NoReturn:
180187
for i, dist in enumerate(dists):
181188
if i % args.num_shards != args.shard_index:
182189
continue
183-
if not run_stubtest(dist, verbose=args.verbose):
190+
if not run_stubtest(dist, verbose=args.verbose, specified_stubs_only=args.specified_stubs_only):
184191
result = 1
185192
sys.exit(result)
186193

0 commit comments

Comments
 (0)
0