Skip to content

Commit

Permalink
show logging if available
Browse files Browse the repository at this point in the history
  • Loading branch information
partouf committed Nov 23, 2024
1 parent 1adfbbb commit d2e29f0
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 9 deletions.
22 changes: 22 additions & 0 deletions build-logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ class BuildLogging {
return results;
}

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

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

const results = await stmt.all();

return results;
}

async getCompilerFailureRates() {
const stmt = await this.connection.prepare(
`select compiler_version, count(*) failures
Expand Down
20 changes: 19 additions & 1 deletion cpp-build-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,28 @@ class CppBuildResultsView {
const lib_key = this.create_library_key(library, library_version, commit_hash);
const scan_result = await this.list_all_results(lib_key);

const latest_results = await this.logging.getBuildResultsForCommit(library, library_version, commit_hash);

const has_logging = (compiler_version, arch, libcxx) => {
return !!latest_results.find((res) => res.compiler_version === compiler_version && res.arch === arch && res.libcxx === libcxx);
};

const compilers_with_results = _.map(scan_result.Items, (item) => {
const compiler_details = this.extract_compiler_details(item.compiler.S);
let logging_url = '';
let package_url = '';
if (!item.success.BOOL && has_logging(compiler_details.compiler_version, compiler_details.arch, compiler_details.libcxx)) {
logging_url = `/getlogging_forcommit/${library}/${library_version}/${commit_hash}/${compiler_details.compiler_version}/${compiler_details.arch || ' '}/${compiler_details.libcxx || ' '}`;
} else if (item.success.BOOL) {
// TODO: requires new API call downloadpkg specifically for arch+libcxx
// TODO: how to make sure user knows this is the latest package and might not be for this commit?
package_url = '';
}

return {
...this.extract_compiler_details(item.compiler.S),
...compiler_details,
success: item.success.BOOL ? 'ok' : 'failed',
logging_url,
}
});

Expand Down
37 changes: 33 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ function main() {
'/hasfailedbefore',
'/whathasfailedbefore',
'/allfailedbuilds',
/^\/getlogging\/[0-9]*/,
/^\/getlogging\/.*/,
/^\/getlogging_forcommit\/.*/,
/^\/binaries\/.*/,
/^\/downloadcshared\/.*/,
/^\/downloadpkg\/.*/,
Expand Down Expand Up @@ -589,16 +590,16 @@ function main() {
const builds = await buildlogging.listBuilds();
res.send(builds);
})
.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'));
})
.options('/getlogging', expireshourly, async (req, res) => {
res.send();
})
.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 @@ -622,6 +623,34 @@ function main() {
res.sendStatus(404);
}
})
.options('/getlogging_forcommit', expireshourly, async (req, res) => {
res.send();
})
.get('/getlogging_forcommit/:library/:library_version/:commithash/:compiler_version/:arch/:libcxx', expireshourly, async (req, res) => {
const logging = await buildlogging.getLoggingForCommit(req.params.library, req.params.library_version, req.params.commithash,
req.params.compiler_version, req.params.arch.trim(), req.params.libcxx.trim());

if (logging) {
const entry = logging[0];

if (logging.length >= 1) {
const filename = `${entry.library}_${entry.library_version}_${entry.commithash}` +
`_${entry.compiler_version}_${entry.arch}_${entry.libcxx}_${entry.build_dt}.txt`;
let content = '';
for (const item of logging) {
content = content + item.logging;
if (logging.length > 1) {
content = content + '\n\n--- More entries ---\n\n';
}
}
res.header('Content-Disposition', 'attachment; filename="' + filename +'"').send(content);
} else {
res.sendStatus(404);
}
} else {
res.sendStatus(404);
}
})
.use('/cpp_library_build_results/:library/:library_version/:commit_hash', async (req, res) => {
const view = new CppBuildResultsView(
buildlogging,
Expand Down
18 changes: 14 additions & 4 deletions views/library_build_results.pug
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,20 @@ block prepend content
td #{compiler.arch}
td #{compiler.libcxx}
td(class="success")
if compiler.success == 'ok'
i(class='fa-solid fa-check')
if compiler.success == 'failed'
i(class='fa-solid fa-x')
span(style='display: inline-block; width: 25px')
if compiler.success == 'ok'
i(class='fa-solid fa-check')
if compiler.success == 'failed'
i(class='fa-solid fa-x')
if compiler.logging_url
span(style='display: inline-block; width: 25px')
a(href=compiler.logging_url target='_blank')
i(class='fa-solid fa-file-text')
if compiler.package_url
span(style='display: inline-block; width: 25px')
a(href=compiler.package_url target='_blank')
i(class='fa-solid fa-paperclip')

script
| if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
| document.querySelectorAll('.table-striped').forEach(table => {
Expand Down

0 comments on commit d2e29f0

Please sign in to comment.