mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
fix(manager/circleci): extract executors of CircleCi files again (#30562)
This commit is contained in:
parent
f0c2067798
commit
269a4dd125
3 changed files with 29 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
|||
import { codeBlock } from 'common-tags';
|
||||
import { Fixtures } from '../../../../test/fixtures';
|
||||
import { extractPackageFile } from '.';
|
||||
|
||||
|
@ -78,5 +79,24 @@ describe('modules/manager/circleci/extract', () => {
|
|||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('extracts executors', () => {
|
||||
const res = extractPackageFile(codeBlock`
|
||||
executors:
|
||||
my-executor:
|
||||
docker:
|
||||
- image: cimg/ruby:3.0.3-browsers`);
|
||||
expect(res?.deps).toEqual([
|
||||
{
|
||||
autoReplaceStringTemplate:
|
||||
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
|
||||
currentValue: '3.0.3-browsers',
|
||||
datasource: 'docker',
|
||||
depName: 'cimg/ruby',
|
||||
depType: 'docker',
|
||||
replaceString: 'cimg/ruby:3.0.3-browsers',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import { OrbDatasource } from '../../datasource/orb';
|
|||
import * as npmVersioning from '../../versioning/npm';
|
||||
import { getDep } from '../dockerfile/extract';
|
||||
import type { PackageDependency, PackageFileContent } from '../types';
|
||||
import { CircleCiFile } from './schema';
|
||||
import { CircleCiFile, type CircleCiJob } from './schema';
|
||||
|
||||
export function extractPackageFile(
|
||||
content: string,
|
||||
|
@ -30,7 +30,12 @@ export function extractPackageFile(
|
|||
});
|
||||
}
|
||||
|
||||
for (const job of Object.values(parsed.jobs ?? {})) {
|
||||
// extract environments
|
||||
const environments: CircleCiJob[] = [
|
||||
Object.values(parsed.executors ?? {}),
|
||||
Object.values(parsed.jobs ?? {}),
|
||||
].flat();
|
||||
for (const job of environments) {
|
||||
for (const dockerElement of coerceArray(job.docker)) {
|
||||
deps.push({
|
||||
...getDep(dockerElement.image),
|
||||
|
|
|
@ -4,12 +4,14 @@ export const CircleCiDocker = z.object({
|
|||
image: z.string(),
|
||||
});
|
||||
|
||||
export type CircleCiJob = z.infer<typeof CircleCiJob>;
|
||||
export const CircleCiJob = z.object({
|
||||
docker: z.array(CircleCiDocker).optional(),
|
||||
});
|
||||
|
||||
export const CircleCiFile = z.object({
|
||||
aliases: z.array(CircleCiDocker).optional(),
|
||||
executors: z.record(z.string(), CircleCiJob).optional(),
|
||||
jobs: z.record(z.string(), CircleCiJob).optional(),
|
||||
orbs: z.record(z.string()).optional(),
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue