Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(manager/asdf): add support for .tools-versions as used by asdf #17166

Merged
merged 28 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8b4804b
feat(manager/asdf): add asdf+nodejs support
sawilde Aug 14, 2022
8b35c6c
feat(manager/asdf): allow for skip comments
sawilde Aug 14, 2022
394b131
feat(manager/asdf): switch to a for ... of loop
sawilde Aug 14, 2022
dc307ad
Merge branch 'main' into feat/asdf-support
rarkins Aug 14, 2022
3c5f4f1
feat(manager/asdf): use regEx util, is.truthy, ... (post review)
sawilde Aug 19, 2022
df3708c
Merge branch 'main' into feat/asdf-support
rarkins Aug 20, 2022
6a15ba3
Update lib/modules/manager/asdf/readme.md
rarkins Aug 30, 2022
298ffd7
Merge branch 'main' into feat/asdf-support
rarkins Aug 30, 2022
b075fae
feat(manger/asdf): use skipReason ignored for ignore comments
sawilde Sep 4, 2022
8eedb1a
feat(manager/asdf): amend extractPackageFile signature
sawilde Sep 4, 2022
9de3dda
feat(manager/asdf): provide skip reason for unsupported tools
sawilde Sep 4, 2022
3c4d981
fix(manager/asdf): only pass version to currentValue field
sawilde Sep 4, 2022
d256bfb
feat(manager/asdf): provide skip reason for ignoring unsupported vers…
sawilde Sep 4, 2022
62e9abb
refactor(manager/asdf): simplify the regex
sawilde Sep 4, 2022
4d8b8dc
feat(manager/asdf): can support multiple tools in one file
sawilde Sep 4, 2022
951b279
Merge branch 'main' into feat/asdf-support
rarkins Sep 6, 2022
9c0fabb
refactor(manager/asdf): use a dummy tool name instead of a possible f…
sawilde Sep 7, 2022
f89e4b2
refactor(manager/asdf): simplify regex, move supported version format…
sawilde Sep 7, 2022
e55aa44
refactor(manager/asdf): simplify regex, add additional comment handli…
sawilde Sep 7, 2022
f7157a9
feat(manager/asdf): let renovate check, and reject, the supplied vers…
sawilde Sep 7, 2022
dc23b6d
feat(manager/asdf): update readme on position on fallback version mgmt
sawilde Sep 7, 2022
86430a8
Merge branch 'main' into feat/asdf-support
rarkins Sep 8, 2022
a5a7313
refactor(manager/asdf): change regex, update comment tests
sawilde Sep 8, 2022
aa07fb9
Merge branch 'main' into feat/asdf-support
rarkins Sep 8, 2022
1e90146
Merge branch 'main' into feat/asdf-support
viceice Sep 17, 2022
78010c9
Merge branch 'main' into feat/asdf-support
sawilde Sep 18, 2022
e169fd7
Merge branch 'main' into feat/asdf-support
sawilde Sep 19, 2022
3ddc70f
Merge branch 'main' into feat/asdf-support
rarkins Sep 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ test/datasource/nuget/_fixtures/obj

# testing
/docker-compose.yml

# version management
.tool-versions
sawilde marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions lib/modules/manager/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as ansible from './ansible';
import * as ansibleGalaxy from './ansible-galaxy';
import * as argoCD from './argocd';
import * as asdf from './asdf';
import * as azurePipelines from './azure-pipelines';
import * as batect from './batect';
import * as batectWrapper from './batect-wrapper';
Expand Down Expand Up @@ -80,6 +81,7 @@ export default api;
api.set('ansible', ansible);
api.set('ansible-galaxy', ansibleGalaxy);
api.set('argocd', argoCD);
api.set('asdf', asdf);
api.set('azure-pipelines', azurePipelines);
api.set('batect', batect);
api.set('batect-wrapper', batectWrapper);
Expand Down
87 changes: 87 additions & 0 deletions lib/modules/manager/asdf/extract.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { extractPackageFile } from '.';

describe('modules/manager/asdf/extract', () => {
describe('extractPackageFile()', () => {
it('returns a result', () => {
const res = extractPackageFile('nodejs 16.16.0\n');
expect(res.deps).toEqual([
{
currentValue: 'nodejs 16.16.0',
datasource: 'github-tags',
depName: 'node',
packageName: 'nodejs/node',
},
]);
});

it('ignores lines with unsupported tooling', () => {
const res = extractPackageFile('yarn 1.22.5\n');
expect(res.deps).toEqual([]);
});

it('only captures the first version', () => {
const res = extractPackageFile('nodejs 16.16.0 16.15.1\n');
expect(res.deps).toEqual([
{
currentValue: 'nodejs 16.16.0',
datasource: 'github-tags',
depName: 'node',
packageName: 'nodejs/node',
},
]);
});

it('ignores supported tooling with ref: versioning', () => {
const res = extractPackageFile('nodejs ref:234abc4\n');
expect(res.deps).toEqual([]);
sawilde marked this conversation as resolved.
Show resolved Hide resolved
});

it('ignores supported tooling with path: versioning', () => {
const res = extractPackageFile('nodejs path:/path/to/tooling\n');
expect(res.deps).toEqual([]);
sawilde marked this conversation as resolved.
Show resolved Hide resolved
});

it('ignores supported tooling with system versioning', () => {
const res = extractPackageFile('nodejs system\n');
expect(res.deps).toEqual([]);
sawilde marked this conversation as resolved.
Show resolved Hide resolved
});

describe('comment handling', () => {
it('ignores comments at the end of lines', () => {
const res = extractPackageFile('nodejs 16.16.0 # this is a comment\n');
expect(res.deps).toEqual([
{
currentValue: 'nodejs 16.16.0',
datasource: 'github-tags',
depName: 'node',
packageName: 'nodejs/node',
},
]);
});

it('ignores lines that are just comments at the end of lines', () => {
const res = extractPackageFile('# this is a full line comment\n');
expect(res.deps).toEqual([]);
});

it('ignores comments across multiple lines', () => {
const res = extractPackageFile(
'# this is a full line comment\nnodejs 16.16.0 # this is a comment\n'
);
expect(res.deps).toEqual([
{
currentValue: 'nodejs 16.16.0',
datasource: 'github-tags',
depName: 'node',
packageName: 'nodejs/node',
},
]);
});

it('ignores supported tooling with a renovate:ignore comment', () => {
const res = extractPackageFile('nodejs 16.16.0 # renovate:ignore\n');
expect(res.deps).toEqual([]);
});
});
});
});
40 changes: 40 additions & 0 deletions lib/modules/manager/asdf/extract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { logger } from '../../../logger';
import { isSkipComment } from '../../../util/ignore';
import { GithubTagsDatasource } from '../../datasource/github-tags';
import type { PackageDependency, PackageFile } from '../types';

const upgradeableTooling: Record<
string,
Pick<PackageDependency, 'depName' | 'datasource' | 'packageName'>
> = {
nodejs: {
depName: 'node',
datasource: GithubTagsDatasource.id,
packageName: 'nodejs/node',
sawilde marked this conversation as resolved.
Show resolved Hide resolved
},
};

export function extractPackageFile(content: string): PackageFile {
sawilde marked this conversation as resolved.
Show resolved Hide resolved
logger.trace('asdf.extractPackageFile()');

const regex =
/^(?<content>(?<toolname>(\w+))\s+(?<version>(\d[\d.]+\d)))([^#]*(#(?<comment>(.*))))?/gm;
sawilde marked this conversation as resolved.
Show resolved Hide resolved

const deps = [...content.matchAll(regex)]
.filter((match) => !!match.groups)
.map((match) => match.groups!)
.filter((groups) => upgradeableTooling[groups['toolname']])
.filter((groups) => !isSkipComment((groups['comment'] ?? '').trim()))
.map((groups) => {
sawilde marked this conversation as resolved.
Show resolved Hide resolved
const tool = upgradeableTooling[groups['toolname']];
const dep: PackageDependency = {
depName: tool.depName,
currentValue: groups['content'].trim(),
sawilde marked this conversation as resolved.
Show resolved Hide resolved
datasource: tool.datasource,
packageName: tool.packageName,
};
return dep;
});

return { deps };
sawilde marked this conversation as resolved.
Show resolved Hide resolved
}
11 changes: 11 additions & 0 deletions lib/modules/manager/asdf/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { GithubTagsDatasource } from '../../datasource/github-tags';

export { extractPackageFile } from './extract';

export const displayName = 'asdf';

export const defaultConfig = {
fileMatch: ['(^|/)\\.tools-versions$'],
};

export const supportedDatasources = [GithubTagsDatasource.id];
8 changes: 8 additions & 0 deletions lib/modules/manager/asdf/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Keeps the [asdf](https://asdf-vm.com/manage/configuration.html#tool-versions)
`.tools-versions` file updated.

Because asdf supports the version management of many different tools, only a few of those that are also supported by renovate will be targeted by this manager.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

Currently, only the following is supported

- [nodejs](https://github.com/asdf-vm/asdf-nodejs)