Compute transitive dependencies
This commit is contained in:
parent
00c3a4117a
commit
b986cf69af
|
@ -1,4 +1,4 @@
|
||||||
FROM ubuntu:rolling AS build
|
FROM riju:ubuntu AS build
|
||||||
|
|
||||||
COPY docker/app/install-build.bash /tmp/
|
COPY docker/app/install-build.bash /tmp/
|
||||||
RUN /tmp/install-build.bash
|
RUN /tmp/install-build.bash
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM ubuntu:rolling
|
FROM riju:ubuntu
|
||||||
|
|
||||||
COPY docker/base/install.bash /tmp/
|
COPY docker/base/install.bash /tmp/
|
||||||
RUN /tmp/install.bash
|
RUN /tmp/install.bash
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM ubuntu:rolling
|
FROM riju:ubuntu
|
||||||
|
|
||||||
COPY docker/packaging/install.bash /tmp/
|
COPY docker/packaging/install.bash /tmp/
|
||||||
RUN /tmp/install.bash
|
RUN /tmp/install.bash
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM ubuntu:rolling
|
FROM riju:ubuntu
|
||||||
|
|
||||||
COPY docker/runtime/install.bash /tmp/
|
COPY docker/runtime/install.bash /tmp/
|
||||||
RUN /tmp/install.bash
|
RUN /tmp/install.bash
|
||||||
|
|
|
@ -4,6 +4,7 @@ import process from "process";
|
||||||
import url from "url";
|
import url from "url";
|
||||||
|
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
import { getTestHash } from "../lib/hash-test.js";
|
import { getTestHash } from "../lib/hash-test.js";
|
||||||
import {
|
import {
|
||||||
|
@ -76,13 +77,11 @@ async function getImageArtifact({ tag, isBaseImage, isLangImage }) {
|
||||||
}
|
}
|
||||||
return baseImage.replace(/^riju:/, "");
|
return baseImage.replace(/^riju:/, "");
|
||||||
});
|
});
|
||||||
dependencies = baseImageTags.map(
|
dependencies = baseImageTags.map((baseImageTag) => `image:${baseImageTag}`);
|
||||||
(baseImageName) => `image:${baseImageTag}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (isLangImage) {
|
if (isLangImage) {
|
||||||
dependencies.push(`deb:lang-${isLangImage.lang}`);
|
dependencies.push(`deb:lang-${isLangImage.lang}`);
|
||||||
dependencies.concat(
|
dependencies = dependencies.concat(
|
||||||
isLangImage.sharedDeps.map((name) => `deb:shared-${name}`)
|
isLangImage.sharedDeps.map((name) => `deb:shared-${name}`)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +177,7 @@ async function getDebArtifact({ type, lang }) {
|
||||||
async function getLanguageTestArtifact({ lang }) {
|
async function getLanguageTestArtifact({ lang }) {
|
||||||
return {
|
return {
|
||||||
name: `test:lang-${lang}`,
|
name: `test:lang-${lang}`,
|
||||||
dependencies: ["image:runtime"],
|
dependencies: ["image:runtime", `image:lang-${lang}`],
|
||||||
informationalDependencies: {
|
informationalDependencies: {
|
||||||
getPublishedHash: "s3TestHashes",
|
getPublishedHash: "s3TestHashes",
|
||||||
retrieveFromRegistry: "s3TestHashes",
|
retrieveFromRegistry: "s3TestHashes",
|
||||||
|
@ -274,8 +273,30 @@ async function getDepGraph() {
|
||||||
return { informationalDependencies, artifacts };
|
return { informationalDependencies, artifacts };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function executeDepGraph({ publish, yes, targets }) {
|
function getTransitiveDependencies({ artifacts, targets }) {
|
||||||
//
|
let queue = targets;
|
||||||
|
let found = new Set();
|
||||||
|
while (queue.length > 0) {
|
||||||
|
const name = queue.pop();
|
||||||
|
if (found.has(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!artifacts[name]) {
|
||||||
|
throw new Error(`no such artifact: ${name}`);
|
||||||
|
}
|
||||||
|
queue = queue.concat(artifacts[name].dependencies);
|
||||||
|
found.add(name);
|
||||||
|
}
|
||||||
|
return _.sortBy([...found], (name) => Object.keys(artifacts).indexOf(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function executeDepGraph({ depgraph, publish, yes, targets }) {
|
||||||
|
const artifacts = {};
|
||||||
|
for (const artifact of depgraph.artifacts) {
|
||||||
|
artifacts[artifact.name] = artifact;
|
||||||
|
}
|
||||||
|
const transitiveTargets = getTransitiveDependencies({ artifacts, targets });
|
||||||
|
console.log(transitiveTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
@ -298,7 +319,7 @@ async function main() {
|
||||||
if (program.args.length === 0) {
|
if (program.args.length === 0) {
|
||||||
program.help({ error: true });
|
program.help({ error: true });
|
||||||
}
|
}
|
||||||
await executeDepGraph({ publish, yes, targets: program.args });
|
await executeDepGraph({ depgraph, publish, yes, targets: program.args });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.argv[1] === url.fileURLToPath(import.meta.url)) {
|
if (process.argv[1] === url.fileURLToPath(import.meta.url)) {
|
||||||
|
|
|
@ -70,13 +70,13 @@ export async function getBaseImages(name) {
|
||||||
dockerfile.map(({ name, args, error }) => {
|
dockerfile.map(({ name, args, error }) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
throw error;
|
throw error;
|
||||||
if (name === "FROM") {
|
}
|
||||||
if (typeof args !== "string") {
|
if (name === "FROM") {
|
||||||
throw new Error("got unexpected non-string for FROM args");
|
if (typeof args !== "string") {
|
||||||
}
|
throw new Error("got unexpected non-string for FROM args");
|
||||||
const image = args.split(" ")[0];
|
|
||||||
baseImages.push(image);
|
|
||||||
}
|
}
|
||||||
|
const image = args.split(" ")[0];
|
||||||
|
baseImages.push(image);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return baseImages;
|
return baseImages;
|
||||||
|
|
Loading…
Reference in New Issue