annotate service/iot2/tasks.py @ 1489:a4fb4cc60ae1

get some iot2 tests going Ignore-this: cdfdf88f445f043aa5aa55f737f6b776 darcs-hash:f0dc8fe99648fd4f7a3870c2b564ae1e4c85fdd9
author drewp <drewp@bigasterisk.com>
date Tue, 21 Jan 2020 23:59:45 -0800
parents
children e3eceee54937
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1489
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
1 from invoke import task
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
2 from pathlib import Path
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
3
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
4 @task
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
5 def nim_install(ctx):
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
6 if Path('nim-1.0.4/bin/nim').exists():
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
7 return
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
8 ctx.run(f'curl https://nim-lang.org/download/nim-1.0.4-linux_x64.tar.xz | xz -dc | tar x')
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
9
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
10 @task
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
11 def py_install(ctx):
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
12 if Path('env/bin/python').exists():
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
13 return
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
14 ctx.run(f'mkdir -p env')
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
15 ctx.run(f'virtualenv -p /usr/bin/python3.7 env')
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
16
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
17 @task(pre=[py_install])
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
18 def py_deps(ctx):
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
19 pip_install_ran = Path('env/lib/python3.7/site-packages/wheel').stat().st_mtime
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
20 requirements = Path('requirements.txt').stat().st_mtime
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
21 if pip_install_ran > requirements:
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
22 return
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
23 ctx.run(f'env/bin/pip install --quiet --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple -r requirements.txt')
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
24
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
25 @task(pre=[nim_install])
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
26 def nim_deps(ctx):
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
27 pkgs = ['nimpy-0.1.0']
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
28 if all(Path(f'~/.nimble/pkgs/{pkg}').expanduser().exists() for pkg in pkgs):
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
29 return
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
30 plain_names = ' '.join(p.split('-')[0] for p in pkgs)
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
31 ctx.run(f'nim-1.0.4/bin/nimble install {plain_names}', pty=True)
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
32
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
33
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
34 @task(pre=[nim_install])
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
35 def nim_build_x86(ctx):
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
36 ctx.run(f'nim-1.0.4/bin/nim c --out:iot2_linux_x86 iot2_linux.nim', pty=True)
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
37
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
38 @task
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
39 def arm_cross_compiler_install(ctx):
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
40 ctx.run(f'sudo apt install -y crossbuild-essential-armhf', pty=True)
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
41
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
42 @task(pre=[nim_install])
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
43 def nim_build_arm(ctx):
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
44 ctx.run(f'nim-1.0.4/bin/nim c --cpu:arm --out:iot2_linux_arm iot2_linux.nim', pty=True)
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
45
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
46 @task(pre=[py_deps, nim_build_x86])
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
47 def local_run(ctx):
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
48 ctx.run(f'./iot2_linux_x86')
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
49
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
50
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
51 # pack this into docker for pushing to Pi
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
52
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
53 # apt install -y sshfs
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
54 # sshfs drewp@10.2.0.110:/my/proj/homeauto/service/iot2 /mnt
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
55 # cd /mnt
a4fb4cc60ae1 get some iot2 tests going
drewp <drewp@bigasterisk.com>
parents:
diff changeset
56 # ./iot2_linux_arm