Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
Gabriel Augendre | 0b2a43128b | ||
Gabriel Augendre | 2f4b560b9b | ||
Gabriel Augendre | 989fe96f8b | ||
Gabriel Augendre | b6ba3d3506 | ||
Gabriel Augendre | 561289614f | ||
Gabriel Augendre | 614fd2fdd7 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -221,3 +221,4 @@ Temporary Items
|
||||||
|
|
||||||
/target
|
/target
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
.direnv
|
||||||
|
|
2
.mise.toml
Normal file
2
.mise.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[tools]
|
||||||
|
python = {version="3.11", virtualenv=".venv"}
|
|
@ -19,15 +19,9 @@ repos:
|
||||||
args:
|
args:
|
||||||
- --markdown-linebreak-ext=md
|
- --markdown-linebreak-ext=md
|
||||||
- repo: https://github.com/golangci/golangci-lint
|
- repo: https://github.com/golangci/golangci-lint
|
||||||
rev: v1.42.0
|
rev: v1.54.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: golangci-lint
|
- 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
|
- repo: https://github.com/PyCQA/isort
|
||||||
rev: 5.9.3
|
rev: 5.9.3
|
||||||
hooks:
|
hooks:
|
||||||
|
|
|
@ -67,6 +67,7 @@ type InseeData struct {
|
||||||
// NewInseeData generates an InseeData struct, extracting the data into the relevant fields.
|
// NewInseeData generates an InseeData struct, extracting the data into the relevant fields.
|
||||||
// The data is converted to a human-readable format before being stored.
|
// 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.
|
// 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) {
|
func NewInseeData(inseeNumber string) (*InseeData, error) {
|
||||||
if len(inseeNumber) != 15 {
|
if len(inseeNumber) != 15 {
|
||||||
return nil, fmt.Errorf("le numéro INSEE doit contenir 15 caractères")
|
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.
|
// IsValid returns true when the insee number is valid and false when not.
|
||||||
// The insee number is valid when it matches its ControlKey.
|
// 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) {
|
func (insee InseeData) IsValid() (bool, error) {
|
||||||
r := strings.NewReplacer(
|
r := strings.NewReplacer(
|
||||||
"2A", "19",
|
"2A", "19",
|
||||||
|
|
22
tasks.py
22
tasks.py
|
@ -9,6 +9,7 @@ from invoke import Context, task
|
||||||
|
|
||||||
TARGETS = [
|
TARGETS = [
|
||||||
"darwin/amd64",
|
"darwin/amd64",
|
||||||
|
"darwin/arm64",
|
||||||
"freebsd/386",
|
"freebsd/386",
|
||||||
"freebsd/amd64",
|
"freebsd/amd64",
|
||||||
"freebsd/arm",
|
"freebsd/arm",
|
||||||
|
@ -27,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)
|
||||||
|
@ -50,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 = []
|
||||||
|
@ -81,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:
|
||||||
|
@ -101,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:
|
||||||
|
@ -137,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",
|
||||||
|
|
Loading…
Reference in a new issue