2022-01-04 12:21:08 +03:00
|
|
|
// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.
|
2021-02-07 00:28:42 +03:00
|
|
|
// Use of this source code is governed by an MIT license
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
|
2022-11-02 14:22:34 +03:00
|
|
|
const fast_dir = os.dir(@FILE)
|
|
|
|
|
|
|
|
const vdir = os.dir(os.dir(os.dir(fast_dir)))
|
|
|
|
|
|
|
|
const vexe = os.join_path(vdir, 'v')
|
2022-11-01 16:49:23 +03:00
|
|
|
|
|
|
|
const sleep_period = 120
|
|
|
|
|
2022-11-01 13:54:12 +03:00
|
|
|
fn elog(msg string) {
|
|
|
|
eprintln('$time.now().format_ss_micro() $msg')
|
|
|
|
}
|
|
|
|
|
2022-11-01 16:49:23 +03:00
|
|
|
fn delay() {
|
|
|
|
elog('Sleeping for $sleep_period seconds...')
|
|
|
|
time.sleep(sleep_period * time.second)
|
|
|
|
}
|
|
|
|
|
2021-02-07 00:28:42 +03:00
|
|
|
// 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() {
|
2022-11-01 16:49:23 +03:00
|
|
|
os.setenv('LANG', 'C', true)
|
2022-11-02 14:22:34 +03:00
|
|
|
elog('fast_job fast_dir: $fast_dir | vdir: $vdir | vexe: $vexe')
|
|
|
|
|
|
|
|
os.chdir(fast_dir)!
|
|
|
|
|
2022-11-01 16:49:23 +03:00
|
|
|
elog('fast_job start in os.getwd(): $os.getwd()')
|
2022-11-01 13:54:12 +03:00
|
|
|
defer {
|
|
|
|
elog('fast_job end')
|
|
|
|
}
|
2022-11-01 16:49:23 +03:00
|
|
|
|
2021-02-07 00:28:42 +03:00
|
|
|
if !os.exists('website') {
|
|
|
|
println('cloning the website repo...')
|
|
|
|
os.system('git clone git@github.com:/vlang/website.git')
|
|
|
|
}
|
|
|
|
for {
|
2022-11-01 16:49:23 +03:00
|
|
|
elog('------------------- Checking for updates ... -------------------')
|
2021-03-08 21:52:13 +03:00
|
|
|
res_pull := os.execute('git pull --rebase')
|
2022-11-02 14:22:34 +03:00
|
|
|
elog('> res_pull.output: $res_pull.output')
|
2021-03-08 21:52:13 +03:00
|
|
|
if res_pull.exit_code != 0 {
|
2022-11-01 17:12:36 +03:00
|
|
|
elog('Git pull failed. You may have uncommitted changes?')
|
2022-11-01 16:49:23 +03:00
|
|
|
delay()
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if res_pull.output.contains('Already up to date.') {
|
2022-11-02 11:39:18 +03:00
|
|
|
if os.args.contains('-force-update') {
|
2022-11-01 16:49:23 +03:00
|
|
|
elog('The repository was already updated, but -force-update was passed too.')
|
|
|
|
} else {
|
|
|
|
delay()
|
|
|
|
continue
|
|
|
|
}
|
2021-02-07 00:28:42 +03:00
|
|
|
}
|
2022-11-01 16:49:23 +03:00
|
|
|
|
|
|
|
elog('recompiling V')
|
|
|
|
os.system('${os.quoted_path(vexe)} self')
|
2022-11-01 17:12:36 +03:00
|
|
|
os.system('ls -la ${os.quoted_path(vexe)}')
|
2022-11-01 16:49:23 +03:00
|
|
|
|
|
|
|
elog('recompiling ./fast')
|
2022-11-02 14:22:34 +03:00
|
|
|
recompile_fast_v_code := os.system('${os.quoted_path(vexe)} fast.v')
|
|
|
|
if recompile_fast_v_code != 0 {
|
|
|
|
elog('WARNING: could not recompile fast.v')
|
|
|
|
delay()
|
|
|
|
continue
|
|
|
|
}
|
2022-11-01 16:49:23 +03:00
|
|
|
os.system('ls -la fast fast.v')
|
|
|
|
|
2022-11-01 13:54:12 +03:00
|
|
|
elog('running ./fast -upload')
|
2022-11-02 14:22:34 +03:00
|
|
|
fast_exit_code := os.system('./fast -upload')
|
|
|
|
if fast_exit_code != 0 {
|
|
|
|
println('fast_exit_code = $fast_exit_code, != 0')
|
2021-02-07 00:28:42 +03:00
|
|
|
}
|
2022-11-01 16:49:23 +03:00
|
|
|
|
|
|
|
delay()
|
2021-02-07 00:28:42 +03:00
|
|
|
}
|
|
|
|
}
|