-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Scenario
When configured to run on a push event and the GitHub's context.payload.before commit is 0000000000000000000000000000000000000000 (meaning there was no prior commit) then the action fails with error Error: Not Found.
The error is raised by util.js by determineModifiedFiles(..) function when it invokes octokit.rest.repos.compareCommitsWithBasehead(..)
https://github.com/pmd/pmd-github-action/blob/main/lib/util.js#L143
Config File
# .github/workflows/pmd.yml
name: Run PMD
on:
push:
branches:
- my-branch
paths:
- my-folder
jobs:
build:
name: Run PMD
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run Apex Rules
uses: pmd/pmd-github-action@v1
with:
rulesets: rulesets/PMD/apex-rules-github.xml
sourcePath: my-folder
analyzeModifiedFilesOnly: true
createGitHubAnnotations: trueExpected Result
- PMD to not perform a diff comparison because there is no prior commit.
- PMD to identify the list of files included in the commit for the given source path.
$ git diff-tree --no-commit-id --name-only --diff-filter=AM -r <commit>
index.html
my-folder/some-file.javaconst response = await octokit.rest.repos.getCommit({
...context.repo,
ref: eventData.after,
});
console.log(response);
---
{
status: 200,
url: 'https://api.github.com/repos/my-org/my-repo/commits/65a6b28ce342017b77bde00498434386961cdff7',
headers: {
...
},
data: {
sha: '65a6b28ce342017b77bde00498434386961cdff7',
node_id: 'C_kwDOFndAydoAKDY1YTZiMjhjZTM0MjAxN2I3N2JkZTAwNDk4NDM0Mzg2OTYxY2RmZjc',
commit: {
...
},
url: '...',
html_url: '...',
comments_url: '...',
author: {
...
},
committer: {
...
},
parents: [ { ... } ],
stats: { total: 40, additions: 36, deletions: 4 },
files: [
{
sha: '4b38cfc1be0f3290f3340093825b6bbc48fd69b4',
filename: 'index.html',
status: 'modified',
additions: 9,
deletions: 1,
changes: 10,
blob_url: '...',
raw_url: '...',
contents_url: '...',
patch: '...'
},
{
sha: '565abd034c00e10add52d15cfe478f5bee3fe1da',
filename: 'my-folder/my-file.java',
status: 'modified',
additions: 9,
deletions: 1,
changes: 10,
blob_url: '...',
raw_url: '...',
contents_url: '...',
patch: '...'
}
]
}
}Actual Result
- Action fails with the following error
##[debug]finished caching tool
Using PMD 6.49.0 from cached path /home/docker/actions-runner/_work/_tool/pmd/6.49.0/x64
Determining modified files in my-folder...
##[debug]Push on refs/heads/my-branch: 0000000000000000000000000000000000000000...c46068a4fd0827f6c4365d24c02c1bc44707287a
Error: Not Found
##[debug]Node Action run completed with exit code 1
Workaround
- Push another commit to the branch
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working