Skip to content

Commit

Permalink
If no experiments are specified, use the GitHub service defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyskoedijk committed Dec 14, 2024
1 parent de32399 commit 8c5e5e4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,14 @@ function buildUpdateJobConfig(
'prefix-development': update['commit-message']?.['prefix-development'],
'include-scope': update['commit-message']?.['include'],
},
'experiments': taskInputs.experiments,
'experiments': Object.keys(taskInputs.experiments || {}).reduce(
(acc, key) => {
// Replace '-' with '_' in the experiment keys to match the dependabot-core models
acc[key.replace(/-/g, '_')] = taskInputs.experiments[key];
return acc;
},
{} as Record<string, string | boolean>,
),
'max-updater-run-time': undefined, // TODO: add config for this?
'reject-external-code': update['insecure-external-code-execution']?.toLocaleLowerCase() == 'allow',
'repo-private': undefined, // TODO: add config for this?
Expand Down
15 changes: 15 additions & 0 deletions extension/tasks/dependabotV2/utils/dependabot/experiments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// The default experiments known to be used by the GitHub Dependabot service.
// This changes often, update as needed by extracting them from a Dependabot GitHub Action run.
// e.g. https://github.com/tinglesoftware/dependabot-azure-devops/actions/workflows/dependabot/dependabot-updates
export const DEFAULT_EXPERIMENTS: Record<string, string | boolean> = {
'record-ecosystem-versions': true,
'record-update-job-unknown-error': true,
'proxy-cached': true,
'move-job-token': true,
'dependency-change-validation': true,
'nuget-native-analysis': true,
'nuget-use-direct-discovery': true,
'enable-file-parser-python-local': true,
'lead-security-dependency': true,
'enable-record-ecosystem-meta': true,
};
9 changes: 9 additions & 0 deletions extension/tasks/dependabotV2/utils/getSharedVariables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as tl from 'azure-pipelines-task-lib/task';
import { DEFAULT_EXPERIMENTS } from './dependabot/experiments';
import extractHostname from './extractHostname';
import extractOrganization from './extractOrganization';
import extractVirtualDirectory from './extractVirtualDirectory';
Expand Down Expand Up @@ -140,6 +141,14 @@ export default function getSharedVariables(): ISharedVariables {
{} as Record<string, string | boolean>,
);

// If no experiments are defined, use the default experiments
if (!experiments) {
experiments = DEFAULT_EXPERIMENTS;
tl.debug('No experiments provided; Using default experiments.');
}

console.log('Experiments:', experiments);

let debug: boolean = tl.getVariable('System.Debug')?.match(/true/i) ? true : false;

// Get the target identifiers
Expand Down

0 comments on commit 8c5e5e4

Please sign in to comment.