|
| 1 | +.. _GitHub Workflows: |
| 2 | + |
| 3 | +Enabling GitHub Workflows |
| 4 | +========================= |
| 5 | + |
| 6 | +.. toctree:: |
| 7 | + :maxdepth: 2 |
| 8 | + :hidden: |
| 9 | + |
| 10 | + configuration |
| 11 | + |
| 12 | +The PTB ships with configurable GitHub workflow templates covering the most common |
| 13 | +CI/CD setup variants for Python projects. The templates are defined in: |
| 14 | +`exasol/toolbox/templates/github/workflows <https://github.com/exasol/python-toolbox/tree/main/exasol/toolbox/templates/github/workflows>`__. |
| 15 | + |
| 16 | +The PTB provides a command line interface (CLI) for generating and updating actual |
| 17 | +workflows from the templates. |
| 18 | + |
| 19 | +.. code-block:: bash |
| 20 | +
|
| 21 | + poetry run -- tbx workflow --help |
| 22 | +
|
| 23 | +.. attention:: |
| 24 | + |
| 25 | + In most cases, we recommend using _all_ workflows without change to ensure |
| 26 | + consistent interdependencies. For more details, see :ref:`ci_actions`. |
| 27 | + |
| 28 | +Underlying the CLI, the PTB uses Jinja to dynamically generate project-specific |
| 29 | +workflows. The rendering process is supported by the ``github_template_dict`` found in |
| 30 | +your ``noxconfig.py::PROJECT_CONFIG``. This dictionary is inherited by default from |
| 31 | +``BaseConfig.py``, ensuring a standardized baseline that can be easily overridden, if |
| 32 | +necessary. |
| 33 | + |
| 34 | +.. literalinclude:: ../../../../exasol/toolbox/config.py |
| 35 | + :language: python |
| 36 | + :start-at: github_template_dict |
| 37 | + |
| 38 | + |
| 39 | +Workflows |
| 40 | +--------- |
| 41 | + |
| 42 | +.. list-table:: |
| 43 | + :widths: 25 25 50 |
| 44 | + :header-rows: 1 |
| 45 | + |
| 46 | + * - Filename |
| 47 | + - Run on |
| 48 | + - Description |
| 49 | + * - ``build-and-publish.yml`` |
| 50 | + - Workflow call |
| 51 | + - Packages the distribution and publishes it to PyPi and GitHub. |
| 52 | + * - ``cd.yml`` |
| 53 | + - Push with new tag |
| 54 | + - Manages continuous delivery by calling ``check-release-tag.yml``, |
| 55 | + ``build-and-publish.yml``, and ``gh-pages.yml``. See :ref:`cd_yml` |
| 56 | + for a graph of workflow calls. |
| 57 | + * - ``check-release-tag.yml`` |
| 58 | + - Workflow call |
| 59 | + - Verifies that the release tag matches the project's internal versioning. |
| 60 | + * - ``checks.yml`` |
| 61 | + - Workflow call |
| 62 | + - Executes many small & fast checks: builds documentation and validates |
| 63 | + cross-references (AKA. "links") to be valid,runs various linters |
| 64 | + (security, type checks, etc.), and unit tests. |
| 65 | + * - ``ci.yml`` |
| 66 | + - Pull request and monthly |
| 67 | + - Executes the continuous integration suite by calling ``merge-gate.yml`` and |
| 68 | + ``report.yml``. See :ref:`ci_yml` for a graph of workflow calls. |
| 69 | + * - ``gh-pages.yml`` |
| 70 | + - Workflow call |
| 71 | + - Builds the documentation and deploys it to GitHub Pages. |
| 72 | + * - ``matrix-all.yml`` |
| 73 | + - Workflow call |
| 74 | + - Calls Nox session ``matrix:all``, which typically evaluates ``exasol_versions`` |
| 75 | + and ``python_versions`` from the ``PROJECT_CONFIG``. |
| 76 | + * - ``matrix-exasol.yml`` |
| 77 | + - Workflow call |
| 78 | + - Calls Nox session ``matrix:exasol`` to get the ``exasol_versions`` from the |
| 79 | + ``PROJECT_CONFIG``. |
| 80 | + * - ``matrix-python.yml`` |
| 81 | + - Workflow call |
| 82 | + - Calls Nox session ``matrix:python`` to get the ``python_versions`` from the |
| 83 | + ``PROJECT_CONFIG``. |
| 84 | + * - ``merge-gate.yml`` |
| 85 | + - Workflow call |
| 86 | + - Acts as a final status check (gatekeeper) to ensure all required CI steps have |
| 87 | + passed before allowing to merge the branch of your pull request to the |
| 88 | + default branch of the repository. e.g. ``main``. |
| 89 | + * - ``pr-merge.yml`` |
| 90 | + - Push to main |
| 91 | + - Runs ``checks.yml``, ``gh-pages.yml``, and ``report.yml``. See |
| 92 | + :ref:`pr_merge_yml` for a graph of called workflows. |
| 93 | + * - ``report.yml`` |
| 94 | + - Workflow call |
| 95 | + - Downloads results from code coverage analysis and linting, |
| 96 | + creates a summary displayed by GitHub as result of running |
| 97 | + the action, and uploads the results to Sonar. |
| 98 | + * - ``slow-checks.yml`` |
| 99 | + - Workflow call |
| 100 | + - Runs long-running checks, which typically involve an Exasol database instance. |
| 101 | + |
| 102 | +.. _ci_actions: |
| 103 | + |
| 104 | +CI Actions |
| 105 | +---------- |
| 106 | + |
| 107 | +.. _ci_yml: |
| 108 | + |
| 109 | +Pull Request |
| 110 | +^^^^^^^^^^^^ |
| 111 | + |
| 112 | +When any pull request is opened, synchronized, or reopened, then the ``ci.yml`` will be |
| 113 | +triggered. |
| 114 | + |
| 115 | +When configured as described on :ref:`github_workflows_configuration`, the |
| 116 | +``run-slow-tests`` job requires a developer to manually approve executing the slower |
| 117 | +workflows, like ``slow-checks.yml``. This allows developers to update their pull |
| 118 | +request more often and to only periodically run the more time-expensive tests. |
| 119 | + |
| 120 | +If one of the jobs in the chain fails (or if ``run-slow-tests`` is not approved), |
| 121 | +then the subsequent jobs will not be started. |
| 122 | + |
| 123 | +.. mermaid:: |
| 124 | + |
| 125 | + graph TD |
| 126 | + %% Workflow Triggers (Solid Lines) |
| 127 | + ci[ci.yml] --> merge-gate[merge-gate.yml] |
| 128 | + ci --> metrics[report.yml] |
| 129 | + |
| 130 | + merge-gate --> fast-checks[checks.yml] |
| 131 | + merge-gate --> run-slow-tests[run-slow-tests] |
| 132 | + run-slow-tests -.->|needs| slow-checks[slow-checks.yml] |
| 133 | + |
| 134 | + %% Dependencies / Waiting (Dotted Lines) |
| 135 | + fast-checks -.->|needs| approve-merge[approve-merge] |
| 136 | + slow-checks -.->|needs| approve-merge |
| 137 | + |
| 138 | + %% Final Dependency |
| 139 | + approve-merge -.->|needs| metrics |
| 140 | + |
| 141 | + %% Visual Styling to distinguish jobs |
| 142 | + style approve-merge fill:#fff,stroke:#333,stroke-dasharray: 5 5 |
| 143 | + style run-slow-tests fill:#fff,stroke:#333,stroke-dasharray: 5 5 |
| 144 | + |
| 145 | + |
| 146 | +.. _pr_merge_yml: |
| 147 | + |
| 148 | +Merge |
| 149 | +^^^^^ |
| 150 | + |
| 151 | +When a pull request is merged to main, then the ``pr-merge.yml`` workflow is activated. |
| 152 | + |
| 153 | +.. mermaid:: |
| 154 | + :name: merge-diagram |
| 155 | + |
| 156 | + graph TD |
| 157 | + %% Workflow Triggers (Solid Lines) |
| 158 | + pr-merge[pr-merge.yml] --> checks[checks.yml] |
| 159 | + pr-merge --> publish-docs[publish-docs.yml] |
| 160 | + |
| 161 | + %% Dependencies / Waiting (Dotted Lines) |
| 162 | + checks -.->|needs| report[report.yml] |
| 163 | + |
| 164 | +.. _cd_yml: |
| 165 | + |
| 166 | +Release |
| 167 | +^^^^^^^ |
| 168 | + |
| 169 | +When the nox session ``release:trigger`` is used, a new tag is created & pushed |
| 170 | +to main. This starts the release process by activating the ``cd.yml`` workflow. |
| 171 | + |
| 172 | +.. mermaid:: |
| 173 | + :name: release-diagram |
| 174 | + |
| 175 | + graph TD |
| 176 | + %% Workflow Triggers (Solid Lines) |
| 177 | + cd[cd.yml] --> check-release-tag[check-release-tag.yml] |
| 178 | + |
| 179 | + %% Dependencies / Waiting (Dotted Lines) |
| 180 | + check-release-tag -.->|needs| build-and-publish[build-and-publish.yml] |
| 181 | + build-and-publish -.->|needs| gh-pages[gh-pages.yml] |
0 commit comments