Skip to main content

A Python library to manage dependencies between changes.

Project description

depends-on-action

GitHub action to install dependent Pull Requests and configure them to be used by later steps.

Overview

This 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 the Depends-On: <PR url> syntax. You can have multiple dependencies in the description of the main Pull Request by adding multiple Depends-On: lines. For example, if you depend on a Pull Request in the org/library repository, 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/123

If 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 changes in the code to use the other Pull Requests.

Go lang

For a Go lang change, the action adds replace directives for the dependencies inside the go.mod file. This action needs to be placed after installing the Go lang toolchain.

Python

The action replaces entries in requirements.txt for a Python change with a -e <local change> or the equivalent for pyproject.toml.

Javascript

The action replaces entries in package.json for Javascript change with file:<local change>.

Container

The action auto-detects if a container is present and injects the changes in a compatible way if this is the case.

Enabling the action

Sample Configuration

Defining Github Actions requires creating a directory .github/workflows inside 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.yml with the following contents:

---
name: Pull Request
on:
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  validate-tests:
    runs-on: ubuntu-latest
    steps:

      - name: Checkout code
        uses: actions/checkout@master

      # install the toolchain for your language

      - name: Extract dependent Pull Requests
        uses: depends-on/depends-on-action@main
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

      # <your usual actions here>

  check-all-dependencies-are-merged:
    runs-on: ubuntu-latest
    steps:

      - name: Checkout code
        uses: actions/checkout@master

      - name: Check all dependent Pull Requests are merged
        uses: depends-on/depends-on-action@main
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          check-unmerged-pr: true
...

You need two pipelines: one to do your regular builds and tests and the second to block until the dependent PR are merged.

Details

When the action is called with the check-unmerged-pr: true setting, stages 1 and 2 are used but not stage 3. Stage 2, in this case, is not extracting the dependent PR on disk but just checking the merge status of all the dependent PR.

Roadmap

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

depends-on-0.9.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

depends_on-0.9.0-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file depends-on-0.9.0.tar.gz.

File metadata

  • Download URL: depends-on-0.9.0.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for depends-on-0.9.0.tar.gz
Algorithm Hash digest
SHA256 05979630dfb81c1ffc6040e7b81d936ab4bab5b46df58598df38574f40e8fc10
MD5 6cfa104e79c8a4d711048d736d8d9e10
BLAKE2b-256 443309f65c171574d35e8b72669d4a2a69f369bd47cad8e4b4e20b11460adb91

See more details on using hashes here.

File details

Details for the file depends_on-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: depends_on-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for depends_on-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9d65172cde770144c0ed0663d1469c578f26931eece49f79e9e55d70c89cd18
MD5 8ff4372d7417c11281e425e7804b2cc3
BLAKE2b-256 f90d815eda1571f39241d23631e6d721fd28ac84956a09d0209f23745cfd1a92

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page