integration.yaml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. name: Lint and mock tests
  2. # Runs on every push and pull request — including PRs from forks. This workflow
  3. # is intentionally limited to lint + the mock provider so it can run safely on
  4. # untrusted code (no secrets, no cloud credentials).
  5. #
  6. # Cloud-provider integration tests live in integration-cloud.yaml, which uses
  7. # pull_request_target plus a maintainer-applied `safe-to-test` label and a
  8. # protected GitHub Environment.
  9. on:
  10. push:
  11. branches:
  12. - main
  13. paths-ignore:
  14. - 'docs/**'
  15. - '**.md'
  16. - '**.rst'
  17. - LICENSE
  18. pull_request:
  19. branches:
  20. - main
  21. paths-ignore:
  22. - 'docs/**'
  23. - '**.md'
  24. - '**.rst'
  25. - LICENSE
  26. workflow_dispatch: {}
  27. permissions:
  28. contents: read
  29. jobs:
  30. lint:
  31. name: Lint code
  32. runs-on: ubuntu-latest
  33. strategy:
  34. matrix:
  35. python-version: [ '3.13' ]
  36. steps:
  37. - name: Checkout code
  38. uses: actions/checkout@v6
  39. with:
  40. persist-credentials: false
  41. - name: Setup Python
  42. uses: actions/setup-python@v6
  43. with:
  44. python-version: ${{ matrix.python-version }}
  45. - name: Cache pip dir
  46. uses: actions/cache@v5
  47. with:
  48. path: ~/.cache/pip
  49. key: pip-cache-${{ matrix.python-version }}-lint
  50. - name: Install required packages
  51. run: pip install tox
  52. - name: Run tox
  53. run: tox -e lint
  54. - name: Run mypy
  55. run: tox -e mypy
  56. bare-install:
  57. name: Bare install imports
  58. runs-on: ubuntu-latest
  59. # Every test environment installs the [dev] extra, which drags in the
  60. # provider SDKs and their transitive dependencies, so the suite passes
  61. # happily against a package whose declared dependencies are incomplete.
  62. # cloudbridge 4.3.1 and 4.4.0 both shipped unable to import
  63. # cloudbridge.base.resources from a plain `pip install cloudbridge`,
  64. # because base.helpers imports cryptography at module scope and nothing
  65. # declared it. Install the built wheel on its own and import the modules
  66. # a user reaches for first.
  67. steps:
  68. - name: Checkout code
  69. uses: actions/checkout@v6
  70. with:
  71. persist-credentials: false
  72. - name: Setup Python
  73. uses: actions/setup-python@v6
  74. with:
  75. # The floor, since a missing dependency is likelier to be satisfied
  76. # by chance on a newer interpreter's richer wheel set.
  77. python-version: '3.10'
  78. - name: Build the distributions
  79. run: |
  80. pip install build
  81. python -m build
  82. - name: Install the wheel with no extras
  83. run: pip install dist/*.whl
  84. - name: Import without the repo on sys.path
  85. # Run from elsewhere: the working directory is the repo root, and
  86. # Python would import the source tree in preference to the wheel,
  87. # which hides exactly the failure this job exists to catch.
  88. working-directory: /tmp
  89. run: |
  90. python -c "
  91. import cloudbridge
  92. from cloudbridge.base.resources import BaseBucketObject
  93. from cloudbridge.base.helpers import generate_key_pair
  94. from cloudbridge.factory import CloudProviderFactory
  95. public, _ = generate_key_pair()
  96. assert public.startswith('ssh-rsa'), public[:32]
  97. print('cloudbridge', cloudbridge.get_version(), 'imports from a bare install')
  98. "
  99. mock:
  100. name: Mock-provider tests
  101. runs-on: ubuntu-latest
  102. strategy:
  103. matrix:
  104. # Lowest and highest supported Python versions
  105. python-version: ['3.10', '3.13']
  106. steps:
  107. - name: Checkout code
  108. uses: actions/checkout@v6
  109. with:
  110. persist-credentials: false
  111. - name: Setup Python
  112. uses: actions/setup-python@v6
  113. with:
  114. python-version: ${{ matrix.python-version }}
  115. - name: Cache pip dir
  116. uses: actions/cache@v5
  117. with:
  118. path: ~/.cache/pip
  119. key: pip-cache-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/requirements.txt') }}
  120. - name: Install required packages
  121. run: pip install tox
  122. - name: Run tox
  123. run: tox -e py${{ matrix.python-version }}-mock
  124. env:
  125. PYTHONUNBUFFERED: "True"