diff --git a/lib/modules/manager/gitlabci-include/extract.ts b/lib/modules/manager/gitlabci-include/extract.ts index 026f51e80760a9e0af7e58c9ea5124014d52b128..60eb93772a183a00cf2e94376d15c967eb2211bf 100644 --- a/lib/modules/manager/gitlabci-include/extract.ts +++ b/lib/modules/manager/gitlabci-include/extract.ts @@ -14,7 +14,6 @@ import type { GitlabIncludeProject, GitlabPipeline, } from '../gitlabci/types'; -import { replaceReferenceTags } from '../gitlabci/utils'; import type { PackageDependency, PackageFileContent } from '../types'; function extractDepFromIncludeFile( @@ -76,7 +75,7 @@ export function extractPackageFile( : null; try { // TODO: use schema (#9610) - const docs = parseYaml<GitlabPipeline>(replaceReferenceTags(content), { + const docs = parseYaml<GitlabPipeline>(content, { uniqueKeys: false, }); for (const doc of docs) { diff --git a/lib/modules/manager/gitlabci/common.spec.ts b/lib/modules/manager/gitlabci/common.spec.ts index 9c491ef848f968a696e2de2cb4b84677d9d81a4c..5f55bcdb4b83ec7a322bb338d1b12513a10d83a6 100644 --- a/lib/modules/manager/gitlabci/common.spec.ts +++ b/lib/modules/manager/gitlabci/common.spec.ts @@ -1,7 +1,6 @@ import { codeBlock } from 'common-tags'; import { parseSingleYaml } from '../../../util/yaml'; import type { GitlabPipeline } from '../gitlabci/types'; -import { replaceReferenceTags } from '../gitlabci/utils'; import { filterIncludeFromGitlabPipeline, isGitlabIncludeComponent, @@ -12,7 +11,7 @@ import { // TODO: use schema (#9610) const pipeline = parseSingleYaml<GitlabPipeline>( - replaceReferenceTags(codeBlock` + codeBlock` include: - project: mikebryant/include-source-example file: /template.yaml @@ -25,7 +24,7 @@ const pipeline = parseSingleYaml<GitlabPipeline>( script: - !reference [.setup, script] - - !reference [arbitrary job name with space and no starting dot, nested1, nested2, nested3]`), + - !reference [arbitrary job name with space and no starting dot, nested1, nested2, nested3]`, ); const includeLocal = { local: 'something' }; const includeProject = { project: 'something' }; @@ -37,7 +36,15 @@ describe('modules/manager/gitlabci/common', () => { const filtered_pipeline = filterIncludeFromGitlabPipeline(pipeline); expect(filtered_pipeline).not.toHaveProperty('include'); expect(filtered_pipeline).toEqual({ - script: [null, null], + script: [ + ['.setup', 'script'], + [ + 'arbitrary job name with space and no starting dot', + 'nested1', + 'nested2', + 'nested3', + ], + ], }); }); }); diff --git a/lib/modules/manager/gitlabci/utils.spec.ts b/lib/modules/manager/gitlabci/utils.spec.ts index 3c563ce93cbb93298a619dea146bbae26ba27f81..0b89036dd8f5df4724949b7979d166b1dd856dd0 100644 --- a/lib/modules/manager/gitlabci/utils.spec.ts +++ b/lib/modules/manager/gitlabci/utils.spec.ts @@ -1,6 +1,5 @@ -import { Fixtures } from '../../../../test/fixtures'; import type { PackageDependency } from '../types'; -import { getGitlabDep, replaceReferenceTags } from './utils'; +import { getGitlabDep } from './utils'; describe('modules/manager/gitlabci/utils', () => { describe('getGitlabDep', () => { @@ -82,12 +81,4 @@ describe('modules/manager/gitlabci/utils', () => { }); }); }); - - describe('replaceReferenceTags', () => { - it('replaces all !reference tags with empty strings', () => { - const yamlFileReferenceConfig = Fixtures.get('gitlab-ci.reference.yaml'); - const replaced = replaceReferenceTags(yamlFileReferenceConfig); - expect(replaced).not.toContain('!reference'); - }); - }); }); diff --git a/lib/modules/manager/gitlabci/utils.ts b/lib/modules/manager/gitlabci/utils.ts index e69552b2a61f69aae03ee85ac37d6cdf398cd706..1a861897df735d31d0fff6b270d013c5d6cb8dad 100644 --- a/lib/modules/manager/gitlabci/utils.ts +++ b/lib/modules/manager/gitlabci/utils.ts @@ -2,19 +2,6 @@ import { regEx } from '../../../util/regex'; import { getDep } from '../dockerfile/extract'; import type { PackageDependency } from '../types'; -const re = /!reference \[[^\]]+\]/g; - -/** - * Replaces GitLab reference tags before parsing, because our yaml parser cannot process them anyway. - * @param content pipeline yaml - * @returns replaced pipeline content - * https://docs.gitlab.com/ee/ci/yaml/#reference-tags - */ -export function replaceReferenceTags(content: string): string { - const res = content.replace(re, ''); - return res; -} - const depProxyRe = regEx( `(?<prefix>\\$\\{?CI_DEPENDENCY_PROXY_(?:DIRECT_)?GROUP_IMAGE_PREFIX\\}?/)(?<depName>.+)`, );