More fixes for CI

This commit is contained in:
Radon Rosborough 2020-12-26 20:36:24 -08:00
parent 2c12fdd04a
commit d9014b2342
4 changed files with 32 additions and 8 deletions

View File

@ -5,13 +5,14 @@ import { promisify } from "util";
import _ from "lodash";
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 stripAnsi from "strip-ansi";
import { v4 as getUUID } from "uuid";
import api from "./api";
import { LangConfig, langs } from "./langs";
import { langs } from "./langs";
function parseIntOr(thing, def) {
const num = parseInt(thing);

View File

@ -1,4 +1,5 @@
import crypto from "crypto";
import { promises as fs } from "fs";
import process from "process";
import { getLangs } from "./config.js";
@ -8,13 +9,24 @@ import { runCommand } from "./util.js";
async function main() {
const args = process.argv.slice(2);
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);
}
const mode = args[0];
let getHash;
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) => {
return (
await runCommand(
@ -24,7 +36,7 @@ async function main() {
).stdout.trim();
};
break;
case "remote":
case "s3":
const remoteHashes = Object.fromEntries(
(
await runCommand("tools/list-s3-hashes.bash", { getStdout: true })

View File

@ -66,8 +66,19 @@ for lang in "${langs[@]}"; do
done
done
composite_local_hash="$(node tools/hash-composite-image.js local)"
composite_remote_hash="$(node tools/hash-composite-image.js remote)"
for lang in "${langs[@]}"; do
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
make image push I=composite

View File

@ -39,7 +39,7 @@ export async function runCommand(cmd, options) {
proc.on("close", (code) => resolve({ code, ...rv }));
});
if (rv.code !== 0) {
throw new Error(`command exited with code ${code}`);
throw new Error(`command exited with code ${rv.code}`);
}
return rv;
}