Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build history proof of concept #46

Merged
merged 5 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion build-annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ const
fsconstants = require('fs').constants,
ini = require('ini');

class RemoteAnnotations {
constructor(conanserverurl) {
this.conanserverurl = conanserverurl;
}

async readAnnotations(library, version, buildhash) {
try {
// eslint-disable-next-line no-undef
const response = await fetch(this.conanserverurl + `/annotations/${library}/${version}/${buildhash}`);

if (response.status !== 200) {
return {};
}

return await response.json();
} catch(err) {
return {
error: "error"
};
}
}
}

class BuildAnnotations {
constructor(conanserverroot) {
this.conanserverroot = conanserverroot;
Expand Down Expand Up @@ -98,5 +121,6 @@ class BuildAnnotations {
}

module.exports = {
BuildAnnotations
BuildAnnotations,
RemoteAnnotations
};
27 changes: 27 additions & 0 deletions build-logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,33 @@ class BuildLogging {
return results;
}

async listPossibleCompilers() {
const results = await this.connection.all(
`select distinct compiler, compiler_version, arch, libcxx, compiler_flags
from latest
order by compiler asc, compiler_version asc, arch asc, libcxx asc, compiler_flags asc`);

return results;
}

async getBuildResultsForCommit(library, library_version, commithash) {
const stmt = await this.connection.prepare(
`select library, library_version, compiler, compiler_version, arch, libcxx, compiler_flags, success, build_dt
from latest
where library=@library and library_version=@library_version and commithash=@commithash`
);

await stmt.bind({
'@library': library,
'@library_version': library_version,
'@commithash': commithash
});

const results = await stmt.all();

return results;
}

async getLogging(library, library_version, arch, build_dt) {
const stmt = await this.connection.prepare(
`select library, library_version, compiler, compiler_version, arch, libcxx, compiler_flags, success, build_dt, logging
Expand Down
193 changes: 193 additions & 0 deletions cpp-build-results.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
const
pug = require('pug'),
{ BuildLogging } = require('./build-logging'),
{ BuildAnnotations } = require('./build-annotations'),
_ = require('underscore');

const {DynamoDBClient, ScanCommand} = require ('@aws-sdk/client-dynamodb');

class CppBuildResultsView {
/**
*
* @param {BuildLogging} logging
* @param {BuildAnnotations} annotations
*/
constructor(logging, annotations, conanfunc, compilernames, compilersemvers) {
this.results_view = pug.compileFile('views/library_build_results.pug');

this.logging = logging;
this.annotations = annotations;
this.conanfunc = conanfunc;
this.compilernames = compilernames;
this.compilersemvers = compilersemvers;

this.ddbClient = new DynamoDBClient({region: 'us-east-1'});
}

extract_compiler_details(compiler_str) {
const compiler_arr = compiler_str.split('#');
const id = compiler_arr[1];
return {
compiler: compiler_arr[0],
compiler_version: id,
arch: compiler_arr[2],
libcxx: compiler_arr[3],
compiler_name: this.compilernames[id],
compiler_semver: this.compilersemvers[id],
};
}

async get(library, library_version, commit_hash, show_all_compilers) {
const lib_key = `${library}#${library_version}#${commit_hash}`;

const scanCommand = new ScanCommand({
TableName: 'library-build-history',
ProjectionExpression: 'compiler,success',
FilterExpression: '#library=:lib_key',
ExpressionAttributeNames: {
'#library': 'library',
},
ExpressionAttributeValues: {
':lib_key': {
S: lib_key,
},
},
});

const scan_result = await this.ddbClient.send(scanCommand);

const compilers_with_results = _.map(scan_result.Items, (item) => {
return {
...this.extract_compiler_details(item.compiler.S),
success: item.success.BOOL ? 'ok' : 'failed',
}
});

compilers_with_results.sort((a, b) => a.compiler_version > b.compiler_version);

return await this.results_view({
lib: {
commit_url: `https://github.com/fmtlib/fmt/commit/${commit_hash}`,
commit_hash: commit_hash,
name: `${library} ${library_version}`,
},
view: {
show_all_compilers
},
compilers: compilers_with_results,
});
}

// async get(library, library_version, commit_hash, show_all_compilers) {
// const compilers = await this.logging.listPossibleCompilers();
// const results = await this.logging.getBuildResultsForCommit(library, library_version, commit_hash);

// const binaries = await this.conanfunc(library, library_version);

// const compilers_with_results_prom = compilers.map(async (compiler) => {
// const found = results.find((result) =>
// result.compiler === compiler.compiler && result.compiler_version === compiler.compiler_version && result.arch === compiler.arch && result.libcxx === compiler.libcxx);

// const comp = this.compilernames[compiler.compiler_version];
// let compiler_name = comp;
// if (!compiler_name) {
// compiler_name = compiler.compiler_version;
// }
// compiler_name = compiler_name.replaceAll('-', '_');

// if (found) {
// const statustext = found.success ? 'ok' : 'failed';
// const statuscolor = found.success ? 'green' : 'red';

// return {
// ...compiler,
// compiler_name,
// success: statustext,
// static_badge_link: `https://img.shields.io/badge/${compiler_name}-${statustext}-${statuscolor}`,
// buildhash: ''
// };
// } else {
// const bins = binaries.perCompiler[compiler.compiler_version];
// if (bins) {
// const foundIdx = binaries.possibleCombinations.findIndex((result) =>
// result.arch === compiler.arch && result['compiler.libcxx'] === compiler.libcxx
// );

// if (foundIdx >= 0) {
// const comboIdx = bins.combinations.findIndex(comboid => comboid === foundIdx);
// if (comboIdx >= 0) {
// const buildhash = bins.hashes[comboIdx];

// const anno = await this.annotations.readAnnotations(library, library_version, buildhash);
// if (commit_hash === anno.commithash) {
// const statustext = 'ok';
// const statuscolor = 'green';
// return {
// ...compiler,
// compiler_name,
// success: statustext,
// static_badge_link: `https://img.shields.io/badge/${compiler_name}-${statustext}-${statuscolor}`,
// buildhash: buildhash
// };
// }
// }
// }

// const statustext = 'unknown';
// const statuscolor = 'orange';
// return {
// ...compiler,
// compiler_name,
// success: statustext,
// static_badge_link: '',
// buildhash: ''
// };
// }
// return {...compiler, success: '?', buildhash: ''};
// }
// });

// let compilers_with_results = await Promise.all(compilers_with_results_prom);
// if (!show_all_compilers) {
// compilers_with_results = _.filter(compilers_with_results, (result) => result.static_badge_link);
// }

// for (const result of compilers_with_results) {
// const lib_key = `${library}#${library_version}#${commit_hash}`;
// const compiler_key = `${result.compiler}#${result.compiler_version}#${result.arch}#${result.libcxx}`;

// const putCommand = new PutItemCommand({
// TableName: 'library-build-history',
// Item: {
// library: {
// S: lib_key,
// },
// compiler: {
// S: compiler_key,
// },
// success: {
// BOOL: result.success === 'ok',
// }
// },
// });
// await this.ddbClient.send(putCommand);
// }

// return await this.results_view({
// lib: {
// commit_url: `https://github.com/fmtlib/fmt/commit/${commit_hash}`,
// commit_hash: commit_hash,
// name: library,
// },
// view: {
// show_all_compilers
// },
// compilers: compilers_with_results,
// results: results,
// });
// }
};

module.exports = {
CppBuildResultsView
};
19 changes: 19 additions & 0 deletions html/conan.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
--black: rgba(0,0,0, 0.8);;
}

body {
color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
body {
background-color: black;
color: white;
}
}

td.success:has(.fa-check) {
color: lime;
}

td.success:has(.fa-x) {
color: red;
}

a.libraryversion {
padding-right: 10px;
}
Expand Down
12 changes: 12 additions & 0 deletions html/libraries.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
matrixNode.find("td").html("");

const matrixTable = $("<table class='table table-striped'><thead><tr class='binmatrixheader' /></thead><tbody /></table>");
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
matrixTable.addClass('table-dark');
}
const header = matrixTable.find('.binmatrixheader');

const tdCompiler = $("<th class='binmatrixheadercompiler' scope='col'>Compiler</th>");
Expand Down Expand Up @@ -177,6 +180,15 @@

$(document).ready(() => {
refreshLibraries();

if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.querySelectorAll('.table-striped').forEach(table => {
table.classList.add('table-dark');
});
document.querySelectorAll('#libraries').forEach(table => {
table.classList.add('table-dark');
});
}
});
</script>
<title>CE - All available library binaries</title>
Expand Down
12 changes: 12 additions & 0 deletions html/libraries_cpp.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
matrixNode.find("td").html("");

const matrixTable = $("<table class='table table-striped'><thead><tr class='binmatrixheader' /></thead><tbody /></table>");
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
matrixTable.addClass('table-dark');
}
const header = matrixTable.find('.binmatrixheader');

const tdCompiler = $("<th class='binmatrixheadercompiler' scope='col'>Compiler</th>");
Expand Down Expand Up @@ -194,6 +197,15 @@

$(document).ready(() => {
refreshLibraries();

if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.querySelectorAll('.table-striped').forEach(table => {
table.classList.add('table-dark');
});
document.querySelectorAll('#libraries').forEach(table => {
table.classList.add('table-dark');
});
}
});
</script>
<title>CE - All C++ library binaries</title>
Expand Down
12 changes: 12 additions & 0 deletions html/libraries_fortran.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
matrixNode.find("td").html("");

const matrixTable = $("<table class='table table-striped'><thead><tr class='binmatrixheader' /></thead><tbody /></table>");
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
matrixTable.addClass('table-dark');
}
const header = matrixTable.find('.binmatrixheader');

const tdCompiler = $("<th class='binmatrixheadercompiler' scope='col'>Compiler</th>");
Expand Down Expand Up @@ -173,6 +176,15 @@

$(document).ready(() => {
refreshLibraries();

if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.querySelectorAll('.table-striped').forEach(table => {
table.classList.add('table-dark');
});
document.querySelectorAll('#libraries').forEach(table => {
table.classList.add('table-dark');
});
}
});
</script>
<title>CE - All Fortran library binaries</title>
Expand Down
12 changes: 12 additions & 0 deletions html/libraries_rust.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
matrixNode.find("td").html("");

const matrixTable = $("<table class='table table-striped'><thead><tr class='binmatrixheader' /></thead><tbody /></table>");
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
matrixTable.addClass('table-dark');
}
const header = matrixTable.find('.binmatrixheader');

const tdCompiler = $("<th class='binmatrixheadercompiler' scope='col'>Compiler</th>");
Expand Down Expand Up @@ -173,6 +176,15 @@

$(document).ready(() => {
refreshLibraries();

if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.querySelectorAll('.table-striped').forEach(table => {
table.classList.add('table-dark');
});
document.querySelectorAll('#libraries').forEach(table => {
table.classList.add('table-dark');
});
}
});
</script>
<title>CE - All Rust library binaries</title>
Expand Down
Loading
Loading