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): support mise backends #33113

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e811461
feat(manager): support mise backends
risu729 Dec 14, 2024
cbdb797
refactor: split backends to new file
risu729 Dec 15, 2024
b6886a9
test: fix nested tests
risu729 Dec 15, 2024
8b6c6aa
test: remove tests with escapes
risu729 Dec 15, 2024
27d6b1d
test: fix toml escapes in fixtures
risu729 Dec 15, 2024
01e306f
fix: fix regex
risu729 Dec 15, 2024
fd9118e
test: add missing caret
risu729 Dec 15, 2024
3f36ff3
Merge branch 'main' into feat/mise-backends
risu729 Dec 15, 2024
68af992
feat: support git url syntax of cargo backended tools
risu729 Dec 15, 2024
e303e6a
docs: update readme
risu729 Dec 15, 2024
95be7f4
feat: support pipx git hash syntax
risu729 Dec 15, 2024
c6e0cfc
test: add test for pipx git url
risu729 Dec 15, 2024
0b47a6b
fix: use g flag for regexes in replaceAll
risu729 Dec 15, 2024
3ef0305
test: fix packageName in pipx test
risu729 Dec 15, 2024
af40deb
test: add test for unsupported backends
risu729 Dec 15, 2024
02e8ce5
test: fix unsupported backend test
risu729 Dec 15, 2024
ac2dd31
Merge branch 'main' into feat/mise-backends
risu729 Dec 15, 2024
f26b4d1
fix: trim leading v prefix automatically
risu729 Dec 23, 2024
d8b7f0b
Merge branch 'main' into feat/mise-backends
risu729 Dec 23, 2024
5e042cb
fix: do not include options in packageName
risu729 Dec 27, 2024
63265b8
test: fix typo
risu729 Dec 27, 2024
ae07f50
fix: revert order of version and config null checks
risu729 Dec 27, 2024
237f1b7
test: remove leadin v from extractVersion
risu729 Dec 27, 2024
60a025b
feat: support dotnet backend
risu729 Dec 27, 2024
37aa7ae
feat: support gem backend
risu729 Dec 27, 2024
6480bad
Merge branch 'main' into feat/mise-backends
risu729 Dec 27, 2024
0e13a05
fix
risu729 Dec 28, 2024
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
263 changes: 263 additions & 0 deletions lib/modules/manager/mise/backends.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
import {
createAquaToolConfig,
createCargoToolConfig,
createDotnetToolConfig,
createGemToolConfig,
createGoToolConfig,
createNpmToolConfig,
createPipxToolConfig,
createSpmToolConfig,
createUbiToolConfig,
} from './backends';

describe('modules/manager/mise/backends', () => {
describe('createAquaToolConfig()', () => {
it('should create a tooling config', () => {
expect(
createAquaToolConfig('BurntSushi/ripgrep', '14.1.1'),
).toStrictEqual({
packageName: 'BurntSushi/ripgrep',
datasource: 'github-tags',
currentValue: '14.1.1',
extractVersion: '^v?(?<version>.+)',
});
});

it('should trim the leading v from version', () => {
expect(
createAquaToolConfig('BurntSushi/ripgrep', 'v14.1.1'),
).toStrictEqual({
packageName: 'BurntSushi/ripgrep',
datasource: 'github-tags',
currentValue: '14.1.1',
extractVersion: '^v?(?<version>.+)',
});
});
});

describe('createCargoToolConfig()', () => {
it('should create a tooling config for crate', () => {
expect(createCargoToolConfig('eza', '')).toStrictEqual({
packageName: 'eza',
datasource: 'crate',
});
});

it('should create a tooling config for git tag', () => {
expect(
createCargoToolConfig('https://github.com/username/demo', 'tag:v0.1.0'),
).toStrictEqual({
packageName: 'https://github.com/username/demo',
currentValue: 'v0.1.0',
datasource: 'git-tags',
});
});

it('should provide skipReason for git branch', () => {
expect(
createCargoToolConfig(
'https://github.com/username/demo',
'branch:main',
),
).toStrictEqual({
packageName: 'https://github.com/username/demo',
skipReason: 'unsupported-version',
});
});

it('should create a tooling config for git rev', () => {
expect(
createCargoToolConfig('https://github.com/username/demo', 'rev:abcdef'),
).toStrictEqual({
packageName: 'https://github.com/username/demo',
currentValue: 'abcdef',
datasource: 'git-refs',
});
});

it('should provide skipReason for invalid version', () => {
expect(
createCargoToolConfig('https://github.com/username/demo', 'v0.1.0'),
).toStrictEqual({
packageName: 'https://github.com/username/demo',
skipReason: 'invalid-version',
});
});
});

describe('createDotnetToolConfig()', () => {
it('should create a tooling config', () => {
expect(createDotnetToolConfig('GitVersion.Tool')).toStrictEqual({
packageName: 'GitVersion.Tool',
datasource: 'nuget',
});
});
});

describe('createGemToolConfig()', () => {
it('should create a tooling config', () => {
expect(createGemToolConfig('rubocop')).toStrictEqual({
packageName: 'rubocop',
datasource: 'rubygems',
});
});
});

describe('createGoToolConfig()', () => {
it('should create a tooling config', () => {
expect(createGoToolConfig('github.com/DarthSim/hivemind')).toStrictEqual({
packageName: 'github.com/DarthSim/hivemind',
datasource: 'go',
});
});
});

describe('createNpmToolConfig()', () => {
it('should create a tooling config', () => {
expect(createNpmToolConfig('prettier')).toStrictEqual({
packageName: 'prettier',
datasource: 'npm',
});
});
});

describe('createPipxToolConfig()', () => {
it('should create a tooling config for pypi package', () => {
expect(createPipxToolConfig('yamllint')).toStrictEqual({
packageName: 'yamllint',
datasource: 'pypi',
});
});

it('should create a tooling config for github shorthand', () => {
expect(createPipxToolConfig('psf/black')).toStrictEqual({
packageName: 'psf/black',
datasource: 'github-tags',
});
});

it('should create a tooling config for github url', () => {
expect(
createPipxToolConfig('git+https://github.com/psf/black.git'),
).toStrictEqual({
packageName: 'psf/black',
datasource: 'github-tags',
});
});

it('should create a tooling config for git url', () => {
expect(
createPipxToolConfig('git+https://gitlab.com/user/repo.git'),
).toStrictEqual({
packageName: 'https://gitlab.com/user/repo',
datasource: 'git-refs',
});
});

it('provides skipReason for zip file url', () => {
expect(
createPipxToolConfig('https://github.com/psf/black/archive/18.9b0.zip'),
).toStrictEqual({
packageName: 'https://github.com/psf/black/archive/18.9b0.zip',
skipReason: 'unsupported-url',
});
});
});

describe('createSpmToolConfig()', () => {
it('should create a tooling config for github shorthand', () => {
expect(createSpmToolConfig('tuist/tuist')).toStrictEqual({
packageName: 'tuist/tuist',
datasource: 'github-releases',
});
});

it('should create a tooling config for github url', () => {
expect(
createSpmToolConfig('https://github.com/tuist/tuist.git'),
).toStrictEqual({
packageName: 'tuist/tuist',
datasource: 'github-releases',
});
});

it('provides skipReason for other url', () => {
expect(
createSpmToolConfig('https://gitlab.com/user/repo.git'),
).toStrictEqual({
packageName: 'https://gitlab.com/user/repo.git',
skipReason: 'unsupported-url',
});
});
});

describe('createUbiToolConfig()', () => {
it('should create a tooling config with empty options', () => {
expect(createUbiToolConfig('nekto/act', '0.2.70', {})).toStrictEqual({
packageName: 'nekto/act',
datasource: 'github-releases',
currentValue: '0.2.70',
extractVersion: '^v?(?<version>.+)',
});
});

it('should trim the leading v from version', () => {
expect(createUbiToolConfig('cli/cli', 'v2.64.0', {})).toStrictEqual({
packageName: 'cli/cli',
datasource: 'github-releases',
currentValue: '2.64.0',
extractVersion: '^v?(?<version>.+)',
});
});

it('should ignore options unless tag_regex is provided', () => {
expect(
createUbiToolConfig('cli/cli', '2.64.0', { exe: 'gh' } as any),
).toStrictEqual({
packageName: 'cli/cli',
datasource: 'github-releases',
currentValue: '2.64.0',
extractVersion: '^v?(?<version>.+)',
});
});

it('should set extractVersion if tag_regex is provided', () => {
expect(
createUbiToolConfig('cargo-bins/cargo-binstall', '1.10.17', {
tag_regex: '^\\d+\\.\\d+\\.',
}),
).toStrictEqual({
packageName: 'cargo-bins/cargo-binstall',
datasource: 'github-releases',
currentValue: '1.10.17',
extractVersion: '^v?(?<version>\\d+\\.\\d+\\.)',
});
});

it('should trim the leading ^v from tag_regex', () => {
expect(
createUbiToolConfig('cargo-bins/cargo-binstall', '1.10.17', {
tag_regex: '^v\\d+\\.\\d+\\.',
}),
).toStrictEqual({
packageName: 'cargo-bins/cargo-binstall',
datasource: 'github-releases',
currentValue: '1.10.17',
extractVersion: '^v?(?<version>\\d+\\.\\d+\\.)',
});
});

it('should trim the leading ^v? from tag_regex', () => {
expect(
createUbiToolConfig('cargo-bins/cargo-binstall', '1.10.17', {
tag_regex: '^v?\\d+\\.\\d+\\.',
}),
).toStrictEqual({
packageName: 'cargo-bins/cargo-binstall',
datasource: 'github-releases',
currentValue: '1.10.17',
extractVersion: '^v?(?<version>\\d+\\.\\d+\\.)',
});
});
});
});
Loading
Loading