Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show installed packages after setup in CI envs
Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
- Loading branch information
1 parent
1d739a2
commit 927e16a
Showing
10 changed files
with
117 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
|
||
_ENV_VARS = { # per https://adamj.eu/tech/2020/03/09/detect-if-your-tests-are-running-on-ci | ||
"CI": None, # generic flag | ||
"TF_BUILD": "true", # Azure Pipelines | ||
"bamboo.buildKey": None, # Bamboo | ||
"BUILDKITE": "true", # Buildkite | ||
"CIRCLECI": "true", # Circle CI | ||
"CIRRUS_CI": "true", # Cirrus CI | ||
"CODEBUILD_BUILD_ID": None, # CodeBuild | ||
"GITHUB_ACTIONS": "true", # GitHub Actions | ||
"GITLAB_CI": None, # GitLab CI | ||
"HEROKU_TEST_RUN_ID": None, # Heroku CI | ||
"BUILD_ID": None, # Hudson | ||
"TEAMCITY_VERSION": None, # TeamCity | ||
"TRAVIS": "true", # Travis CI | ||
} | ||
|
||
|
||
def is_ci() -> bool: | ||
""":return: a flag indicating if running inside a CI env or not""" | ||
return any(e in os.environ if v is None else os.environ.get(e) == v for e, v in _ENV_VARS.items()) | ||
|
||
|
||
__all__ = [ | ||
"is_ci", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
|
||
from tox.pytest import ToxProjectCreator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
|
||
from tox.pytest import ToxProjectCreator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from tox.util.ci import _ENV_VARS, is_ci | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"env_var", | ||
{ | ||
"CI": None, # generic flag | ||
"TF_BUILD": "true", # Azure Pipelines | ||
"bamboo.buildKey": None, # Bamboo | ||
"BUILDKITE": "true", # Buildkite | ||
"CIRCLECI": "true", # Circle CI | ||
"CIRRUS_CI": "true", # Cirrus CI | ||
"CODEBUILD_BUILD_ID": None, # CodeBuild | ||
"GITHUB_ACTIONS": "true", # GitHub Actions | ||
"GITLAB_CI": None, # GitLab CI | ||
"HEROKU_TEST_RUN_ID": None, # Heroku CI | ||
"BUILD_ID": None, # Hudson | ||
"TEAMCITY_VERSION": None, # TeamCity | ||
"TRAVIS": "true", # Travis CI | ||
}.items(), | ||
ids=lambda v: v[0], # type: ignore | ||
) | ||
def test_is_ci(env_var: tuple[str, str | None], monkeypatch: pytest.MonkeyPatch) -> None: | ||
for var in _ENV_VARS: | ||
monkeypatch.delenv(var, raising=False) | ||
monkeypatch.setenv(env_var[0], env_var[1] or "") | ||
assert is_ci() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"env_var", | ||
{ | ||
"TF_BUILD": "", # Azure Pipelines | ||
"BUILDKITE": "", # Buildkite | ||
"CIRCLECI": "", # Circle CI | ||
"CIRRUS_CI": "", # Cirrus CI | ||
"GITHUB_ACTIONS": "", # GitHub Actions | ||
"TRAVIS": "", # Travis CI | ||
}.items(), | ||
ids=lambda v: v[0], # type: ignore | ||
) | ||
def test_is_ci_bad_set(env_var: tuple[str, str], monkeypatch: pytest.MonkeyPatch) -> None: | ||
for var in _ENV_VARS: | ||
monkeypatch.delenv(var, raising=False) | ||
monkeypatch.setenv(env_var[0], env_var[1]) | ||
assert not is_ci() | ||
|
||
|
||
def test_is_ci_not(monkeypatch: pytest.MonkeyPatch) -> None: | ||
for var in _ENV_VARS: | ||
monkeypatch.delenv(var, raising=False) | ||
assert not is_ci() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters