Skip to content

Commit 25c2479

Browse files
committed
Analyze all files if modified files cannot be determined
1 parent ffa00d2 commit 25c2479

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async function main() {
2121
if (core.getInput('analyzeModifiedFilesOnly', { required: true }) === 'true') {
2222
core.info(`Determining modified files in ${sourcePath}...`);
2323
modifiedFiles = await util.determineModifiedFiles(token, sourcePath);
24-
if (modifiedFiles.length === 0) {
24+
if (modifiedFiles !== undefined && modifiedFiles.length === 0) {
2525
core.info(`No modified files have been found in ${sourcePath} - exiting`);
2626
core.setOutput('violations', 0);
2727
return;

lib/util.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ const determineModifiedFiles = async function(token, sourcePath) {
146146

147147
return modifiedFilenames;
148148
} else {
149-
throw new Error(`Unsupported github action event '${context.eventName}'`);
149+
core.warning(`Unsupported github action event '${context.eventName}' - cannot determine modified files. All files will be analyzed.`);
150+
return undefined;
150151
}
151152
}
152153

tests/util.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,11 @@ describe('pmd-github-action-util', function () {
218218
.map(f => path.normalize(f)));
219219
})
220220

221-
test('throws for unsupported event', async () => {
221+
test('return undefined for unsupported event', async () => {
222222
process.env['GITHUB_REPOSITORY'] = 'pmd/pmd-github-action-tests'
223223
process.env['GITHUB_EVENT_NAME'] = 'workflow_dispatch';
224-
await expect(util.determineModifiedFiles('my_test_token', 'src/main/java')).rejects.toThrow();
224+
let result = await util.determineModifiedFiles('my_test_token', path.normalize('src/main/java'));
225+
expect(result).toBe(undefined);
225226
})
226227

227228
it('can execute PMD with list of files', async () => {

0 commit comments

Comments
 (0)