Package: depends-on
depends-on-actionGitHub action to install dependent Pull Requests and configure them to be used
by later steps.OverviewThis action allows you to install Pull Request dependencies when the workflow
action is triggered.You need this action if your project is split into multiple repositories, and you can have Pull Requests that must be tested together. It happens often when you have libraries or micro-services in different repositories, and you need to test changes with the programs that use them. Even if you depend on third-party repositories that are not yours, you can use this action to test your Pull Requests with the third-party Pull Requests.How does it work? This GitHub action extracts all the Pull Requests that are declared in the description of the main Pull Request with theDepends-On: <PR url>syntax. You can have multiple dependencies in the description of the main Pull Request by adding multipleDepends-On:lines. For example, if you depend on a Pull Request in theorg/libraryrepository, you can add the following line in the description of your Pull Request:Change to use the new library function

Depends-On: https://github.com/org/library/pull/123If you need to specify a sub-directory for a particular Pull Request, use the following syntax:Depends-On: <PR url>?subdir=<subdir path>This GitHub action then injects the needed modifications in the code to use the other changes.Gerrit and Gitlab changesGerrit and Gitlab dependencies are also supported. Examples:Depends-On: https://gerrit-review.googlesource.com/c/gerrit/+/394841
Depends-On: https://gitlab.com/adblockinc/ext/adblockplus/spec/-/merge_requests/428The detection of the type of change is done in this order:If there is a/c/in the url, it is a Gerrit change.If there isgitlabin the hostname, it is a Gitlab change.It is a Github change.Gitlab credentialsIf you need credentials to access the Gitlab server, you can set the environment variablesGITLAB_TOKENandGITLAB_USERas secrets. Depending on the configuration of your server, you could only needGITLAB_TOKEN.Go langFor a Go lang change, the action addsreplacedirectives for the dependencies inside thego.modfile. This action needs to be placed after installing the Go lang toolchain.PythonThe action replaces entries inrequirements.txtfor a Python change with a-e <local change>or the equivalent forpyproject.toml.JavascriptThe action replaces entries inpackage.jsonfor a Javascript change withfile:<local change>.AnsibleThe action replaces entries inrequirements.ymlfor an Ansible collection change.ContainerThe action auto-detects if a container is present and injects the changes in a compatible way if this is the case.Enabling the actionSample ConfigurationDefining Github Actions requires creating a directory.github/workflowsinside your repository. Inside this directory, you create files processed when various events occur.The simplest example of using this action would be to create the file.github/workflows/pull_request.ymlwith the following contents:---name:Pull Requeston:pull_request:types:[opened,synchronize,reopened]jobs:validate-tests:runs-on:ubuntu-lateststeps:-name:Checkout codeuses:actions/checkout@v4# install the toolchain for your language-name:Extract dependent Pull Requestsuses:depends-on/depends-on-action@0.14.0with:token:${{ secrets.GITHUB_TOKEN }}# optional if needed for Gitlabenv:GITLAB_TOKEN:${{ secrets.GITLAB_TOKEN }}GITLAB_USER:${{ secrets.GITLAB_USER }}# <your usual actions here>check-all-dependencies-are-merged:runs-on:ubuntu-lateststeps:-name:Check all dependent Pull Requests are mergeduses:depends-on/depends-on-action@0.14.0with:token:${{ secrets.GITHUB_TOKEN }}check-unmerged-pr:true# optional if needed for Gitlabenv:GITLAB_TOKEN:${{ secrets.GITLAB_TOKEN }}GITLAB_USER:${{ secrets.GITLAB_USER }}...As demonstrated above, you need at least two pipelines: one or more to do your regular builds and tests injecting the dependent changes and, a specific one to block until the dependent changes are merged.Multiple checkoutsIf your pipeline is cloning multiple git repositories, you could want to inject the dependencies in all these directories. To do so, use theextra-dirsoption with space separated names of directories like this:---name:Pull Requeston:pull_request:types:[opened,synchronize,reopened]jobs:validate-tests:runs-on:ubuntu-lateststeps:-name:Checkout codeuses:actions/checkout@v4-name:Check out an extra diruses:actions/checkout@v4with:repository:org/projpath:proj# install the toolchain for your language-name:Extract dependent Pull Requestsuses:depends-on/depends-on-action@0.14.0with:token:${{ secrets.GITHUB_TOKEN }}extra-dirs:org/proj# <your usual actions here>......Detailsstage 1:javascript programto extract the dependency information from the main change.stage 2:depends_on_stage2 python programto extract the dependent changes.stage 3:depends_on_stage3 python programto inject the dependencies into the main change according to the detected programming languages.When the action is called with thecheck-unmerged-pr: truesetting, stages 1 and 2 are used but not stage 3. Stage 2, in this case, is not extracting the dependent changes on disk but just checking the merge status of all the dependent changes.Usage outside of a GitHub actionIf you want to use the same dependency management in other CI pipelines or in a local test, you can install the python package:$ pip install depends-onand use thedepends_on_stage1script as an entry point taking the URL of the change you want to download in parameter:$ cd <workspace>
$ export GITHUB_TOKEN=<your token>
$ # if you need access to a private Gitlab server
$ export GITLAB_USER=<your user>
$ export GITLAB_TOKEN=<your gitlab token>
$ # Extracting a Github change and its dependencies
$ depends_on_stage1 https://github.com/depends-on/pyprog/pulls/2
$ # Extracting a Gitlab change and its dependencies
$ depends_on_stage1 https://gitlab.com/adblockinc/ext/adblockplus/spec/-/merge_requests/428
$ # Extracting a Gerrit change and its dependencies
$ depends_on_stage1 https://softwarefactory-project.io/r/c/dci-pipeline/+/29700Roadmapstage 1: extract public PRstage 3: go supportstage 2: prevent merging if a dependent PR isn't mergedstage 3: python supportstage 3: python poetry supportstage 3: python subdir supportstage 3: container supportstage 3: javascript supportpython package on pypiNon GitHub action usagestage 2: gerrit supportstage 2: gitlab supportstage 2: multiple checkouts supportstage 3: ansible supportstage 3: custom injectionstage 2: extract private PRstage 3: rust supportstage 2: support stacked changes