Bit of a weird question, but is there a way to run...
# general
f
Bit of a weird question, but is there a way to run certain targets differently based on platform? Or run additional targets based on platform. Reason for asking, I test on macOS (arm), but our CI/CD runs Linux (amd64) and I want to somehow make sure I use GNU tar on both...
f
An example: The CI for Pants itself has a
platform_specific_behavior
tag added to targets which test platform behavior. Then the CI workflows include running just those tagged tests on all platforms while running the non-platform tests on a single platform to save on the time cost of running all tests on all platforms.
So the solution is to configure your CI in such a way that platform-specific tests are run on all platforms.
(And have the tests check the current platform
sys.platform
(?) if they need to vary how the test is run.)
thus, to run just the tagged tests, you would do:
pants --tag=+platform_specific_behavior test ::
The Pants CI goes one step further and has a
@pytest.mark.platform_specific_behavior
annotation to restrict which tests in a file are run as well.
And then the command becomes:
pants --tag=+platform_specific_behavior test :: -- -m platform_specific_behavior