mitchspano / sfdx-scan-pull-request

Runs sfdx-scanner on a pull request and generates in-line comments with the findings.
Apache License 2.0
73 stars 25 forks source link

Error while using the action #50

Closed devboorla closed 1 year ago

devboorla commented 1 year ago

Beginning sfdx-scan-pull-request run... Validating that this action was invoked from an acceptable context... Getting difference within the pull request ... { baseRef: 'abc-demo-01', headRef: 'jira-001' } error: remote destination already exists. (node:14284) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. (Use node --trace-deprecation ... to show where the warning was created) node:child_process:826 err = new Error(msg); ^

Error: Command failed: git remote add -f destination https://github.ABC.com/salesforce/ABC-Salesforce-POC.git error: remote destination already exists.

mitchspano commented 1 year ago

Thanks for checking out the action. Please share your repository's workflow YML so I can assist with debugging.

devboorla commented 1 year ago
- name: Run SFDX Scanner - Report findings as comments
  uses: mitchspano/sfdx-scan-pull-request@v0.1.10
  with:
    pmdconfig: .github/workflows/pmd-ruleset.xml
    severity-threshold: 4
    strictly-enforced-rules: '[{ "engine": "pmd", "category": "Performance", "rule": "AvoidDebugStatements" }]'
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
mitchspano commented 1 year ago

Can you share the entire file? I would like to see how the checkout action is being performed.

mitchspano commented 1 year ago

Is this being ran on a standalone repository or on a fork of an existing repository?

devboorla commented 1 year ago

fork of an existing repo. Whenever a PR is created the action is being called upon. checkout and all happens properly as I am running validation against target org successfully. I unfortunately cannot share code as it is for an enterprise. but below is the action that I use to do checkout. pretty standard stuff. nothing out of ordinary.

build: runs-on: Java steps:

mitchspano commented 1 year ago

Gotcha - thank your for clarifying.

The code in question is here. It was introduced in #24 as part of a fix for #23. I am curious why that seemed to resolve the issue then, but it is causing errors now....

To test this out, I have removed the registration of the destination remote in this commit on the fixForkingIssue branch.

Can you try again with the following yml structure:

- name: Run SFDX Scanner - Report findings as comments
  uses: mitchspano/sfdx-scan-pull-request@fixForkingIssue
  with:
    pmdconfig: .github/workflows/pmd-ruleset.xml
    severity-threshold: 4
    strictly-enforced-rules: '[{ "engine": "pmd", "category": "Performance", "rule": "AvoidDebugStatements" }]'
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
devboorla commented 1 year ago

Hi! my Apologies. I was trying out something else and I was working on few other things. Incorporating the above action gives me below error:

Getting difference within the pull request ... { baseRef: 'abc-demo-01', headRef: 'jira-001' } fatal: ambiguous argument 'destination/abc-demo-01...origin/jira-001': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]' (node:11381) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. (Use node --trace-deprecation ... to show where the warning was created)

Yurii-Zakharov commented 1 year ago

The same issue on self-hosted runner and latest version v0.1.10: node:internal/errors:841 const err = new Error(message); ^

Error: Command failed: git remote add -f destination https://github.com/.git fatal: remote destination already exists.

Applied a workaround with pre-step:

The strange thing is that it worked initially without issues, then switched on ubuntu-latest for testing and once switched back to self-hosted - got this error.

mitchspano commented 1 year ago

It's odd that we have issues with both the main and the firForkingIssue branches. Those criteria are mutually exclusive - either the destination branch is there, or it is not.

Perhaps @Yurii-Zakharov's finding about the running OS might hold some clues.

@devboorla Can you try running both branches on ubuntu and see if the issue persists?