Skip to content

Commit

Permalink
Merge branch 'main' into chore/remove-default-prettier-option
Browse files Browse the repository at this point in the history
  • Loading branch information
hairihou authored Oct 4, 2024
2 parents 8d8e7e0 + bb809d3 commit 1a87c85
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ jobs:
node-version: ${{ needs.setup-build.outputs.node-version }}
os: ${{ runner.os }}

- uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0
- uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0

- name: Docker registry login
run: |
Expand Down
3 changes: 2 additions & 1 deletion lib/data/monorepo.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@
"https://github.com/FasterXML/jackson",
"https://github.com/FasterXML/jackson-databind",
"https://github.com/FasterXML/jackson-dataformats-binary",
"https://github.com/FasterXML/jackson-dataformats-text"
"https://github.com/FasterXML/jackson-dataformats-text",
"https://github.com/FasterXML/jackson-module-kotlin"
],
"jasmine": "https://github.com/jasmine/jasmine",
"javahamcrest": "https://github.com/hamcrest/JavaHamcrest",
Expand Down
27 changes: 27 additions & 0 deletions lib/modules/manager/docker-compose/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,33 @@ describe('modules/manager/docker-compose/extract', () => {
expect(res?.deps).toHaveLength(1);
});

it('extracts can parse yaml tags for version 3', () => {
const compose = codeBlock`
web:
image: node:20.0.0
ports:
- "80:8000"
worker:
extends:
service: web
ports: !reset null
`;
const res = extractPackageFile(compose, '', {});
expect(res).toEqual({
deps: [
{
depName: 'node',
currentValue: '20.0.0',
currentDigest: undefined,
replaceString: 'node:20.0.0',
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
datasource: 'docker',
},
],
});
});

it('extracts image and replaces registry', () => {
const compose = codeBlock`
version: "3"
Expand Down
3 changes: 1 addition & 2 deletions lib/modules/manager/gitlabci-include/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type {
GitlabIncludeProject,
GitlabPipeline,
} from '../gitlabci/types';
import { replaceReferenceTags } from '../gitlabci/utils';
import type { PackageDependency, PackageFileContent } from '../types';

function extractDepFromIncludeFile(
Expand Down Expand Up @@ -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) {
Expand Down
15 changes: 11 additions & 4 deletions lib/modules/manager/gitlabci/common.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand All @@ -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' };
Expand All @@ -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',
],
],
});
});
});
Expand Down
11 changes: 1 addition & 10 deletions lib/modules/manager/gitlabci/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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');
});
});
});
13 changes: 0 additions & 13 deletions lib/modules/manager/gitlabci/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>.+)`,
);
Expand Down
18 changes: 18 additions & 0 deletions lib/util/yaml.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,23 @@ describe('util/yaml', () => {
},
});
});

it('should parse content with yaml tags', () => {
expect(
parseSingleYaml(
codeBlock`
myObject:
aString: value
aStringWithTag: !reset null
`,
{ removeTemplates: true },
),
).toEqual({
myObject: {
aString: 'value',
aStringWithTag: 'null',
},
});
});
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
"async-mutex": "0.5.0",
"auth-header": "1.0.0",
"aws4": "1.13.2",
"azure-devops-node-api": "14.0.2",
"azure-devops-node-api": "14.1.0",
"bunyan": "1.8.15",
"cacache": "18.0.4",
"chalk": "4.1.2",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1a87c85

Please sign in to comment.