From d9014b2342c847b99f5f787e3b5a4571439db432 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sat, 26 Dec 2020 20:36:24 -0800 Subject: [PATCH] More fixes for CI --- backend/test-runner.js | 5 +++-- tools/hash-composite-image.js | 18 +++++++++++++++--- tools/publish.bash | 15 +++++++++++++-- tools/util.js | 2 +- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/backend/test-runner.js b/backend/test-runner.js index 4ed6dd8..5c96796 100644 --- a/backend/test-runner.js +++ b/backend/test-runner.js @@ -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); diff --git a/tools/hash-composite-image.js b/tools/hash-composite-image.js index c5fe2a3..2d55e07 100644 --- a/tools/hash-composite-image.js +++ b/tools/hash-composite-image.js @@ -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 }) diff --git a/tools/publish.bash b/tools/publish.bash index d2a54f4..3ea5506 100755 --- a/tools/publish.bash +++ b/tools/publish.bash @@ -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 diff --git a/tools/util.js b/tools/util.js index 047c7ad..900dc01 100644 --- a/tools/util.js +++ b/tools/util.js @@ -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; }