Skip to Content
Technical Articles
Author's profile photo Enno Wulff

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

Assigned tags

      7 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Steffen Bühl
      Steffen Bühl

      Thats great - do you track the issues somehow? (e.g. add a reference to commit hash + linenumber) to avoid duplicates? (however this wont prevent duplicates, because those values could change) . maybe add the ticket-id to the sourcecode (although this creates another commit that will trigger another build)?

      Author's profile photo Enno Wulff
      Enno Wulff
      Blog Post Author

      Hey Steffen Bühl 

      thanks for your comment! This feature might need some practical experience… I am not sure how this works or reacts on changes.

      /edit: so far it looks quite good. the workflow seems to recognize the correct code line or the name of the issue. no duplicates. 

      Author's profile photo Jhodel Cailan
      Jhodel Cailan

      Hi Enno Wulff

      This is indeed so cool! Automation is always cool! Thanks for sharing! Will definitely add this to my workflow.

      Author's profile photo Enno Wulff
      Enno Wulff
      Blog Post Author

      Thanks for your feedback @jhodel18!

      Author's profile photo Michael Keller
      Michael Keller

      Another small building block in a big topic. Really, very cool! I believe everyone reading your blog can feel and see your happiness about this possibility 🙂

      Author's profile photo Enno Wulff
      Enno Wulff
      Blog Post Author

      If you only could see all of the memes I created in this happiness Michael Keller … ?

      Author's profile photo VIKRAM P
      VIKRAM P

      Thanks for sharing Enno Wulff  .