Skip to content

Commit

Permalink
tools: update fast.v and fast_job.v to update docs.vlang.io and fast.…
Browse files Browse the repository at this point in the history
…vlang.io on each commit to master.
  • Loading branch information
spytheman committed Apr 26, 2024
1 parent 206c0e3 commit cdec163
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
5 changes: 5 additions & 0 deletions cmd/tools/fast/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ table.html
v.c
v2
fast.log

website/

fast.vlang.io/
docs.vlang.io/
30 changes: 23 additions & 7 deletions cmd/tools/fast/fast.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import time
import arrays
import log

const warmup_samples = 2

Expand All @@ -25,7 +26,7 @@ fn elog(msg string) {
f.write_string(line) or {}
f.close()
}
eprint(line)
log.info(msg)
}

fn lsystem(cmd string) int {
Expand Down Expand Up @@ -74,8 +75,8 @@ fn main() {

// fetch the last commit's hash
commit := lexec('git rev-parse HEAD')[..8]
if os.exists('website/index.html') {
uploaded_index := os.read_file('website/index.html')!
if os.exists('fast.vlang.io/index.html') {
uploaded_index := os.read_file('fast.vlang.io/index.html')!
if uploaded_index.contains('>${commit}<') {
elog('NOTE: commit ${commit} had been benchmarked already.')
if !os.args.contains('-force') {
Expand Down Expand Up @@ -159,13 +160,28 @@ fn main() {

// upload the result to github pages
if os.args.contains('-upload') {
elog('uploading...')
os.chdir('website')!
os.chdir('${fast_dir}/fast.vlang.io/')!
elog('Uploading to fast.vlang.io/ ...')
lexec('git checkout gh-pages')
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')
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)!
}
}

Expand Down
10 changes: 7 additions & 3 deletions cmd/tools/fast/fast_job.v
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ fn main() {
elog('fast_job end')
}

if !os.exists('website') {
println('cloning the website repo...')
os.system('git clone --filter=blob:none [email protected]:/vlang/website.git')
if !os.exists('fast.vlang.io/') {
println('cloning the fast.vlang.io/ repo...')
os.system('git clone [email protected]:/vlang/website.git fast.vlang.io/')
}
if !os.exists('docs.vlang.io') {
println('cloning the docs.vlang.io/ repo...')
os.system('git clone [email protected]:/vlang/docs.git docs.vlang.io/')
}
for {
elog('------------------- Checking for updates ... -------------------')
Expand Down

0 comments on commit cdec163

Please sign in to comment.