Compare commits

...

6 commits

5 changed files with 16 additions and 19 deletions

1
.gitignore vendored
View file

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

2
.mise.toml Normal file
View file

@ -0,0 +1,2 @@
[tools]
python = {version="3.11", virtualenv=".venv"}

View file

@ -19,15 +19,9 @@ repos:
args:
- --markdown-linebreak-ext=md
- repo: https://github.com/golangci/golangci-lint
rev: v1.42.0
rev: v1.54.2
hooks:
- id: golangci-lint
- repo: https://github.com/TekWizely/pre-commit-golang
rev: v1.0.0-beta.4
hooks:
- id: go-fumpt
args:
- -w
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:

View file

@ -67,6 +67,7 @@ type InseeData struct {
// NewInseeData generates an InseeData struct, extracting the data into the relevant fields.
// The data is converted to a human-readable format before being stored.
// If a value can't be determined, the corresponding field is generally set to Unknown.
// It returns an error when the given number isn't 15 characters long.
func NewInseeData(inseeNumber string) (*InseeData, error) {
if len(inseeNumber) != 15 {
return nil, fmt.Errorf("le numéro INSEE doit contenir 15 caractères")
@ -147,6 +148,7 @@ func NewInseeData(inseeNumber string) (*InseeData, error) {
// IsValid returns true when the insee number is valid and false when not.
// The insee number is valid when it matches its ControlKey.
// It returns an error when the insee number can't be converted to an integer.
func (insee InseeData) IsValid() (bool, error) {
r := strings.NewReplacer(
"2A", "19",

View file

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