tools: update fast.v and fast_job.v to update docs.vlang.io and fast.vlang.io on each commit to master.

This commit is contained in:
Delyan Angelov 2024-04-26 15:02:40 +03:00
parent 206c0e33be
commit cdec163154
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
3 changed files with 35 additions and 10 deletions

View file

@ -4,3 +4,8 @@ table.html
v.c v.c
v2 v2
fast.log fast.log
website/
fast.vlang.io/
docs.vlang.io/

View file

@ -4,6 +4,7 @@
import os import os
import time import time
import arrays import arrays
import log
const warmup_samples = 2 const warmup_samples = 2
@ -25,7 +26,7 @@ fn elog(msg string) {
f.write_string(line) or {} f.write_string(line) or {}
f.close() f.close()
} }
eprint(line) log.info(msg)
} }
fn lsystem(cmd string) int { fn lsystem(cmd string) int {
@ -74,8 +75,8 @@ fn main() {
// fetch the last commit's hash // fetch the last commit's hash
commit := lexec('git rev-parse HEAD')[..8] commit := lexec('git rev-parse HEAD')[..8]
if os.exists('website/index.html') { if os.exists('fast.vlang.io/index.html') {
uploaded_index := os.read_file('website/index.html')! uploaded_index := os.read_file('fast.vlang.io/index.html')!
if uploaded_index.contains('>${commit}<') { if uploaded_index.contains('>${commit}<') {
elog('NOTE: commit ${commit} had been benchmarked already.') elog('NOTE: commit ${commit} had been benchmarked already.')
if !os.args.contains('-force') { if !os.args.contains('-force') {
@ -159,13 +160,28 @@ fn main() {
// upload the result to github pages // upload the result to github pages
if os.args.contains('-upload') { if os.args.contains('-upload') {
elog('uploading...') os.chdir('${fast_dir}/fast.vlang.io/')!
os.chdir('website')! elog('Uploading to fast.vlang.io/ ...')
lexec('git checkout gh-pages') lexec('git checkout gh-pages')
os.mv('../index.html', 'index.html')! os.mv('../index.html', 'index.html')!
lsystem('git commit -am "update benchmark for commit ${commit}"') elog(' adding changes...')
lsystem('git commit -am "update fast.vlang.io for commit ${commit}"')
elog(' pushing...')
lsystem('git push origin gh-pages') lsystem('git push origin gh-pages')
elog('uploading done') elog('uploading to fast.vlang.io/ done')
os.chdir(fast_dir)!
os.chdir('${fast_dir}/docs.vlang.io/')!
elog('Uploading to docs.vlang.io/ ...')
elog(' running build.vsh...')
lexec('${vdir}/vprod run build.vsh')
elog(' adding changes...')
lsystem('git add .')
lsystem('git commit -am "update docs for commit ${commit}"')
elog(' pushing...')
lsystem('git push')
elog('uploading to fast.vlang.io/ done')
os.chdir(fast_dir)!
} }
} }

View file

@ -34,9 +34,13 @@ fn main() {
elog('fast_job end') elog('fast_job end')
} }
if !os.exists('website') { if !os.exists('fast.vlang.io/') {
println('cloning the website repo...') println('cloning the fast.vlang.io/ repo...')
os.system('git clone --filter=blob:none git@github.com:/vlang/website.git') os.system('git clone git@github.com:/vlang/website.git fast.vlang.io/')
}
if !os.exists('docs.vlang.io') {
println('cloning the docs.vlang.io/ repo...')
os.system('git clone git@github.com:/vlang/docs.git docs.vlang.io/')
} }
for { for {
elog('------------------- Checking for updates ... -------------------') elog('------------------- Checking for updates ... -------------------')