Skip to content

Commit

Permalink
Merge branch 'main' into GH-588-handshake-3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner authored Jan 31, 2023
2 parents 55578c4 + a4c2960 commit 3ad8767
Show file tree
Hide file tree
Showing 1,373 changed files with 73,659 additions and 17,070 deletions.
6 changes: 4 additions & 2 deletions .cicd/platforms/ubuntu18.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ RUN apt-get update && apt-get upgrade -y && \
libcurl4-openssl-dev \
libgmp-dev \
libssl-dev \
libusb-1.0-0-dev \
llvm-7-dev \
ninja-build \
pkg-config \
python3 \
python3-numpy \
python3-pip \
software-properties-common \
zlib1g-dev \
zstd

RUN python3 -m pip install dataclasses

# GitHub's actions/checkout requires git 2.18+ but Ubuntu 18 only provides 2.17
RUN add-apt-repository ppa:git-core/ppa && apt update && apt install -y git

Expand Down
3 changes: 1 addition & 2 deletions .cicd/platforms/ubuntu20.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ RUN apt-get update && apt-get upgrade -y && \
libcurl4-openssl-dev \
libgmp-dev \
libssl-dev \
libusb-1.0-0-dev \
llvm-11-dev \
ninja-build \
pkg-config \
python3-numpy \
zstd
3 changes: 1 addition & 2 deletions .cicd/platforms/ubuntu22.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ RUN apt-get update && apt-get upgrade -y && \
libcurl4-openssl-dev \
libgmp-dev \
libssl-dev \
libusb-1.0-0-dev \
llvm-11-dev \
ninja-build \
pkg-config \
python3-numpy \
zstd
14 changes: 14 additions & 0 deletions .github/actions/parallel-ctest-containers/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'Parallel ctest'
description: 'Runs a set of labeled ctests in parallel via multiple docker containers'
inputs:
container:
required: true
error-log-paths:
required: true
log-tarball-prefix:
required: true
tests-label:
required: true
runs:
using: 'node16'
main: 'dist/index.mjs'
3 changes: 3 additions & 0 deletions .github/actions/parallel-ctest-containers/dist/index.mjs

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions .github/actions/parallel-ctest-containers/main.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import child_process from 'node:child_process';
import process from 'node:process';
import stream from 'node:stream';
import fs from 'node:fs';
import zlib from 'node:zlib';
import tar from 'tar-stream';
import core from '@actions/core'

const container = core.getInput('container', {required: true});
const error_log_paths = JSON.parse(core.getInput('error-log-paths', {required: true}));
const log_tarball_prefix = core.getInput('log-tarball-prefix', {required: true});
const tests_label = core.getInput('tests-label', {required: true});

try {
if(child_process.spawnSync("docker", ["run", "--name", "base", "-v", `${process.cwd()}/build.tar.zst:/build.tar.zst`, "--workdir", "/__w/leap/leap", container, "sh", "-c", "zstdcat /build.tar.zst | tar x"], {stdio:"inherit"}).status)
throw new Error("Failed to create base container");
if(child_process.spawnSync("docker", ["commit", "base", "baseimage"], {stdio:"inherit"}).status)
throw new Error("Failed to create base image");
if(child_process.spawnSync("docker", ["rm", "base"], {stdio:"inherit"}).status)
throw new Error("Failed to remove base container");

// the correct approach is by far "--show-only=json-v1" and then pluck out .tests[].name; but that doesn't work on U18's cmake 3.10 since it lacks json-v1 output
const test_query_result = child_process.spawnSync("docker", ["run", "--rm", "baseimage", "bash", "-e", "-o", "pipefail", "-c", `cd build; ctest -L '${tests_label}' --show-only | head -n -1 | cut -d ':' -f 2 -s | jq -cnR '[inputs | select(length>0)[1:]]'`]);
if(test_query_result.status)
throw new Error("Failed to discover tests with label")
const tests = JSON.parse(test_query_result.stdout);

let subprocesses = [];
tests.forEach(t => {
subprocesses.push(new Promise(resolve => {
child_process.spawn("docker", ["run", "--name", t, "--init", "baseimage", "bash", "-c", `cd build; ctest --output-on-failure -R '^${t}$'`], {stdio:"inherit"}).on('close', code => resolve(code));
}));
});

const results = await Promise.all(subprocesses);

for(let i = 0; i < results.length; ++i) {
if(results[i] === 0)
continue;

//failing test
core.setFailed("Some tests failed");

let extractor = tar.extract();
let packer = tar.pack();

extractor.on('entry', (header, stream, next) => {
if(!header.name.startsWith(`__w/leap/leap/build`)) {
stream.on('end', () => next());
stream.resume();
return;
}

header.name = header.name.substring(`__w/leap/leap/`.length);
if(header.name !== "build/" && error_log_paths.filter(p => header.name.startsWith(p)).length === 0) {
stream.on('end', () => next());
stream.resume();
return;
}

stream.pipe(packer.entry(header, next));
}).on('finish', () => {packer.finalize()});

child_process.spawn("docker", ["export", tests[i]]).stdout.pipe(extractor);
stream.promises.pipeline(packer, zlib.createGzip(), fs.createWriteStream(`${log_tarball_prefix}-${tests[i]}-logs.tar.gz`));
}
} catch(e) {
core.setFailed(`Uncaught exception ${e.message}`);
}
Loading

0 comments on commit 3ad8767

Please sign in to comment.