Skip to content

Commit

Permalink
feat(manager/elixir): support install binary source (#16710)
Browse files Browse the repository at this point in the history
* feat(manager/elixir): support install binary source

* test: fix snapshot
  • Loading branch information
viceice authored Jul 22, 2022
1 parent 892595a commit 6854145
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/modules/manager/mix/__snapshots__/artifacts.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Array [
exports[`modules/manager/mix/artifacts authenticates to private repositories 2`] = `
Array [
Object {
"cmd": "docker ps --filter name=renovate_elixir -aq",
"cmd": "docker ps --filter name=renovate_sidecar -aq",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker run --rm --name=renovate_elixir --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -v \\"/tmp/cache\\":\\"/tmp/cache\\" -e BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/elixir bash -l -c \\"mix hex.organization auth renovate_test --key valid_test_token && mix deps.update private_package other_package\\"",
"cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -v \\"/tmp/cache\\":\\"/tmp/cache\\" -e BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool erlang 24.3.4.2 && install-tool elixir v1.13.4 && mix hex.organization auth renovate_test --key valid_test_token && mix deps.update private_package other_package\\"",
"options": Object {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand Down Expand Up @@ -68,19 +68,19 @@ Array [
exports[`modules/manager/mix/artifacts returns updated mix.lock 1`] = `
Array [
Object {
"cmd": "docker pull renovate/elixir",
"cmd": "docker pull renovate/sidecar",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker ps --filter name=renovate_elixir -aq",
"cmd": "docker ps --filter name=renovate_sidecar -aq",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker run --rm --name=renovate_elixir --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -v \\"/tmp/cache\\":\\"/tmp/cache\\" -e BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/elixir bash -l -c \\"mix deps.update plug\\"",
"cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -v \\"/tmp/cache\\":\\"/tmp/cache\\" -e BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool erlang 24.3.4.2 && install-tool elixir 1.13.4 && mix deps.update plug\\"",
"options": Object {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand Down
45 changes: 44 additions & 1 deletion lib/modules/manager/mix/artifacts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { join } from 'upath';
import { envMock, mockExecAll } from '../../../../test/exec-util';
import { env, fs, hostRules } from '../../../../test/util';
import { env, fs, hostRules, mockedFunction } from '../../../../test/util';
import { GlobalConfig } from '../../../config/global';
import type { RepoGlobalConfig } from '../../../config/types';
import * as docker from '../../../util/exec/docker';
import { getPkgReleases as _getPkgReleases } from '../../datasource';
import type { UpdateArtifactsConfig } from '../types';
import { updateArtifacts } from '.';

jest.mock('../../../util/exec/env');
jest.mock('../../../util/fs');
jest.mock('../../../util/host-rules');
jest.mock('../../datasource');

const getPkgReleases = mockedFunction(_getPkgReleases);

const adminConfig: RepoGlobalConfig = {
// `join` fixes Windows CI
Expand Down Expand Up @@ -87,6 +91,26 @@ describe('modules/manager/mix/artifacts', () => {
fs.findLocalSiblingOrParent.mockResolvedValueOnce('mix.lock');
const execSnapshots = mockExecAll();
fs.readLocalFile.mockResolvedValueOnce('New mix.lock');

// erlang
getPkgReleases.mockResolvedValueOnce({
releases: [
{ version: '22.3.4.26' },
{ version: '23.1.1.0' },
{ version: '24.3.4.1' },
{ version: '24.3.4.2' },
{ version: '25.0.0.0' },
],
});
// elixir
getPkgReleases.mockResolvedValueOnce({
releases: [
{ version: '1.8.2' },
{ version: '1.13.3' },
{ version: '1.13.4' },
],
});

expect(
await updateArtifacts({
packageFileName: 'mix.exs',
Expand All @@ -112,6 +136,25 @@ describe('modules/manager/mix/artifacts', () => {
hostRules.find.mockReturnValueOnce({ token: 'valid_test_token' });
hostRules.find.mockReturnValueOnce({});

// erlang
getPkgReleases.mockResolvedValueOnce({
releases: [
{ version: '22.3.4.26' },
{ version: '23.1.1.0' },
{ version: '24.3.4.1' },
{ version: '24.3.4.2' },
{ version: '25.0.0.0' },
],
});
// elixir
getPkgReleases.mockResolvedValueOnce({
releases: [
{ version: 'v1.8.2' },
{ version: 'v1.13.3' },
{ version: 'v1.13.4' },
],
});

const result = await updateArtifacts({
packageFileName: 'mix.exs',
updatedDeps: [
Expand Down
12 changes: 11 additions & 1 deletion lib/modules/manager/mix/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,18 @@ export async function updateArtifacts({
const execOptions: ExecOptions = {
cwdFile: packageFileName,
docker: {
image: 'elixir',
image: 'sidecar',
},
toolConstraints: [
{
toolName: 'erlang',
// https://hexdocs.pm/elixir/1.13.4/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp
constraint: '^24',
},
{
toolName: 'elixir',
},
],
preCommands,
};
const command = [
Expand Down
11 changes: 11 additions & 0 deletions lib/util/exec/buildpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { id as npmVersioningId } from '../../modules/versioning/npm';
import { id as pep440VersioningId } from '../../modules/versioning/pep440';
import { id as rubyVersioningId } from '../../modules/versioning/ruby';
import { id as semverVersioningId } from '../../modules/versioning/semver';
import { id as semverCoercedVersioningId } from '../../modules/versioning/semver-coerced';
import type { Opt, ToolConfig, ToolConstraint } from './types';

const allToolConfig: Record<string, ToolConfig> = {
Expand All @@ -32,6 +33,16 @@ const allToolConfig: Record<string, ToolConfig> = {
depName: 'corepack',
versioning: npmVersioningId,
},
erlang: {
datasource: 'github-releases',
depName: 'containerbase/erlang-prebuild',
versioning: semverCoercedVersioningId,
},
elixir: {
datasource: 'github-releases',
depName: 'elixir-lang/elixir',
versioning: semverVersioningId,
},
flux: {
datasource: 'github-releases',
depName: 'fluxcd/flux2',
Expand Down

0 comments on commit 6854145

Please sign in to comment.