Code Monkey home page Code Monkey logo

todo-2-azdo's Introduction

TODO-2-AzDO

This action runs through your recent changes and closes all corresponding AzDO work items if relevant TODO comments were removed in a pushed commit, and converts all newly added TODO comments to new AzDO work items.

Demo

Todo-2-AzDO in action

Screenshot

Todo-2-AzDO result

Usage

Create a workflow file in your .github/workflows/ directory as follows:

todo-2-azdo.yaml

name: "TODO-2-AzDO"
on: ["push"]
jobs:
  build:
    runs-on: "ubuntu-latest"
    steps:
      - uses: "actions/checkout@master"
      - name: "TODO-2-AzDO"
        uses: "jamminroot/todo-2-azdo"
        with:
          TOKEN: ${{ secrets.GITHUB_TOKEN }}
          AZDO_TOKEN: ${{ secrets.AZDO_TOKEN}}
          AZDO_ORGANIZATION: ${{ secrets.AZDO_ORGANIZATION}}
          AZDO_TEAM: ${{ secrets.AZDO_TEAM}}
          AZDO_PROJECT: ${{ secrets.AZDO_PROJECT}}
          AZDO_LANE: "TODOs"
          AZDO_CLOSED: "Closed"
          AZDO_NEW: "New"
          TODO_PATTERN: "(?<=\\/\\/ ?TODO[ :]).+"
          LABEL: "TODO"
          TRIM: ",: \""
          TIMEOUT: 1000
          LINES_BEFORE: 2
          LINES_AFTER: 5
          LABELS_PATTERN: "(?<=\\[).+?(?=\\])"
          LABELS_REPLACE_PATTERN: "\\[(.+?)\\]"
          IGNORED_LINES_LENGTH: 255
          EXCLUDED_PATHS: /FilePath/ToExclude/1|/FilePath/ToExclude/2
          INCLUDED_PATHS: /FilePath/ToExclude/1/Exception|/FilePath/ToExclude/2/Exception
          FILE_PATTERN: ".*cs"
        id: "todo-2-azdo"

NOTE: Keep in mind that you have to escape slashes in regex patterns when putting them to yml

NOTE: Always put values for TOKEN, AZDO_TOKEN as secrets in github action preferences. Consider hiding AZDO_ORGANIZATION, AZDO_TEAM and AZDO_PROJECT if that might concern you.

Inputs

Input Description
TOKEN The GitHub access token to allow us get diff and commit history.
AZDO_TOKEN The Azure DevOps PAT which would allow us manage items (Consider reducing scope to Work Items: Manage).
AZDO_ORGANIZATION The Azure DevOps Organization to use.
AZDO_TEAM The Azure DevOps Team to use.
AZDO_PROJECT The Azure DevOps PAT Project to use.
AZDO_LANE The Azure DevOps lane to put new workitems to.
AZDO_CLOSED The Azure DevOps column to move closed workitems to.
AZDO_NEW The Azure DevOps column to move new workitems to.
TODO_PATTERN Regex pattern used to identify TODO comment. Default is (?<=\\/\\/ ?TODO[ :]).+ for // TODO.
LABEL Label to add to a ticket.
TRIM Set of characters (as a string) to be trimmed from resulting title.
TIMEOUT Delay between requests.
LINES_BEFORE How many lines above // TODO to include to snippet.
LINES_AFTER How many lines after // TODO to include to snippet.
LABELS_PATTERN Regex to parse inlined labels. If empty, they will be left in todo. Default is text inside square brackets.
LABELS_REPLACE_PATTERN Regex to replace inlined labels. Only works when LABELS_PATTERN provided. Default is text with square brackets.
IGNORED_LINES_LENGTH Maximum length of diff line to be processed by action. Useful for binary data (e.g. Unity repos). Ignored if 0.
EXCLUDED_PATHS List of vertical line-separated file paths to be excluded from processing.
INCLUDED_PATHS List of vertical line-separated file paths to be included to processing OR a list of exceptions if EXCLUDED_PATHS is not empty.
FILE_PATTERN Maximum length of diff line to be processed by action. Useful for binary data (e.g. Unity repos). Ignored if empty or whitespace.

NOTE: INCLUDED_PATHS and EXCLUDED_PATHS use | as separator: /Path1|/Path2, each path must start with / and must use it as separator (your OS does not matter in this case, don't worry - that's just to parse diff correctly). Only beginning of the filepath is checked.

NOTE: TODO labels will only be compared if they follow matching comment pattern.

NOTE: For repositories with binary data consider using IGNORED_LINES_LENGTH to avoid regex getting stuck on processing long lines.

NOTE: For repositories with various data types where you only need to check specific file extensions (e.g. Unity repos), consider using FILE_PATTERN to provide regex to match file pattern. It is only matched against after line length check.

NOTE: If excluded paths list is not empty, and included paths list is, all TODOs are processed if they are not under one of those excluded; If excluded paths list is empty, and included paths list is not, only those TODOs are processed which are under one of those in included list; If both lists are not empty, all TODOs are processed if they are not under one of those excluded (and included paths list acts like a list of exceptions).

Examples

Adding TODOs

+// TODO Change method signature [Easy]
void method() {

}

This will create an issue with the title Change method signature with two labels: [Easy] and the one provided in yml.

Removing TODOs

-// TODO Change method signature
void method() {

}

Removing the // TODO comment will close the issue on push.

NOTE: Labels, filenames, issue bodies' contents and line numbers are ignored when parsing existing issues.

Updating TODOs

-// TODO Change method signature
+// TODO [Shower thoughts] Change method signature to something more creative
void method() {

}

Changing the contents of TODO comment will close existing issue (Change method signature) and create new one (Change method signature to something more creative) labelled with 2 labels: [Shower thoughts] and label provided in yml.

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.