Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/cyclonedx/bom.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/analysis/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { logger } from '../helper/logger.js';
import { runTicsAnalyzer } from '../tics/analyzer.js';
import { getChangedFiles } from './helper/changed-files.js';
import { processCompleteAnalysis, processIncompleteAnalysis } from './client/process-analysis.js';
import { ticsConfig } from '../configuration/config.js';

export async function clientAnalysis(): Promise<Verdict> {
const changedFiles = await getChangedFiles();
Expand All @@ -12,8 +13,8 @@ export async function clientAnalysis(): Promise<Verdict> {
message: ''
};

// if no changed files are found, return early
if (changedFiles.files.length === 0) {
// if no changed files are found, return early (except when a filelist is given)
if (changedFiles.files.length === 0 && ticsConfig.filelist === '') {
logger.info('No changed files found to analyze.');
return verdict;
}
Expand Down
2 changes: 2 additions & 0 deletions src/helper/interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { ChangedFile } from '../github/interfaces.js';
import { ExtendedAnnotation, LabelInfo, QualityGate } from '../viewer/interfaces.js';

export interface ChangedFiles {
/** Changed files returned by GitHub */
files: ChangedFile[];
/** Path of the filelist to pass to TICS */
path: string;
}

Expand Down
15 changes: 15 additions & 0 deletions test/unit/analysis/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ describe('setFailed checks (TICS Client)', () => {
expect(spyInfo).toHaveBeenCalledWith(expect.stringContaining('No changed files found to analyze.'));
});

it('should run analyzer if there are no changed files but a filelist is passed', async () => {
ticsConfigMock.filelist = 'location/changedFiles.txt';
spyChangedFiles.mockResolvedValueOnce({ files: [], path: 'location/changedFiles.txt' });
spyAnalyzer.mockResolvedValue(analysisNoUrl);
spyIncomplete.mockResolvedValueOnce('');

const verdict = await clientAnalysis();

expect(verdict).toEqual({
passed: true,
message: ''
});
expect(spyAnalyzer).toHaveBeenCalled();
});

it('should return failing verdict if there is no Explorer URL and processIncomplete returns a failed message', async () => {
spyChangedFiles.mockResolvedValueOnce({ files: singleChangedFiles, path: 'location/changedFiles.txt' });
spyAnalyzer.mockResolvedValue(analysisNoUrl);
Expand Down
Loading