Skip to content

Commit

Permalink
feat(manager/azure-pipelines): Deployment jobs support (renovatebot#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbera authored and hersentino committed Jan 9, 2024
1 parent 27b60f4 commit 8842d57
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 109 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

237 changes: 212 additions & 25 deletions lib/modules/manager/azure-pipelines/extract.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { codeBlock } from 'common-tags';
import { Fixtures } from '../../../../test/fixtures';
import { GlobalConfig } from '../../../config/global';
import { AzurePipelinesTasksDatasource } from '../../datasource/azure-pipelines-tasks';
Expand All @@ -15,9 +16,6 @@ const azurePipelines = Fixtures.get('azure-pipelines.yaml');
const azurePipelinesNoDependency = Fixtures.get(
'azure-pipelines-no-dependency.yaml',
);
const azurePipelinesStages = Fixtures.get('azure-pipelines-stages.yaml');
const azurePipelinesJobs = Fixtures.get('azure-pipelines-jobs.yaml');
const azurePipelinesSteps = Fixtures.get('azure-pipelines-steps.yaml');

describe('modules/manager/azure-pipelines/extract', () => {
afterEach(() => {
Expand Down Expand Up @@ -58,12 +56,11 @@ describe('modules/manager/azure-pipelines/extract', () => {
).toBeNull();
});

it('should return null when reference is not defined', () => {
it('should return null when reference is not defined specified', () => {
expect(
extractRepository({
type: 'github',
name: 'user/repo',
ref: null,
}),
).toBeNull();
});
Expand Down Expand Up @@ -138,10 +135,6 @@ describe('modules/manager/azure-pipelines/extract', () => {
datasource: 'docker',
});
});

it('should return null if image field is missing', () => {
expect(extractContainer({ image: null })).toBeNull();
});
});

describe('extractAzurePipelinesTasks()', () => {
Expand Down Expand Up @@ -191,11 +184,196 @@ describe('modules/manager/azure-pipelines/extract', () => {
).toBeNull();
});

it('should extract deployment jobs runonce', () => {
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
deploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
currentValue: '3',
datasource: AzurePipelinesTasksDatasource.id,
},
]);
});

it('should extract deployment jobs on failure', () => {
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
on:
failure:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
currentValue: '3',
datasource: AzurePipelinesTasksDatasource.id,
},
]);
});

it('should extract deployment jobs on success', () => {
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
on:
success:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
currentValue: '3',
datasource: AzurePipelinesTasksDatasource.id,
},
]);
});

it('should extract deployment jobs postroute', () => {
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
postRouteTraffic:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
currentValue: '3',
datasource: AzurePipelinesTasksDatasource.id,
},
]);
});

it('should extract deployment jobs predeploy', () => {
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
preDeploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
currentValue: '3',
datasource: AzurePipelinesTasksDatasource.id,
},
]);
});

it('should extract deployment jobs route', () => {
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
routeTraffic:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
currentValue: '3',
datasource: AzurePipelinesTasksDatasource.id,
},
]);
});

it('should extract deployment jobs rolling', () => {
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
rolling:
deploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
currentValue: '3',
datasource: AzurePipelinesTasksDatasource.id,
},
]);
});

it('should extract deployment jobs canary', () => {
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
canary:
deploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
currentValue: '3',
datasource: AzurePipelinesTasksDatasource.id,
},
]);
});

it('should extract stages', () => {
const res = extractPackageFile(
azurePipelinesStages,
azurePipelinesFilename,
);
const packageFile = codeBlock`
stages:
- stage: stage_one
jobs:
- job: job_one
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -206,10 +384,15 @@ describe('modules/manager/azure-pipelines/extract', () => {
});

it('should extract jobs', () => {
const res = extractPackageFile(
azurePipelinesJobs,
azurePipelinesFilename,
);
const packageFile = codeBlock`
jobs:
- job: job_one
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -220,10 +403,13 @@ describe('modules/manager/azure-pipelines/extract', () => {
});

it('should extract steps', () => {
const res = extractPackageFile(
azurePipelinesSteps,
azurePipelinesFilename,
);
const packageFile = codeBlock`
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -234,10 +420,11 @@ describe('modules/manager/azure-pipelines/extract', () => {
});

it('should return null when task alias used', () => {
const content = `
steps:
- bash: 'echo Hello World'`;
const res = extractPackageFile(content, azurePipelinesFilename);
const packageFile = codeBlock`
steps:
- bash: 'echo Hello World';
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res).toBeNull();
});
});
Expand Down
Loading

0 comments on commit 8842d57

Please sign in to comment.