Update project files

This commit is contained in:
Gabriel Augendre 2023-03-12 01:29:21 +01:00
parent 561289614f
commit b6ba3d3506
4 changed files with 13 additions and 12 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
layout python3

1
.gitignore vendored
View file

@ -221,3 +221,4 @@ Temporary Items
/target /target
**/*.rs.bk **/*.rs.bk
.direnv

2
.tool-versions Normal file
View file

@ -0,0 +1,2 @@
golang 1.16.15
python 3.11.2

View file

@ -28,21 +28,20 @@ GITEA_TOKEN = os.getenv("GITEA_TOKEN")
@task @task
def test(context): def test(context: Context):
"""Run tests""" """Run tests"""
context: Context
with context.cd(BASE_DIR): with context.cd(BASE_DIR):
context.run(f"go test ./... -race .", echo=True) context.run(f"go test ./... -race .", echo=True)
@task @task
def clean(context): def clean(context: Context):
"""Clean dist files""" """Clean dist files"""
context.run(f"rm -rf {DIST_DIR}", echo=True) context.run(f"rm -rf {DIST_DIR}", echo=True)
@task(pre=[clean, test], post=[clean]) @task(pre=[clean, test], post=[clean])
def release(context, version_name): def release(context: Context, version_name):
"""Create & push git tag + build binaries""" """Create & push git tag + build binaries"""
tag(context, version_name) tag(context, version_name)
binaries = build(context, version_name) binaries = build(context, version_name)
@ -51,16 +50,15 @@ def release(context, version_name):
@task(pre=[test]) @task(pre=[test])
def tag(context, version_name): def tag(context: Context, version_name):
"""Create & push a git tag""" """Create & push a git tag"""
context: Context
version_name = fix_version_name(version_name) version_name = fix_version_name(version_name)
context.run(f"git tag -a {version_name} -m '{version_name}'", echo=True) context.run(f"git tag -a {version_name} -m '{version_name}'", echo=True)
context.run("git push --follow-tags", echo=True) context.run("git push --follow-tags", echo=True)
@task @task
def build(context, version_name): def build(context: Context, version_name):
"""Cross-platform build""" """Cross-platform build"""
version_name = fix_version_name(version_name) version_name = fix_version_name(version_name)
binaries = [] binaries = []
@ -82,8 +80,8 @@ def build(context, version_name):
@task @task
def compress(context, binaries): def compress(context: Context, binaries):
"""Cross-platform build""" """Compress binaries to .tar.gz"""
archives = [] archives = []
with ThreadPoolExecutor() as pool: with ThreadPoolExecutor() as pool:
for binary in binaries: for binary in binaries:
@ -102,8 +100,7 @@ def _compress_single_binary(context, archive_path, binary_name):
@task @task
def upload(ctx, version_name, upload_files): def upload(ctx: Context, version_name, upload_files):
context: Context
version_name = fix_version_name(version_name) version_name = fix_version_name(version_name)
session = requests.Session() session = requests.Session()
if not GITEA_TOKEN: if not GITEA_TOKEN:
@ -138,7 +135,7 @@ def post_attachment(api_url, upload_file, session):
@task @task
def pre_process(context): def pre_process(context: Context):
"""Pre-process raw data into JSON""" """Pre-process raw data into JSON"""
files_to_rename = { files_to_rename = {
r"commune.*\.csv": "commune.csv", r"commune.*\.csv": "commune.csv",