linear-b / gitstream

/:\ gitStream - Workflow automation for your git repo. Use YAML to auto-assign reviewers, auto-merge PRs, automatic PR labeler, and more.
https://gitstream.cm
Apache License 2.0
254 stars 30 forks source link

Error in .cm/gitstream.cm - undefined #456

Closed shaynekasai closed 6 months ago

shaynekasai commented 6 months ago

Describe the bug

Upon installation of Gitstream we get the following error:

Error in .cm/gitstream.cm - undefined

To Reproduce

We installed gitstream, both .cm/gitstream.cm and .github/workflows/gitstream.yml, and we also have it configured GitStream in our GitHub. We see it running however, we get a syntax error

both cm and yml files are verbatim from the documentation and merged into master

Expected behavior

Ideally we would see the regular output of Gitstream or at least better error output to debug the issue

vim-zz commented 6 months ago

Hi @shaynekasai, please share the GitHub action log, or at least it's end where the error is presented.

One reason I can think of, is that something in your tooling changed files content, see: troubleshooting -- to be on the safe side, use a simple tool like notepad or the builtin GitHub editor, and copy the source files again.

shaynekasai commented 6 months ago

Awesome thanks for responding so quickly

warning: refname 'upstream/diana/test-branch' is ambiguous.
warning: refname 'upstream/diana/test-branch' is ambiguous.
warning: refname 'upstream/diana/test-branch' is ambiguous.
Already on 'upstream/diana/test-branch'
warning: refname '@{-1}' is ambiguous.
Already on 'upstream/diana/test-branch'
warning: refname 'upstream/diana/test-branch' is ambiguous.
Failed while parsing CM file, to extract CM config
Error: {
  "message": "Error in .cm/gitstream.cm - undefined",
  "owner": "retreatguru",
  "repo": "programs",
  "branch": "diana/test-branch"
}
Error: Process completed with exit code 60.

The config is cut and pasted from the 'Label and Approve Simple Changes' example

# -*- mode: yaml -*-
manifest:
  version: 1.0

automations:
  safe_changes:
    if:
      - {{ is.docs or is.tests or is.asset or is.formatting }}
    run: 
      - action: add-label@v1
        args:
          label: 'safe-changes'
      - action: approve@v1
is:
  docs: {{ files | allDocs }}
  tests: {{ files | allTests }}
  asset: {{ files | match(regex=r/\.(png|svg|gif|css)$/) | every }}
  formatting: {{ source.diff.files | isFormattingChange }}

Checked for whitespace issues - the other examples on the site def had syntax issues - the above example was the only one that the yq didn't complain about when I ran it through.

vim-zz commented 6 months ago

@shaynekasai can you share the PR link?

One other thing you can do, is to open a new public repo with the gitStream setup and share the link to it so we can see what's wrong, I suspect there are YAML issues in the CM rule file, like wrong indentation.

yakirm-cr commented 6 months ago

@vim-zz We are facing the same issue on one of the branches in one of our private repositories. The rule file .cm/gitstream.cm was last changed more than 4 months ago in this repository (and it was not changed on the branch in which the issue is encountered).

vim-zz commented 6 months ago

@yakirm-cr can you email me the CM file, PR link and the Action log?

PavelLinearB commented 6 months ago

Hi @shaynekasai and @yakirm-cr We have added more verbose logs to our runs and fixed some issues in the engine. Can you please re-run gitStream on the PRs that failed? If the problem persists, please share the logs with me so I can investigate further.

Thanks!

shaynekasai commented 6 months ago

will have a look thanks!

shaynekasai commented 6 months ago

Hey just an update, indeed it was a formatting issue with the yaml file, the extra log information was extremely helpful, thank you! I guess my formatter wasn't really detecting it for some reason, thanks for addressing this!!