Skip to content

Commit

Permalink
feat: add conda versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Feb 21, 2025
1 parent c7737be commit 027966d
Show file tree
Hide file tree
Showing 6 changed files with 446 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/modules/versioning/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as bazelModule from './bazel-module';
import * as cargo from './cargo';
import * as composer from './composer';
import * as conan from './conan';
import * as conda from './conda';
import * as deb from './deb';
import * as debian from './debian';
import * as devbox from './devbox';
Expand Down Expand Up @@ -53,6 +54,7 @@ api.set(bazelModule.id, bazelModule.api);
api.set(cargo.id, cargo.api);
api.set(composer.id, composer.api);
api.set(conan.id, conan.api);
api.set(conda.id, conda.api);
api.set(deb.id, deb.api);
api.set(debian.id, debian.api);
api.set(devbox.id, devbox.api);
Expand Down
249 changes: 249 additions & 0 deletions lib/modules/versioning/conda/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
import { api } from '.';

describe('modules/versioning/conda/index', () => {
it.each`
input | expected
${'0.750'} | ${true}
${'1.2.3'} | ${true}
${'1.9'} | ${true}
${'17.04.0'} | ${true}
${'==1.2.3'} | ${true}
${'==1.2.3.0'} | ${true}
${'==1.2.3rc0'} | ${true}
${'~=1.2.3'} | ${true}
${'1.2.*'} | ${true}
${'>1.2.3'} | ${true}
${'renovatebot/renovate'} | ${false}
${'renovatebot/renovate#master'} | ${false}
${'https://github.com/renovatebot/renovate.git'} | ${false}
`('isValid("$input") === $expected', ({ input, expected }) => {
const res = !!api.isValid(input);
expect(res).toBe(expected);
});

it.each`
input | expected
${'1.2.3'} | ${true}
${'1.2.3rc0'} | ${false}
${'not..version..1'} | ${false}
`('isStable("$input") === $expected', ({ input, expected }) => {
expect(api.isStable(input)).toBe(expected);
});

it.each`
a | b | expected
${'1.0'} | ${'1.0.0'} | ${true}
${'1.0.0'} | ${'1.0.foo'} | ${false}
`('equals($a, $b) === $expected', ({ a, b, expected }) => {
expect(api.equals(a, b)).toBe(expected);
});

it.each`
a | b | expected
${'1.0'} | ${'>=1.0.0'} | ${true}
${'3.0.0'} | ${'==3.0.0'} | ${true}
${'1.6.2'} | ${'<2.2.1.0'} | ${true}
${'3.8'} | ${'>=3.9'} | ${false}
`('matches($a, $b) === $expected', ({ a, b, expected }) => {
expect(api.matches(a, b)).toBe(expected);
});

it.each`
version | isSingle
${'==1.2.3'} | ${true}
${'==1.2.3rc0'} | ${true}
${'==1.2.3'} | ${true}
${'==1.2'} | ${true}
${'== 1.2.3'} | ${true}
${'==1.*'} | ${false}
`('isSingleVersion("$version") === $isSingle', ({ version, isSingle }) => {
const res = !!api.isSingleVersion(version);
expect(res).toBe(isSingle);
});

const versions = [
'0.9.4',
'1.0.0',
'1.1.5',
'1.2.1',
'1.2.2',
'1.2.3',
'1.3.4',
'2.0.3',
];

it.each`
range | expected
${'~=1.2.1'} | ${'1.2.3'}
${'~=2.1'} | ${null}
`(
'getSatisfyingVersion($versions, "$range") === $expected',
({ range, expected }) => {
expect(api.getSatisfyingVersion(versions, range)).toBe(expected);
},
);

it.each`
range | expected
${'~=1.2.1'} | ${'1.2.1'}
${'~=2.1'} | ${null}
`(
'minSatisfyingVersion($versions, "$range") === $expected',
({ range, expected }) => {
expect(api.minSatisfyingVersion(versions, range)).toBe(expected);
},
);

it.each`
currentValue | rangeStrategy | currentVersion | newVersion | expected
${'==1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'==1.2.3'}
${'==1.0.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'==1.2.3'}
${'>=1.2.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'==1.2.3'}
${'~=1.2.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'==1.2.3'}
${'~=1.0.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'==1.2.*'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'==1.0.*'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'<1.2.2.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'<1.2.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'<1.2'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'<1'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'<2.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'==1.2.3'}
${'>0.9.8'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'==1.2.3'}
${'>2.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'>=2.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'~=1.1.0, !=1.1.1'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'~=1.1.0,!=1.1.1'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${' '} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'==1.2.3'}
${'invalid'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
${'==1.0.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'==1.2.3'}
${'!=1.2.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${null}
`(
'getNewValue("$currentValue", "$rangeStrategy", "$currentVersion", "$newVersion") === "$expected"',
({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => {
const res = api.getNewValue({
currentValue,
rangeStrategy,
currentVersion,
newVersion,
});
expect(res).toEqual(expected);
},
);

// it.each`
// currentValue | rangeStrategy | currentVersion | newVersion | expected
// ${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'==1.0.3'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'==1.0.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'==1.0.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>=1.2.0'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>=1.2.0'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.2.0'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.2.0'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>=1.2.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.2.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.0.3'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.0.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.0.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'==1.2.*'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'==1.2.*'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'==1.2.*'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'==1.0.*'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'==1.0.*'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'==1.0.*'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1.2.2.3'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1.2.2.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1.2.3'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1.2.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1.2.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1.2'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1.2'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1.2'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<1'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<2.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<2.0.0'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'<2.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>0.9.8'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>0.9.8'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>0.9.8'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>2.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>2.0.0'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>2.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>=2.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>=2.0.0'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>=2.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.1.0, !=1.1.1'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.1.0, !=1.1.1'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.1.0, !=1.1.1'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.1.0,!=1.1.1'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.1.0,!=1.1.1'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.1.0,!=1.1.1'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${' '} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${' '} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${' '} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'invalid'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'invalid'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'invalid'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'===1.0.3'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'===1.0.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'===1.0.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'!=1.2.3'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'!=1.2.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'!=1.2.3'} | ${'pin'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'~=1.1.0,!=1.1.1'} | ${'unsupported'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
// ${'>=19.12.2,<20.13.9'} | ${'replace'} | ${'19.12.2'} | ${'21.3.1'} | ${'21.3.1'}
// ${'>=19.12.2,<19.13.9'} | ${'replace'} | ${'19.12.2'} | ${'20.3.1'} | ${'20.3.1'}
// ${'>=19.12.2,<19.13.0'} | ${'replace'} | ${'19.12.2'} | ${'20.3.1'} | ${'20.3.1'}
// ${'>=19.12.2,<19.13.0'} | ${'replace'} | ${'19.12.2'} | ${'20.3.0'} | ${'20.3.0'}
// ${'>=19.12.2,<19.13.0'} | ${'replace'} | ${'19.12.2'} | ${'19.13.1'} | ${'19.13.1'}
// ${'>=19.12.2,<19.13.0'} | ${'replace'} | ${'19.12.2'} | ${'19.13.0'} | ${'19.13.0'}
// ${'>=19.12.2,<19.13.0'} | ${'auto'} | ${'19.12.2'} | ${'19.13.0'} | ${'19.13.0'}
// ${'>=19.12.2,<20.13.9'} | ${'widen'} | ${'19.12.2'} | ${'21.3.1'} | ${'21.3.1'}
// ${'>=19.12.2,<19.13.9'} | ${'widen'} | ${'19.12.2'} | ${'20.3.1'} | ${'20.3.1'}
// ${'>=19.12.2,<19.13.0'} | ${'widen'} | ${'19.12.2'} | ${'20.3.1'} | ${'20.3.1'}
// ${'>=19.12.2,<19.13.0'} | ${'widen'} | ${'19.12.2'} | ${'20.3.0'} | ${'20.3.0'}
// ${'>=19.12.2,<19.13.0'} | ${'widen'} | ${'19.12.2'} | ${'19.13.1'} | ${'19.13.1'}
// ${'>=19.12.2,<19.13.0'} | ${'widen'} | ${'19.12.2'} | ${'19.13.0'} | ${'19.13.0'}
// ${'~=7.2'} | ${'replace'} | ${'7.2.0'} | ${'8.0.1'} | ${'8.0.1'}
// ${'~=7.2'} | ${'replace'} | ${'7.2.0'} | ${'8'} | ${'8'}
// ${'~=7.2.0'} | ${'replace'} | ${'7.2.0'} | ${'8.2'} | ${'8.2'}
// ${'~=7.2'} | ${'widen'} | ${'7.2.0'} | ${'8.0.1'} | ${'8.0.1'}
// ${'~=7.2'} | ${'widen'} | ${'7.2.0'} | ${'8'} | ${'8'}
// ${'~=7.2.0'} | ${'widen'} | ${'7.2.0'} | ${'8.2'} | ${'8.2'}
// ${'==3.2.*,>=3.2.2'} | ${'replace'} | ${'3.2.2'} | ${'4.1.1'} | ${'4.1.1'}
// ${'==3.2.*,>=3.2.2'} | ${'replace'} | ${'3.2.2'} | ${'4.0.0'} | ${'4.0.0'}
// ${'>=1.0.0,<1.1.0'} | ${'replace'} | ${'1.0.0'} | ${'1.2.0'} | ${'1.2.0'}
// ${'<1.3.0'} | ${'bump'} | ${'1.3.0'} | ${'0.9.2'} | ${'0.9.2'}
// ${'<1.3.0'} | ${'bump'} | ${'0.9.0'} | ${'0.9.2'} | ${'0.9.2'}
// ${'<=1.3.0'} | ${'bump'} | ${'0.9.0'} | ${'0.9.2'} | ${'0.9.2'}
// ${'<=1.3.0'} | ${'bump'} | ${'1.3.0'} | ${'0.9.2'} | ${'0.9.2'}
// ${'<1.3.0'} | ${'bump'} | ${'1.3.0'} | ${'1.6.0'} | ${'1.6.0'}
// ${'<1.3.0'} | ${'bump'} | ${'0.9.0'} | ${'1.6.0'} | ${'1.6.0'}
// ${'<=1.3.0'} | ${'bump'} | ${'0.9.0'} | ${'1.6.0'} | ${'1.6.0'}
// ${'<=1.3.0'} | ${'bump'} | ${'1.3.0'} | ${'1.6.0'} | ${'1.6.0'}
// ${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'==1.2.3'} | ${'==1.2.3'}
// ${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'>=1.2.3'} | ${'>=1.2.3'}
// ${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'<=1.2.3'} | ${'<=1.2.3'}
// ${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'~=1.2.3'} | ${'~=1.2.3'}
// ${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'!=1.2.3'} | ${'!=1.2.3'}
// ${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'>1.2.3'} | ${'>1.2.3'}
// ${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'<1.2.3'} | ${'<1.2.3'}
// `(
// 'getNewValue("$currentValue", "$rangeStrategy", "$currentVersion", "$newVersion") === "$expected"',
// ({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => {
// const isReplacement = true;
// const res = api.getNewValue({
// currentValue,
// rangeStrategy,
// currentVersion,
// newVersion,
// isReplacement,
// });
// expect(res).toEqual(expected);
// },
// );
});
Loading

0 comments on commit 027966d

Please sign in to comment.