tools: make fast_job.v more robust (setup a custom PATH) and informative on fast.v failures (compile it with -g)

This commit is contained in:
vlang-bot 2024-09-19 12:20:58 +03:00
parent 1f0a6337ce
commit 24088a7ca4

View file

@ -4,13 +4,23 @@
import os
import time
// This program acts as a service/monitor/daemon, that runs in the background, checks for repo updates,
// and runs fast.v, when there are changes. It should *never fail*, even if fast.v can fail. In that case,
// this program should just loop, trying again on the next iteration of the loop, and hoping that the repo
// was fixed enough, so that fast.v can succeed.
// It is the responsibility of * fast.v * , to do all measurements, process them, and to pushes the HTML result
// of that processing to the fast.vlang.io GH pages repo.
const sleep_period = 60
const fast_dir = os.dir(@FILE)
const vdir = os.dir(os.dir(os.dir(fast_dir)))
const vdir = os.real_path(os.dir(os.dir(os.dir(fast_dir))))
const vexe = os.join_path(vdir, 'v')
const vexe = os.real_path(os.join_path(vdir, 'v'))
const sleep_period = 120
const old_path = os.getenv('PATH')
fn elog(msg string) {
eprintln('${time.now().format_ss_micro()} ${msg}')
@ -21,15 +31,19 @@ fn delay() {
time.sleep(sleep_period * time.second)
}
// A job that runs in the background, checks for repo updates,
// runs fast.v, pushes the HTML result to the fast.vlang.io GH pages repo.
fn main() {
elog('fast_job start setup ...')
// ensure a more stable working environment for the used tools, independent on how this executable was started:
os.setenv('LANG', 'C', true)
elog('fast_job fast_dir: ${fast_dir} | vdir: ${vdir} | vexe: ${vexe}')
os.setenv('PATH', '${vdir}:${old_path}', true)
elog('fast_job fast_dir: ${fast_dir}')
elog('fast_job vdir: ${vdir}')
elog('fast_job vexe: ${vexe}')
elog('fast_job PATH: ${os.getenv('PATH')}')
os.chdir(fast_dir)!
elog('fast_job start in os.getwd(): ${os.getwd()}')
defer {
elog('fast_job end')
}
@ -42,8 +56,12 @@ fn main() {
println('cloning the docs.vlang.io/ repo...')
os.system('git clone git@github.com:/vlang/docs.git docs.vlang.io/')
}
mut i := 0
for {
elog('------------------- Checking for updates ... -------------------')
i++
elog('------------------- Checking for updates, loop: ${i} ... -------------------')
os.chdir(fast_dir)!
res_pull := os.execute('git pull --rebase')
elog('> res_pull.output: ${res_pull.output}')
if res_pull.exit_code != 0 {
@ -65,7 +83,7 @@ fn main() {
os.system('ls -la ${os.quoted_path(vexe)}')
elog('recompiling ./fast')
recompile_fast_v_code := os.system('${os.quoted_path(vexe)} fast.v')
recompile_fast_v_code := os.system('${os.quoted_path(vexe)} -keepc -g fast.v')
if recompile_fast_v_code != 0 {
elog('WARNING: could not recompile fast.v')
delay()