Skip to Content
Technical Articles

Automatically generate issues from source code [abapGit]

This. Is. So. Cool!!

 

Thanks to the latest videos of devtoberfest of Johannes Nicolai I learned a lot about github possibilities. In detail I learned about github actions.

There is one action workflow that can create issues from your source code automatically. (Actually there are a lot more, but I tried to use the first from the google search and  it worked out fine):

TODO to issue

 

It really works!

I created a test repository where I wrote a simple demo program that needed optimization.

Overview

If you want to use actions in your repository, then you need to define actions in a YAML-file. You can react on a variety of events. If the event is raised, the action file be executed.

See here the actions page of my demo repository where my workflows are being executed:

Setup

You have to create a YML-file in your .github/workflows directory. If the directory does not exist, create it. I named my action todo2issue.yml:

name: todo2issue
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: TODO to Issue
        uses: alstr/todo-to-issue-action@v2.0
        with:
          REPO: ${{ github.repository }}
          BEFORE: ${{ github.event.before }}
          SHA: ${{ github.sha }}
          TOKEN: ${{ secrets.GITHUB_TOKEN }}
          LABEL: "\"TODO"
          COMMENT_MARKER: "\""
          CLOSE_ISSUES: true
        id: "todo"

make sure that actions are allowed in your repository. The option is generally active. You will have to deactivate it manually, so you should not need to do something.

The most important thing is that we adapt the COMMENT_MARKER. In ABAP we have two possibilities to mark a comment:

  • ‘*’ at the beginning of a line
  • ” at the end of any line

I decided to use the quotation mark as comment marker because it is in my opinion the best way to comment a TODO. Furthermore I had some trouble of using ‘*’ as comment marker in the YML file.

Usage

Create an abapGit project in github and assign it in your SAP system. From now on you can add a comment “TODO in your source code and the action handler in github will automatically issues from this todo:

LOOP AT langs INTO DATA(lang). "TODO use ALV grid for display
  WRITE: / lang-sptxt.
ENDLOOP.

Closing issues

There is one label in the YML file which can be set: CLOSE_ISSUES

The workflow will then automatically recognizes when a TODO has been deleted and will close the corresponding issue.

Additional Features

There are two other features which I didn’t try so far but they look promising

Multiline Todos

You can try to use todos with a comment

" TODO Come up with a more imaginative greeting 
" Everyone uses hello world and it's boring.

Dynamic labels

You have the possibility to use additional labels for the issue:

" labels: enhancement, help wanted

Closure

I can’t wait to using this cool feature in my next project!

Have fun!

~Enno

7 Comments
You must be Logged on to comment or reply to a post.