Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
ci: Fix bazel cache error because man page entries of sshpk use path …
Browse files Browse the repository at this point in the history
…of workspace

 - Allow enabling and disabling of execution_log_binary_file
  • Loading branch information
andreas-doppelhofer authored and lukasholzer committed Oct 21, 2020
1 parent 55f2b20 commit 1123ddf
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .buildkite/baristaPipeline.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
tasks:
default:
build:
execution_log_binary_file: false
trigger:
- test
pre_cmd:
Expand All @@ -13,6 +14,7 @@ tasks:
post_cmd:
- echo "Post command"
test:
execution_log_binary_file: false
bazel_flags:
- "--keep_going"
bazel_cmd:
Expand All @@ -29,8 +31,6 @@ tasks:
- bash -c ".buildkite/build_cache/setup_ci_build_cache.sh"
bazel_cmd:
- "//..."
post_cmd:
- dir
test:
disable: true
bazel_flags:
Expand Down
19 changes: 17 additions & 2 deletions .buildkite/baristacli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import subprocess
from shutil import copyfile
import sys
import time
from urllib.request import url2pathname
from urllib.parse import urlparse
import yaml
Expand Down Expand Up @@ -125,8 +126,16 @@ def arg_hander_command(args):

# bazel build info file
build_event_file = "build_event_file.json"

execution_log = None # default -> disabled
if 'execution_log_binary_file' in stage[args.target] and stage[args.target]['execution_log_binary_file']:
execution_log = "execution-{}-{}.log".format(args.target, int(time.time()))

profile = "profile-{}{}.gz".format(args.target, args.shard if int(args.shard) != 0 else "")

# buildkite files for uplaod
files_for_upload = [profile]

if args.target == "test" and 'parallel' in stage[args.target] and int(
args.shard) != 0:
bazel_flags = stage[args.target]["bazel_flags"] if "bazel_flags" in stage[
Expand All @@ -135,6 +144,9 @@ def arg_hander_command(args):
bazel_flags += ["--build_event_json_file={}".format(build_event_file),
"--profile={}".format(profile),
"--record_full_profiler_data"]
if execution_log:
bazel_flags += ["--execution_log_binary_file={}".format(execution_log)]
files_for_upload.append(execution_log)
execute_command(
[BAZELBIN] + [args.target.split("_")[0]] + test_sharding(
int(args.shard)), fail_if_nonzero=not in_ci())
Expand All @@ -146,6 +158,9 @@ def arg_hander_command(args):
bazel_flags += ["--build_event_json_file={}".format(build_event_file),
"--profile={}".format(profile),
"--record_full_profiler_data"]
if execution_log:
bazel_flags += ["--execution_log_binary_file={}".format(execution_log)]
files_for_upload.append(execution_log)
execute_command(
[BAZELBIN] + [args.target] + stage[args.target][
'bazel_cmd'] + bazel_flags,
Expand All @@ -154,7 +169,7 @@ def arg_hander_command(args):
execute_shell_commands(stage[args.target]['cmd'])

# upload profile
upload_files([profile])
upload_files(files_for_upload)

# analyse Test logs and fail afterwards
if upload_test_logs_from_bep(build_event_file) > 0:
Expand All @@ -174,7 +189,7 @@ def upload_files(files):
""" upload to buildkite"""
if not in_ci():
return 0
execute_command(
return execute_command(
["buildkite-agent", "artifact", "upload", ";".join(files)])

def upload_test_logs_from_bep(bep_file):
Expand Down
22 changes: 22 additions & 0 deletions postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ async function main() {
);
// link the ivy entry points
updateNgccMainFields();
// remove man page path to get rid of bazel cache error while running tests
removeManPagePath();

if (!process.env.BAZEL_NPM_INSTALL) {
await execCommand(`npm run ng build workspace`);
Expand Down Expand Up @@ -89,6 +91,26 @@ function updateNgccMainFields() {
});
}

/**
* Remove man package json entry to get rid of insufficient use of bazel cache because
* man page path are used in package.json (sshpk)
* e.g.
* "man": [
* "/var/lib/buildkite-agent/builds/designops-buildkite-i-0e57b7da3745f484a-1/dynatrace/bazel/node_modules/sshpk/man/man1/sshpk-conv.1",
* "/var/lib/buildkite-agent/builds/designops-buildkite-i-0e57b7da3745f484a-1/dynatrace/bazel/node_modules/sshpk/man/man1/sshpk-sign.1",
* "/var/lib/buildkite-agent/builds/designops-buildkite-i-0e57b7da3745f484a-1/dynatrace/bazel/node_modules/sshpk/man/man1/sshpk-verify.1"
* ],
*/
function removeManPagePath() {
sync('node_modules/sshpk/package.json').forEach((filePath) => {
const parsedJson = JSON.parse(readFileSync(filePath, 'utf8'));
if (parsedJson['man']) {
delete parsedJson['man'];
writeFileSync(filePath, JSON.stringify(parsedJson, null, 2));
}
});
}

main()
.then(() => {
console.log('✅ Successfully run postinstall script!');
Expand Down

0 comments on commit 1123ddf

Please sign in to comment.