Skip to content
Snippets Groups Projects
Commit c5b27a3e authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Front matter linter

parent c275a95b
No related branches found
No related tags found
1 merge request!122Front matter linter
......@@ -4,6 +4,11 @@ workflow:
when: never
- when: always
# Functions that should be executed before the build script is run
variables:
......@@ -15,6 +20,8 @@ variables:
# prod
HOST_PROD: 'defense-finder.pasteur.cloud'
MEILI_HOST_PROD: 'defense-finder-meilisearch.pasteur.cloud'
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
......@@ -44,9 +51,17 @@ stages:
# Build df-wiki-cli package
.df-wiki-cli-run:
image: python:3.11-bullseye
cache: # Pip's cache doesn't store the python packages
paths: # https://pip.pypa.io/en/stable/topics/caching/
- .cache/pip
before_script:
- pip install df-wiki-cli --index-url https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.pasteur.fr/api/v4/projects/5222/packages/pypi/simple
build:df-wiki-cli:
stage: build-df-cli
image: python:3.11-bullseye
stage: build-df-cli
before_script:
- cd packages/df-wiki-cli/
- pip install poetry
......@@ -165,13 +180,11 @@ delete-meili-helm-release:prod:
# lint
lint:
image: python:3.11-bullseye
extends: .df-wiki-cli-run
stage: lint
before_script:
- pip install df-wiki-cli --index-url https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.pasteur.fr/api/v4/projects/5222/packages/pypi/simple
- cd content/3.defense-systems
script:
- find . -name '*.md' -print0 | xargs -0 -I {} df-wiki-cli content lint --file {}
- cd content/3.defense-systems
- find . -name '*.md' ! -name '0.index.md' -print0 | xargs -0 -I {} df-wiki-cli content lint --file {}
when: manual
rules:
- if: $CI_COMMIT_BRANCH != "main"
......@@ -179,12 +192,10 @@ lint:
# Update Meili search indexes
.update-meilisearch-index:
extends: .df-wiki-cli-run
stage: update-meilisearch-indexes
image: python:3.11-bullseye
variables:
MEILI_HOST: "http://localhost:7700"
before_script:
- pip install df-wiki-cli --index-url https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.pasteur.fr/api/v4/projects/5222/packages/pypi/simple
script:
- >
df-wiki-cli
......@@ -225,12 +236,10 @@ update-meilisearch-index:prod:
############# get-meili-key ###############
.set-meili-env:
image: python:3.11-bullseye
extends: .df-wiki-cli-run
stage: get-meili-key
variables:
MEILI_HOST: "http://localhost:7700"
before_script:
- pip install df-wiki-cli --index-url https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.pasteur.fr/api/v4/projects/5222/packages/pypi/simple
script:
- >
df-wiki-cli
......@@ -262,10 +271,8 @@ set-meili-env:prod:
##############################
get-zotero:
image: python:3.11-bullseye
extends: .df-wiki-cli-run
stage: get-data
before_script:
- pip install df-wiki-cli --index-url https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.pasteur.fr/api/v4/projects/5222/packages/pypi/simple
script:
- df-wiki-cli articles --key ${ZOTERO_API_KEY} --output public/articles.json
artifacts:
......@@ -275,10 +282,8 @@ get-zotero:
- if: $CI_COMMIT_BRANCH == "main"
get-pfam:
image: python:3.11-bullseye
extends: .df-wiki-cli-run
stage: get-data
before_script:
- pip install df-wiki-cli --index-url https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.pasteur.fr/api/v4/projects/5222/packages/pypi/simple
script:
- df-wiki-cli pfam --output public/pfam-a-hmm.csv
artifacts:
......
import typer
import sys
from typing_extensions import Annotated
from typing import Optional, List
from pathlib import Path
from pydantic import BaseModel, ValidationError
from pydantic_yaml import parse_yaml_raw_as, to_yaml_str
import frontmatter
from enum import Enum
from rich.console import Console
......@@ -70,7 +70,9 @@ def lint(
# pprint(exc.errors(), expand_all=True)
for err in exc.errors():
console.print(
f"[red]{err['msg']} : {err['type']} {' -> '.join(err['loc'])}"
f"[red]{err['msg']} : {err['type']} {' -> '.join([str(l) for l in err['loc']])}"
)
# raise
sys.exit(1)
else:
console.print("[green] Everything is alright")
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment