Skip to content

Commit

Permalink
fix(manager/circleci): optional jobs parameter (#30251)
Browse files Browse the repository at this point in the history
  • Loading branch information
sugarshin committed Jul 19, 2024
1 parent 8a5e291 commit 7272dd2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
9 changes: 9 additions & 0 deletions lib/modules/manager/circleci/__fixtures__/config4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2.1

orbs:
nodejs: circleci/[email protected]

workflows:
Test:
jobs:
- nodejs/test
13 changes: 13 additions & 0 deletions lib/modules/manager/circleci/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { extractPackageFile } from '.';
const file1 = Fixtures.get('config.yml');
const file2 = Fixtures.get('config2.yml');
const file3 = Fixtures.get('config3.yml');
const file4 = Fixtures.get('config4.yml');

describe('modules/manager/circleci/extract', () => {
describe('extractPackageFile()', () => {
Expand Down Expand Up @@ -65,5 +66,17 @@ describe('modules/manager/circleci/extract', () => {
),
).toBeNull();
});

it('extracts orbs without jobs', () => {
const res = extractPackageFile(file4);
expect(res?.deps).toMatchObject([
{
depName: 'nodejs',
currentValue: '5.2.0',
datasource: 'orb',
depType: 'orb',
},
]);
});
});
});
2 changes: 1 addition & 1 deletion lib/modules/manager/circleci/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function extractPackageFile(
});
}

for (const job of Object.values(parsed.jobs)) {
for (const job of Object.values(parsed.jobs ?? {})) {
for (const dockerElement of coerceArray(job.docker)) {
deps.push({
...getDep(dockerElement.image),
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/circleci/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export const CircleCiJob = z.object({

export const CircleCiFile = z.object({
aliases: z.array(CircleCiDocker).optional(),
jobs: z.record(z.string(), CircleCiJob),
jobs: z.record(z.string(), CircleCiJob).optional(),
orbs: z.record(z.string()).optional(),
});

0 comments on commit 7272dd2

Please sign in to comment.