Git Product home page Git Product logo

minimum-dependency-generator's Introduction

GitHub Action - Minimum Dependency Generator

Unit Tests Integration Test


A GitHub Action to generate minimum Python dependencies.

Usage

This GitHub Action provides a task to generate the minimum Python given 1 or more requirements. The requirements can be defined in text files or a setup.cfg

Text Files

steps:
  - name: Run Minimum Dependency Generator
    id: min_dep_gen
    uses: alteryx/[email protected]
    with:
      paths: 'test-requirements.txt requirements.txt'
  - name: Save the output minimum requirements
    run: printf "${{ steps.min_dep_gen.outputs.min_reqs }}" >> generated-min-reqs.txt

setup.cfg

steps:
  - name: Run Minimum Dependency Generator
    id: min_dep_gen
    uses: alteryx/[email protected]
    with:
      paths: 'setup.cfg'
      options: 'install_requires setup_requires'
      extras_require: 'dev test'
  - name: Save the output minimum requirements
    run: printf "${{ steps.min_dep_gen.outputs.min_reqs }}" >> generated-min-reqs.txt
  • The options can either be install_requires, or setup_requires, or both.
  • The extras_require is optional, and depends on if you package has plugin-like dependencies.
  • However, either options or extra_requires must be defined (or both).

The returned value of a task is available in later steps from the output min_reqs.

steps.<step id>.outputs.min_reqs

Example

This workflow uses the task to generate minimum dependencies, save the output to a text file, and then will generated an Automated MR if there is a change in the minimum dependencies.

# .github/workflows/minimum_dependency_checker.yml
name: Minimum Dependency Checker
on:
  push:
    branches:
      - main
    paths:
      - 'requirements.txt'
      - 'test-requirements.txt'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.ref }}
          repository: ${{ github.event.pull_request.head.repo.full_name }}
      - name: Set up python 3.8
        uses: actions/setup-python@v2
        with:
          python-version: 3.8
      - name: Run Minimum Dependency Generator
        id: min_dep_gen
        uses: alteryx/[email protected]
        with:
          paths: 'test-requirements.txt requirements.txt'
      - name: Update minimum core dependencies
        run: |
          printf "${{ steps.min_dep_gen.outputs.min_reqs }}" >> my_package/deps/minimum_requirements.txt
      - name: Create Pull Request
        uses: FeatureLabs/create-pull-request@v3
        with:
          token: ${{ secrets.REPO_SCOPED_TOKEN }}
          commit-message: Update minimum dependencies
          title: Automated Minimum Dependency Updates
          author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
          body: "This is an auto-generated PR with **minimum** dependency updates.
                 Please do not delete the `min-dep-update` branch because it's needed by the auto-dependency bot."
          branch: min-dep-update
          branch-suffix: short-commit-hash
          base: main

If you have a setup.cfg, you will need to change the paths argument, and specify either options or extra_requires (or you can do both).

To install this workflow, add the file above to the following location in your repository.

.github
└── workflows
    └── minimum_dependency_checker.yml

minimum-dependency-generator's People

Contributors

gsheni avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.