prestoncabe / dmn-benefit-toolbox

Scaffolding for modeling public benefits' eligibility logic with Decision Model and Notation (DMN)
2 stars 1 forks source link

Explore GitDoc for abstracting version control #14

Closed prestoncabe closed 3 months ago

prestoncabe commented 3 months ago

https://github.com/lostintangent/gitdoc

The vision: for DMN files in the repo specifically, GitDoc would automatically create commits and push/pull to/from Github.

This seems promising for both avoiding merge conflicts and making it simpler to use git (or rather not use, but still take advantage of) for non-programmers.

(It also might make a mess... maybe most useful once the repo is actually deployed in an operational setting?)

prestoncabe commented 3 months ago

I spent (way too much) time trying to figure out how to get VS Code Problem Matchers to work. Why? Because GitDoc can use the "Problems" panel of VS Code to prevent automatic commits of errors.

While I was able to get stuff to show up on the Problems panel, I had trouble getting it to work properly. The Quarkus dev server does not log DMN errors in such a way that can be easily integrated with the VS Code Problems system. For example, log entries for errors don't mention the file or line number in which the error occurred. Some log entries do mention the DMN model name, but this is typically the DMN file name without the .dmn extension and VS Code can't map that to a file in the project.

Stepping back, I don't think that GitDoc should be a main feature of this project, but instead of a yet-to-be-created related project that I've been mulling that would streamline the editing and deployment experience for DMN via a custom web application.

I think we should keep the scope of this project focused squarely on DMN building blocks that are useful for developing benefits-related logic (eligibility and estimation rules specifically for now).

Here is where I ended up with the tasks.json experimenting w/ problem matchers:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Develop: quarkus dev server",
            "type": "shell",
            "command": "bin/dev",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "runOptions": {
                "runOn": "folderOpen"
            },
            "isBackground": true,
            "problemMatcher": [
                {
                    "fileLocation": [
                        "relative",
                        "${workspaceFolder}/src/main/resources/"
                    ],
                    "pattern": [
                        {

                            "regexp": "^.*\\s.*\\sERROR.*\\)\\s(.*\\.dmn):\\s(.*)$",
                            "kind": "file",
                            "file": 1,
                            "message": 2
                        }
                    ],
                    "background": {
                        "activeOnStart": true,
                        "beginsPattern": "^.*Restarting quarkus due to changes.*$",
                        "endsPattern": "^.*Live reload total time.*$"
                    }
                },
                {
                    "fileLocation": [
                        "relative",
                        "${workspaceFolder}/src/main/resources/"
                    ],
                    "pattern": [
                        {
                            // only works if you rename the DMN model to include a .dmn extension
                            // (and this means that the REST endpoint will include the .dmn extension...)
                            "regexp": "^.*\\s.*\\sERROR.*\\)\\s(.*\\.dmn):\\s(.*)$",
                            "kind": "file",
                            "file": 1,
                            "message": 2
                        }
                    ],
                    "background": {
                        "activeOnStart": true,
                        // this works (will refresh the Problems panel if quarkus is reload)
                        // ... but quarkus won't live reload unless a request is made to the REST API
                        // ... maybe could workaround by hooking into the DMN Editor callback that can run on save?
                        "beginsPattern": "^.*Restarting quarkus due to changes.*$",
                        "endsPattern": "^.*Live reload total time.*$"
                    }
                },
                {
                    "fileLocation": [
                        "relative",
                        "${workspaceFolder}/src/main/resources/"
                    ],
                    "pattern": [
                        {
                            // DMNFEELHelper is only one of the patterns that would need to be recognized...
                            "regexp": "^.*ERROR\\s.*(DMNFEELHelper)\\] \\(Quarkus Main Thread\\)\\s(.*$)",
                            "kind": "file",
                            "file": 1,
                            "message": 2
                        }
                    ],
                    "background": {
                        "activeOnStart": true,
                        "beginsPattern": "^.*Restarting quarkus due to changes.*$",
                        "endsPattern": "^.*Live reload total time.*$"
                    }
                }
            ],
        }
    ]
}