Skip to content

Commit 87ec804

Browse files
authored
skip CPU tests on GPU GHA jobs (#6970)
1 parent f47e70e commit 87ec804

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

test/common_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
import __main__ # noqa: 401
1414

1515

16-
IN_CIRCLE_CI = os.getenv("CIRCLECI", False) == "true"
16+
IN_OSS_CI = any(os.getenv(var) == "true" for var in ["CIRCLECI", "GITHUB_ACTIONS"])
1717
IN_RE_WORKER = os.environ.get("INSIDE_RE_WORKER") is not None
1818
IN_FBCODE = os.environ.get("IN_FBCODE_TORCHVISION") == "1"
1919
CUDA_NOT_AVAILABLE_MSG = "CUDA device not available"
20-
CIRCLECI_GPU_NO_CUDA_MSG = "We're in a CircleCI GPU machine, and this test doesn't need cuda."
20+
OSS_CI_GPU_NO_CUDA_MSG = "We're in an OSS GPU machine, and this test doesn't need cuda."
2121

2222

2323
@contextlib.contextmanager

test/conftest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
import pytest
55
import torch
6-
from common_utils import CIRCLECI_GPU_NO_CUDA_MSG, CUDA_NOT_AVAILABLE_MSG, IN_CIRCLE_CI, IN_FBCODE, IN_RE_WORKER
6+
from common_utils import CUDA_NOT_AVAILABLE_MSG, IN_FBCODE, IN_OSS_CI, IN_RE_WORKER, OSS_CI_GPU_NO_CUDA_MSG
77

88

99
def pytest_configure(config):
@@ -18,7 +18,7 @@ def pytest_collection_modifyitems(items):
1818
#
1919
# Typically, here, we try to optimize CI time. In particular, the GPU CI instances don't need to run the
2020
# tests that don't need CUDA, because those tests are extensively tested in the CPU CI instances already.
21-
# This is true for both CircleCI and the fbcode internal CI.
21+
# This is true for both OSS CI and the fbcode internal CI.
2222
# In the fbcode CI, we have an additional constraint: we try to avoid skipping tests. So instead of relying on
2323
# pytest.mark.skip, in fbcode we literally just remove those tests from the `items` list, and it's as if
2424
# these tests never existed.
@@ -49,12 +49,12 @@ def pytest_collection_modifyitems(items):
4949
# TODO: something more robust would be to do that only in a sandcastle instance,
5050
# so that we can still see the test being skipped when testing locally from a devvm
5151
continue
52-
elif IN_CIRCLE_CI:
52+
elif IN_OSS_CI:
5353
# Here we're not in fbcode, so we can safely collect and skip tests.
5454
if not needs_cuda and torch.cuda.is_available():
55-
# Similar to what happens in RE workers: we don't need the CircleCI GPU machines
55+
# Similar to what happens in RE workers: we don't need the OSS CI GPU machines
5656
# to run the CPU-only tests.
57-
item.add_marker(pytest.mark.skip(reason=CIRCLECI_GPU_NO_CUDA_MSG))
57+
item.add_marker(pytest.mark.skip(reason=OSS_CI_GPU_NO_CUDA_MSG))
5858

5959
if item.get_closest_marker("dont_collect") is not None:
6060
# currently, this is only used for some tests we're sure we don't want to run on fbcode

0 commit comments

Comments
 (0)