Skip to content

Commit

Permalink
allow viewing of CE compiler buildstatus per library commit
Browse files Browse the repository at this point in the history
  • Loading branch information
partouf committed Nov 22, 2024
1 parent 35575e2 commit 3e312df
Show file tree
Hide file tree
Showing 8 changed files with 7,048 additions and 3,067 deletions.
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
};
7 changes: 7 additions & 0 deletions html/conan.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ body {
}
}

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

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

a.libraryversion {
padding-right: 10px;
Expand Down
29 changes: 27 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

const
_ = require('underscore'),
fs = require('fs').promises,
{ BuildAnnotations } = require('./build-annotations'),
{ BuildAnnotations, RemoteAnnotations } = require('./build-annotations'),
{ BuildLogging } = require('./build-logging'),
{ CppBuildResultsView } = require('./cpp-build-results'),
path = require('path'),
express = require('express'),
{ expressjwt } = require('express-jwt'),
jwt = require('jsonwebtoken'),
Expand All @@ -23,6 +24,7 @@ const conanserverroot = userhome + "/.conan_server";
const buildlogspath = conanserverroot + '/buildslogs.db';

let compilernames = null;
let compilersemvers = null;
let allRustLibrariesAndVersions = null;
let allCppLibrariesAndVersions = null;
let allFortranLibrariesAndVersions = null;
Expand Down Expand Up @@ -140,10 +142,13 @@ async function refreshCECompilers() {
resp.on('end', () => {
const jsdata = JSON.parse(data);
const compilers = {};
const compilers_semvers = {};
_.each(jsdata, (obj) => {
compilers[obj.id] = obj.name;
compilers_semvers[obj.id] = obj.semver;
});
compilernames = compilers;
compilersemvers = compilers_semvers;
resolve(true);
});
}).on('error', (err) => {
Expand Down Expand Up @@ -357,6 +362,9 @@ function main() {
/^\/binaries\/.*/,
/^\/downloadcshared\/.*/,
/^\/downloadpkg\/.*/,
/^\/cpp_library_build_results\/.*/,
'/fontawesome-free.min.css',
/^\/webfonts\/.*/,
{
url: /^\/annotations\/.*/,
methods: ['GET', 'OPTIONS']
Expand Down Expand Up @@ -584,6 +592,13 @@ function main() {
.options('/getlogging', expireshourly, async (req, res) => {
res.send();
})
.get('/webfonts/:font', async (req, res) => {
res.send(await fs.readFile(path.join('node_modules/@fortawesome/fontawesome-free/webfonts', req.params.font)));
})
.get('/fontawesome-free.min.css', async (req, res) => {
res.setHeader('Content-Type', 'text/css; charset=utf-8');
res.send(await fs.readFile('node_modules/@fortawesome/fontawesome-free/css/all.min.css'));
})
.get('/getlogging/:library/:library_version/:arch/:dt', expireshourly, async (req, res) => {
const logging = await buildlogging.getLogging(req.params.library, req.params.library_version, req.params.arch.trim(), req.params.dt);

Expand All @@ -607,6 +622,16 @@ function main() {
res.sendStatus(404);
}
})
.use('/cpp_library_build_results/:library/:library_version/:commit_hash', async (req, res) => {
const view = new CppBuildResultsView(
buildlogging,
new RemoteAnnotations(conanserverurl),
getConanBinaries,
compilernames,
compilersemvers
);
res.send(await view.get(req.params.library, req.params.library_version, req.params.commit_hash, req.query.allcompilers === '1'));
})
.use('/v1', (req, res, next) => {
req.url = `/v1${req.url}`;
proxy.web(req, res, { target: conanserverurl, changeOrigin: true }, e => {
Expand Down
11 changes: 11 additions & 0 deletions migrations/003-oldlogging.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--------------------------------------------------------------------------------
-- Up
--------------------------------------------------------------------------------

UPDATE latest SET logging='Log eliminated due to age' WHERE build_dt < 20240101000000;

--------------------------------------------------------------------------------
-- Down
--------------------------------------------------------------------------------


Loading

0 comments on commit 3e312df

Please sign in to comment.