File: pytci.py

package info (click to toggle)
python-beartype 0.20.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,280 kB
  • sloc: python: 76,306; sh: 299; makefile: 30
file content (38 lines) | stat: -rw-r--r-- 1,358 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
# --------------------( LICENSE                            )--------------------
# Copyright (c) 2014-2025 Beartype authors.
# See "LICENSE" for further details.

'''
:mod:`pytest` **continuous integration (CI) utilities.**
'''

# ....................{ IMPORTS                            }....................
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# WARNING: To raise human-readable test errors, avoid importing from
# package-specific submodules at module scope.
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# ....................{ TESTERS                            }....................
def is_ci() -> bool:
    '''
    :data:`True` only if the active Python process is running under a remote
    continuous integration (CI) workflow.
    '''

    # One-liners for a brighter, bolder, better future... today.
    return is_ci_github_actions()


def is_ci_github_actions() -> bool:
    '''
    :data:`True` only if the active Python process is running under a GitHub
    Actions-based continuous integration (CI) workflow.
    '''

    # Defer test-specific imports.
    from os import environ

    # Return true only if the current shell environment declares a GitHub
    # Actions-specific environment variable.
    return 'GITHUB_ACTIONS' in environ