pull_request_ci.rst 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. Pull request CI and security gates
  2. ==================================
  3. Two CI workflows run on pull requests, with different trust levels:
  4. .. list-table::
  5. :header-rows: 1
  6. :widths: 25 25 20 30
  7. * - Workflow
  8. - Trigger
  9. - Runs on forks?
  10. - Secrets exposed
  11. * - ``Lint and mock tests`` (``integration.yaml``)
  12. - every PR / push
  13. - yes, always
  14. - none
  15. * - ``Cloud integration tests`` (``integration-cloud.yaml``)
  16. - ``safe-to-test`` label, push to ``main``, manual dispatch
  17. - only after maintainer approval
  18. - AWS / Azure / GCP / OpenStack
  19. Fork PRs always get lint + mock feedback automatically. Cloud integration
  20. tests are gated behind maintainer review because they run untrusted PR code
  21. with access to live cloud credentials.
  22. For maintainers: applying ``safe-to-test``
  23. ------------------------------------------
  24. Cloud integration runs against PRs are gated by the ``safe-to-test`` label.
  25. **Adding this label is equivalent to authorising arbitrary code execution
  26. against our cloud accounts.** Before applying it on a PR from a fork, audit
  27. the diff for anything that runs at install or test time:
  28. * ``setup.py`` / ``setup.cfg`` / ``pyproject.toml`` — any new ``cmdclass``,
  29. ``entry_points``, post-install hooks, or ``extras_require`` entries that
  30. pull in unfamiliar packages?
  31. * ``tox.ini`` — any new env definitions, ``commands`` overrides, or
  32. ``setenv`` injections?
  33. * ``conftest.py`` and any ``__init__.py`` under ``tests/`` — these run on
  34. pytest startup before fixtures even decide to run.
  35. * New files anywhere under ``.github/`` — workflow tampering.
  36. * Any new test that does outbound network IO outside the expected cloud
  37. APIs (e.g., raw ``requests.post`` to an arbitrary URL).
  38. * Any change under ``cloudbridge/`` that calls ``subprocess``, ``os.system``,
  39. ``eval``, ``exec``, or writes to disk outside the test working tree.
  40. After labeling, the workflow queues and stops at the ``cloud-integration``
  41. environment gate — you will get a second prompt to approve the actual run.
  42. Treat that as a sanity check, not the primary defence; the label was the
  43. real authorisation moment.
  44. If the PR is updated after labeling, the label is automatically removed by
  45. ``pr-label-strip.yaml``. To re-test, re-audit the new diff before
  46. re-applying.
  47. One-time repo setup
  48. -------------------
  49. If you are setting up CI from scratch on a fork or new repo, these one-time
  50. configurations are required:
  51. ``safe-to-test`` label
  52. ~~~~~~~~~~~~~~~~~~~~~~
  53. Create the label in the repo's Issues → Labels page. Any colour. Restrict
  54. label management to maintainers (default for org-owned repos).
  55. ``cloud-integration`` environment
  56. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  57. 1. Repo Settings → Environments → New environment → name it
  58. ``cloud-integration``.
  59. 2. Under **Required reviewers**, add the maintainer team or users who are
  60. allowed to approve cloud-integration runs.
  61. 3. Under **Deployment branches**, select **Selected branches** and add
  62. ``main`` (the workflow only ever runs from base context).
  63. 4. The environment does not need any environment-scoped secrets — all
  64. secrets live at the repo level.
  65. AWS OIDC role
  66. ~~~~~~~~~~~~~
  67. See ``.github/aws/setup.sh``. The role's trust policy
  68. (``.github/aws/trust-policy.json``) accepts two sub claims:
  69. * ``repo:CloudVE/cloudbridge:ref:refs/heads/main`` — push-to-main runs.
  70. * ``repo:CloudVE/cloudbridge:environment:cloud-integration`` — PR runs that
  71. reached the protected environment. Fork PRs that do not reach the
  72. environment cannot assume this role.
  73. The repo secret ``AWS_OIDC_ROLE_ARN`` must be set to the role ARN printed by
  74. ``setup.sh``.