Skip to content
microsoft image/svg+xml

GitHub Action

Python Actions Collection

0.7.3 Latest version

Python Actions Collection

microsoft image/svg+xml

Python Actions Collection

Run actions for Python Project on pull requests to improve code review experience

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Python Actions Collection

uses: microsoft/action-python@0.7.3

Learn more about this action in microsoft/action-python

Choose a version

action-python

Test reviewdog depup release GitHub release (latest SemVer) action-bumpr supported

This repo contains a action to run various Python tools including:

Input

inputs:
  black:
    description: |
      Run Black
      Default is false.
    default: false
  bandit:
    description: |
      Run Bandit
      Default is false.
    default: false
  pylint:
    description: |
      Run Pylint
      Default is false.
    default: false
  pyright:
    description: |
      Run Pyright
      Default is false.
    default: false
  flake8:
    description: |
      Run Flake8
      Default is false.
    default: false
  testing:
    description: |
      Run tests with PyTest
      Default is false.
    default: false
  publish:
    description: |
      Publish to PyPi
      Default is false
    default: false
  publish_url:
    description: |
      PyPi Target. Use this to point to private or test locations.      
      Default https://pypi.org
    defualt: 'https://pypi.org'
  github_token:
    description: 'GITHUB_TOKEN'
    default: '${{ github.token }}'
  workdir:
    description: 'Working directory relative to the root directory.'
    default: 'src'
  ### Flags for reviewdog ###
  level:
    description: 'Report level for reviewdog [info,warning,error]'
    default: 'error'
  reporter:
    description: 'Reporter of reviewdog command [github-pr-check,github-pr-review].'
    default: 'github-pr-check'
  filter_mode:
    description: |
      Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
      Default is added.
    default: 'added'
  fail_on_error:
    description: |
      Exit code for reviewdog when errors are found [true,false]
      Default is `false`.
    default: 'false'
  reviewdog_flags:
    description: 'Additional reviewdog flags'
    default: ''
  toml:
    description: |
      pyproject.toml location.
      Default pyproject.toml
    default: 'pyproject.toml'
  pylint_rc:
    description: '.pylintrc configuration file'
    default: '.pylintrc'

Usage

name: Pull Request
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  workflow_dispatch:

jobs:
  linting:
    runs-on: ubuntu-latest
    steps:
      - name: Black
        uses: microsoft/action-python@0.7.0
        with:
          black: true

      - name: Bandit
        uses: microsoft/action-python@0.7.0
        with:          
          bandit: true

      - name: Pylint
        uses: microsoft/action-python@0.7.0
        with:
          pylint: true
          
      - name: Pyright
        uses: microsoft/action-python@0.7.0
        with:          
          pyright: true
          
      - name: Flake8
        uses: microsoft/action-python@0.7.0
        with:          
          flake8: true

  testing:
    runs-on: ubuntu-latest
    steps:    
      - name: Pytest
        uses: microsoft/action-python@0.7.0
        with:          
          testing: true

Development

Release

You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch). Pushing tag manually by yourself also work.

This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3. ref: https://help.github.com/en/articles/about-actions#versioning-your-action