Use supplied correlator without concatenation

This commit is contained in:
David Wiggs
2024-07-23 22:33:11 +00:00
parent 2ba839e04b
commit 7592e88109
6 changed files with 10 additions and 22 deletions
+1
View File
@@ -35,6 +35,7 @@ This action writes informations in the repository dependency graph, so if you ar
* `snapshot-dependency-file-name`: An optional user control file path to the POM file, requires `snapshot-include-file-name` to be `true` for the value to be submitted. * `snapshot-dependency-file-name`: An optional user control file path to the POM file, requires `snapshot-include-file-name` to be `true` for the value to be submitted.
* `correlator`: An optional identifier to distinguish between multiple dependency snapshots of the same type. Defaults to the [job_id](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_id) of the current job.
## Examples ## Examples
+1
View File
@@ -68,6 +68,7 @@ inputs:
description: An optional identifier to distinguish between multiple dependency snapshots of the same type description: An optional identifier to distinguish between multiple dependency snapshots of the same type
type: string type: string
required: false required: false
default: ''
runs: runs:
using: node20 using: node20
+1 -1
View File
@@ -510,7 +510,7 @@ function generateSnapshot(directory, mvnConfig, snapshotConfig) {
const snapshot = new dependency_submission_toolkit_1.Snapshot(detector, snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.context, snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.job); const snapshot = new dependency_submission_toolkit_1.Snapshot(detector, snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.context, snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.job);
snapshot.addManifest(manifest); snapshot.addManifest(manifest);
snapshot.job.correlator = (snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.correlator) snapshot.job.correlator = (snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.correlator)
? `${snapshot.job.correlator}-${snapshotConfig.correlator}` ? snapshotConfig.correlator
: (_b = snapshot.job) === null || _b === void 0 ? void 0 : _b.correlator; : (_b = snapshot.job) === null || _b === void 0 ? void 0 : _b.correlator;
const specifiedRef = getNonEmtptyValue(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.ref); const specifiedRef = getNonEmtptyValue(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.ref);
if (specifiedRef) { if (specifiedRef) {
+1 -1
View File
File diff suppressed because one or more lines are too long
+5 -19
View File
@@ -69,39 +69,25 @@ describe('snapshot-generator', () => {
expect(snapshot.manifests['problem-dependency-graph-2602'].countDependencies()).toBe(230); expect(snapshot.manifests['problem-dependency-graph-2602'].countDependencies()).toBe(230);
}, 40000); }, 40000);
it('should append correlator from snapshotConfig if it exists', async() => { it('should use correlator from snapshotConfig if it exists', async() => {
const projectDir = getMavenProjectDirectory('simple'); const projectDir = getMavenProjectDirectory('simple');
const mavenSettingsFile = getMavenSettingsFile(); const mavenSettingsFile = getMavenSettingsFile();
const mavenConfig = {
ignoreMavenWrapper: true,
settingsFile: mavenSettingsFile,
mavenArgs: '-DskipTests'
};
const snapshotConfig = { const snapshotConfig = {
correlator: 'configCorrelator', correlator: 'configCorrelator',
job: {
correlator: 'jobCorrelator'
}
}; };
const snapshot = await generateSnapshot(projectDir, mavenConfig, snapshotConfig); const snapshot = await generateSnapshot(projectDir, undefined, snapshotConfig);
expect(snapshot.job.correlator).toBe('jobCorrelator-configCorrelator'); expect(snapshot.job.correlator).toBe('configCorrelator');
}, 20000); }, 20000);
it('should use existing job correlator if snapshotConfig correlator does not exist', async() => { it('should use a default job correlator when not specified', async() => {
const projectDir = getMavenProjectDirectory('simple'); const projectDir = getMavenProjectDirectory('simple');
const mavenSettingsFile = getMavenSettingsFile();
const mavenConfig = {
ignoreMavenWrapper: true,
settingsFile: mavenSettingsFile,
mavenArgs: '-DskipTests'
};
const snapshotConfig = { const snapshotConfig = {
job: { job: {
correlator: 'jobCorrelator' correlator: 'jobCorrelator'
} }
}; };
const snapshot = await generateSnapshot(projectDir, mavenConfig, snapshotConfig); const snapshot = await generateSnapshot(projectDir, undefined, snapshotConfig);
expect(snapshot.job.correlator).toBe('jobCorrelator'); expect(snapshot.job.correlator).toBe('jobCorrelator');
}, 20000); }, 20000);
+1 -1
View File
@@ -55,7 +55,7 @@ export async function generateSnapshot(directory: string, mvnConfig?: MavenConfi
snapshot.addManifest(manifest); snapshot.addManifest(manifest);
snapshot.job.correlator = snapshotConfig?.correlator snapshot.job.correlator = snapshotConfig?.correlator
? `${snapshot.job.correlator}-${snapshotConfig.correlator}` ? snapshotConfig.correlator
: snapshot.job?.correlator; : snapshot.job?.correlator;
const specifiedRef = getNonEmtptyValue(snapshotConfig?.ref); const specifiedRef = getNonEmtptyValue(snapshotConfig?.ref);