More fixes for CI
This commit is contained in:
parent
2c12fdd04a
commit
d9014b2342
|
@ -5,13 +5,14 @@ import { promisify } from "util";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { Moment } from "moment";
|
import { Moment } from "moment";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import PQueue from "p-queue";
|
import pQueue from "p-queue";
|
||||||
|
const PQueue = pQueue.default;
|
||||||
import rimraf from "rimraf";
|
import rimraf from "rimraf";
|
||||||
import stripAnsi from "strip-ansi";
|
import stripAnsi from "strip-ansi";
|
||||||
import { v4 as getUUID } from "uuid";
|
import { v4 as getUUID } from "uuid";
|
||||||
|
|
||||||
import api from "./api";
|
import api from "./api";
|
||||||
import { LangConfig, langs } from "./langs";
|
import { langs } from "./langs";
|
||||||
|
|
||||||
function parseIntOr(thing, def) {
|
function parseIntOr(thing, def) {
|
||||||
const num = parseInt(thing);
|
const num = parseInt(thing);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
|
import { promises as fs } from "fs";
|
||||||
import process from "process";
|
import process from "process";
|
||||||
|
|
||||||
import { getLangs } from "./config.js";
|
import { getLangs } from "./config.js";
|
||||||
|
@ -8,13 +9,24 @@ import { runCommand } from "./util.js";
|
||||||
async function main() {
|
async function main() {
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
if (args.length !== 1) {
|
if (args.length !== 1) {
|
||||||
console.error("usage: node hash-composite-image.js (local | remote)");
|
console.error(
|
||||||
|
"usage: node hash-composite-image.js (scripts | debs | remote)"
|
||||||
|
);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const mode = args[0];
|
const mode = args[0];
|
||||||
let getHash;
|
let getHash;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case "local":
|
case "scripts":
|
||||||
|
getHash = async (lang, type) => {
|
||||||
|
const text = await fs.readFile(
|
||||||
|
`build/${type}/${lang}/build.bash`,
|
||||||
|
"utf-8"
|
||||||
|
);
|
||||||
|
return crypto.createHash("sha1").update(text).digest("hex");
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case "debs":
|
||||||
getHash = async (lang, type) => {
|
getHash = async (lang, type) => {
|
||||||
return (
|
return (
|
||||||
await runCommand(
|
await runCommand(
|
||||||
|
@ -24,7 +36,7 @@ async function main() {
|
||||||
).stdout.trim();
|
).stdout.trim();
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "remote":
|
case "s3":
|
||||||
const remoteHashes = Object.fromEntries(
|
const remoteHashes = Object.fromEntries(
|
||||||
(
|
(
|
||||||
await runCommand("tools/list-s3-hashes.bash", { getStdout: true })
|
await runCommand("tools/list-s3-hashes.bash", { getStdout: true })
|
||||||
|
|
|
@ -66,8 +66,19 @@ for lang in "${langs[@]}"; do
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
composite_local_hash="$(node tools/hash-composite-image.js local)"
|
for lang in "${langs[@]}"; do
|
||||||
composite_remote_hash="$(node tools/hash-composite-image.js remote)"
|
for type in lang config; do
|
||||||
|
pkg="riju-${type}-${lang}"
|
||||||
|
hash="${local_hashes["${pkg}"]}"
|
||||||
|
published_hash="${published_hashes["${pkg}"]:-}"
|
||||||
|
if [[ "${published_hash}" != "${hash}" ]]; then
|
||||||
|
make download L="${lang}" T="${type}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
composite_local_hash="$(node tools/hash-composite-image.js scripts)"
|
||||||
|
composite_remote_hash="$(node tools/hash-composite-image.js s3)"
|
||||||
|
|
||||||
if [[ "${composite_local_hash}" != "${composite_remote_hash}" ]]; then
|
if [[ "${composite_local_hash}" != "${composite_remote_hash}" ]]; then
|
||||||
make image push I=composite
|
make image push I=composite
|
||||||
|
|
|
@ -39,7 +39,7 @@ export async function runCommand(cmd, options) {
|
||||||
proc.on("close", (code) => resolve({ code, ...rv }));
|
proc.on("close", (code) => resolve({ code, ...rv }));
|
||||||
});
|
});
|
||||||
if (rv.code !== 0) {
|
if (rv.code !== 0) {
|
||||||
throw new Error(`command exited with code ${code}`);
|
throw new Error(`command exited with code ${rv.code}`);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue