@@ -4,13 +4,74 @@ Bootstrap Taskgraph in Decision Task
44This how-to guide outlines the recommended way to bootstrap Taskgraph (and
55other task generation dependencies) in a :term: `Decision Task `.
66
7- If you'd like to follow along, you can download the example
8- :download: `.taskcluster.yml </tutorials/example-taskcluster.yml >` file.
7+ Using the Pre-Built Docker Images
8+ ---------------------------------
9+
10+ The simplest way to make Taskgraph available to your Decision task is to use
11+ Taskgraph's pre-built Docker images under the `mozillareleases/taskgraph `_ Docker Hub
12+ repository.
13+
14+ In your Decision task definition in ``.taskcluster.yml ``, add the following to the task's
15+ ``payload `` section:
16+
17+ .. code-block :: yaml
18+
19+ payload :
20+ image : mozillareleases/taskgraph:decision-latest
21+
22+ This will ensure your Decision task always run with the latest version of Taskgraph.
23+ Of course, it's best practice to pin your CI dependencies, so it's recommended to pin
24+ to a specific version:
25+
26+ .. code-block :: yaml
27+
28+ payload :
29+ image : mozillareleases/taskgraph:decision-v7.3.0
30+
31+ While not required, it's also best practice to specify the image hash:
32+
33+ .. code-block :: yaml
34+
35+ payload :
36+ image : mozillareleases/taskgraph:decision-v7.3.0@sha256:f954e54d427d08b18954a4ff4541d43c76c476d0738f341e4fa82a959939d3fa
37+
38+ The hash can be found on the Docker Hub page for the specific tag you are
39+ pinning to.
40+
41+ .. _mozillareleases/taskgraph : https://hub.docker.com/r/mozillareleases/taskgraph/tags
42+
43+
44+ Using a Python Requirements File
45+ --------------------------------
46+
47+ Sometimes you might have more complex generation logic that requires other
48+ packages in addition to ``taskgraph ``. In this case you'll want to use a
49+ `requirements file `_.
50+
51+ Like before, we'll use a pre-built Docker image provided by Taskgraph:
52+
53+ .. code-block :: yaml
54+
55+ payload :
56+ image : mozillareleases/taskgraph:run-task-v7.3.0
57+
58+ The only difference with this ``run-task `` image, is that it *only * contains
59+ the ``run-task `` script necessary to bootstrap the repository and not the full
60+ Taskgraph package. It leaves how to get Taskgraph bootstrapped into the task up
61+ to you.
62+
63+ This section outlines the recommended way to do that.
64+
65+ .. note ::
66+ If you'd like to follow along, you can download the example
67+ :download: `.taskcluster.yml </tutorials/example-taskcluster.yml >` file.
68+
69+ .. _requirements file : https://pip.pypa.io/en/stable/reference/requirements-file-format/
970
1071.. _define requirements :
1172
1273Define Requirements
13- -------------------
74+ ~~~~~~~~~~~~~~~~~~~
1475
1576We'll use a tool called `pip-compile `_ to help generate the
1677``requirements.txt `` that will contain our Decision task dependencies,
@@ -27,35 +88,41 @@ First make sure you have ``pip-compile`` installed:
2788
2889 pip install pip-tools
2990
30- Next, create the ``requirements.in `` file:
91+ Next, create the ``requirements.in `` file. For this example, let's pretend that
92+ in addition to ``taskcluster-taskgraph `` we also want to depend on
93+ ``requests ``:
3194
3295.. code-block :: bash
3396
3497 cd taskcluster
35- echo " taskcluster-taskgraph" > requirements.in
98+ cat << EOF > requirements.in
99+ taskcluster-taskgraph
100+ requests
101+ EOF
102+
36103 # This works best if you use the same Python as the one used in the Decision
37- # image (currently 3.8 ).
104+ # image (currently 3.11 ).
38105 pip-compile --generate-hashes --output-file requirements.txt requirements.in
39106
40107.. note::
41108
42109 You may add ` version specifiers` _ to packages (e.g,
43- ``taskcluster-taskgraph==1.1.4 ``), but either way the actual version that
110+ ` ` taskcluster-taskgraph==7.3.0 ` ` ), but either way the actual version that
44111 gets used will be pinned once we generate the ` ` requirements.txt` ` .
45112
46- If you intend to create transforms that require additional packages, add them to
113+ If you end up creating transforms that require additional packages, add them to
47114` ` requirements.in` ` and re-generate the lock file.
48115
49116.. _pip-compile: https://github.com/jazzband/pip-tools
50117.. _hashin: https://github.com/peterbe/hashin
51118.. _version specifiers: https://pip.pypa.io/en/stable/cli/pip_install/#requirement-specifiers
52119
53120Instruct ` ` run-task` ` to Install Requirements
54- ---------------------------------------------
121+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55122
56- The `decision docker images `_ provided by Taskgraph contain a script called
57- ` run-task `_. This script acts as a wrapper around the command you'd like to run
58- and handles some initial setup such as cloning repositories needed by the task.
123+ The ` docker images` _ provided by Taskgraph contain a script called ` run-task ` _.
124+ This script acts as a wrapper around the command you'd like to run and handles
125+ some initial setup such as cloning repositories needed by the task.
59126
60127When ` ` run-task` ` clones a repository, it can optionally install Python
61128dependencies that are defined within it. We accomplish this with a set of
@@ -107,11 +174,11 @@ Now ``run-task`` will both clone your repo, as well as install any packages
107174defined in ` ` taskcluster/requirements.txt` ` , ensuring Taskgraph is bootstrapped
108175and ready to go.
109176
110- .. _ decision docker images : https://hub.docker.com/repository/docker/mozillareleases/taskgraph
177+ .. _docker images: https://hub.docker.com/repository/docker/mozillareleases/taskgraph
111178.. _run-task: https://github.com/taskcluster/taskgraph/blob/main/src/taskgraph/run-task/run-task
112179
113180Upgrading Taskgraph
114- -------------------
181+ ~~~~~~~~~~~~~~~~~~~
115182
116183To upgrade Taskgraph to a newer version, re-generate the ` ` requirements.txt` `
117184file:
@@ -132,7 +199,7 @@ If you pinned the package to a specific version don't forget to update
132199.. _semantic versioning: https://semver.org
133200
134201Testing Pre-Release Versions of Taskgraph
135- -----------------------------------------
202+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
136203
137204Sometimes you may wish to test against pre-release revisions of Taskgraph,
138205especially if you are working on changes to Taskgraph itself. This can be
0 commit comments