Skip to content

Commit c7b2f61

Browse files
authored
[GHA] [DOCS] Reusable workflows and workflow organisation document (openvinotoolkit#22380)
* start with organisation doc * add section about adding * add examples, clearer wording
1 parent 1fbfe0a commit c7b2f61

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,73 @@
11
# Overview of the Reusable Workflows used in the OpenVINO GitHub Actions CI
2+
3+
To reduce duplication and increase maintainability, the common jobs from different workflows are extracted into _reusable workflows_.
4+
5+
You can find more information about reusing actions and workflows [here](https://github.com/marketplace?type=actions) and [here](https://docs.github.com/en/actions/using-workflows/reusing-workflows).
6+
7+
The reusable workflows are referenced as `jobs` in several validation workflows. They are structured and behave like [normal jobs](./overview.md#single-job-overview) with their own environment, runner and steps to execute.
8+
9+
This document describes the setup used in the OpenVINO GitHub Actions.
10+
11+
## Workflows Organisation
12+
13+
You can find all the workflows for this repository [here](../../../../.github/workflows).
14+
15+
Two categories of the workflows are present:
16+
* the workflow files starting with the OS name: e.g. [`linux.yml`](./../../../../.github/workflows/linux.yml), [`windows_conditional_compilation.yml`](./../../../../.github/workflows/windows_conditional_compilation.yml)
17+
* the workflow files starting with the word `job`: e.g., [`job_cxx_unit_tests.yml`](./../../../../.github/workflows/job_cxx_unit_tests.yml), [`job_samples_tests.yml`](./../../../../.github/workflows/job_samples_tests.yml)
18+
19+
The former are the validation workflows incorporating building and testing of the corresponding OS, architecture and set of tools. Read more [here](./overview.md#structure-of-the-workflows) about these workflows.
20+
21+
The latter are the _reusable workflows_ that are used as jobs in several other workflows.
22+
23+
For example, the [`job_python_unit_tests.yml`](./../../../../.github/workflows/job_python_unit_tests.yml) reusable workflow is used in the [`linux.yml`](./../../../../.github/workflows/linux.yml), [`linux_arm64.yml`](./../../../../.github/workflows/linux_arm64.yml),
24+
[`mac.yml`](./../../../../.github/workflows/mac.yml) and [`mac_arm64.yml`](./../../../../.github/workflows/mac_arm64.yml) workflows as a `Python_Unit_Tests` job:
25+
```yaml
26+
Python_Unit_Tests:
27+
name: Python unit tests
28+
needs: [ Build, Smart_CI ]
29+
uses: ./.github/workflows/job_python_unit_tests.yml
30+
with:
31+
runner: 'aks-linux-4-cores-16gb'
32+
container: '{"image": "openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04", "volumes": ["/mount:/mount"]}'
33+
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
34+
```
35+
36+
Refer to the next section for the usage reference.
37+
38+
## Using Reusable Workflows
39+
40+
Refer to the [official GitHub Actions documentation](https://docs.github.com/en/actions/using-workflows/reusing-workflows#calling-a-reusable-workflow) for a complete reference.
41+
42+
To use a reusable workflow, it should be referenced as a `job`. The [`job_python_unit_tests.yml`](./../../../../.github/workflows/job_python_unit_tests.yml) reusable workflow example
43+
in the [`linux.yml`](./../../../../.github/workflows/linux.yml) workflow:
44+
```yaml
45+
Python_Unit_Tests:
46+
name: Python unit tests
47+
needs: [ Build, Smart_CI ]
48+
uses: ./.github/workflows/job_python_unit_tests.yml
49+
with:
50+
runner: 'aks-linux-4-cores-16gb'
51+
container: '{"image": "openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04", "volumes": ["/mount:/mount"]}'
52+
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
53+
```
54+
where:
55+
* `name` - the display name of the job
56+
* `needs` - the job's needs, i.e., the jobs that should be completed before this one starts
57+
* `uses` - the path to the reusable workflow
58+
* `with` - the input keys that will be passed to the reusable workflow. Refer to the workflow file to learn more about its inputs, refer to the [official GitHub Actions documentation](https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow) for a syntax reference
59+
60+
## Adding Reusable Workflows
61+
62+
If you would like to add new similar stages to several workflows, consider creating a reusable workflow to reduce duplication.
63+
64+
The reusable workflows in the OpenVINO GitHub Actions CI usually have:
65+
* the filename starting with `job_`, e.g., [`job_cxx_unit_tests.yml`](./../../../../.github/workflows/job_cxx_unit_tests.yml)
66+
* the `runner` input - the runner name that will be used to execute the steps in a job, learn more about the available runners and how to use them [here](./runners.md)
67+
* the `container` input - JSON to be converted to the value of the "container" configuration for the job, learn more about using Docker in the workflows [here](./docker_images.md)
68+
* *Optional* the `affected-components` input - components that are affected by changes in the commit defined by the Smart CI Action, learn more about the Smart CI system [here](./smart_ci.md)
69+
70+
*Note*: Per the [GitHub documentation](https://docs.github.com/en/actions/using-workflows/about-workflows#about-workflows), all workflows should be placed under [`./.github/workflows`](./../../../../.github/workflows).
71+
72+
As the reusable workflows are structured and behave like jobs, refer to [this document](./adding_tests.md) to learn more about creating a job and
73+
use the information about the reusable workflows to make a job into a reusable workflow.

0 commit comments

Comments
 (0)