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: ...@@ -4,6 +4,11 @@ workflow:
when: never when: never
- when: always - when: always
# Functions that should be executed before the build script is run # Functions that should be executed before the build script is run
variables: variables:
...@@ -15,6 +20,8 @@ variables: ...@@ -15,6 +20,8 @@ variables:
# prod # prod
HOST_PROD: 'defense-finder.pasteur.cloud' HOST_PROD: 'defense-finder.pasteur.cloud'
MEILI_HOST_PROD: 'defense-finder-meilisearch.pasteur.cloud' MEILI_HOST_PROD: 'defense-finder-meilisearch.pasteur.cloud'
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache: cache:
...@@ -44,9 +51,17 @@ stages: ...@@ -44,9 +51,17 @@ stages:
# Build df-wiki-cli package # 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: build:df-wiki-cli:
stage: build-df-cli
image: python:3.11-bullseye image: python:3.11-bullseye
stage: build-df-cli
before_script: before_script:
- cd packages/df-wiki-cli/ - cd packages/df-wiki-cli/
- pip install poetry - pip install poetry
...@@ -165,13 +180,11 @@ delete-meili-helm-release:prod: ...@@ -165,13 +180,11 @@ delete-meili-helm-release:prod:
# lint # lint
lint: lint:
image: python:3.11-bullseye extends: .df-wiki-cli-run
stage: lint 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: 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 when: manual
rules: rules:
- if: $CI_COMMIT_BRANCH != "main" - if: $CI_COMMIT_BRANCH != "main"
...@@ -179,12 +192,10 @@ lint: ...@@ -179,12 +192,10 @@ lint:
# Update Meili search indexes # Update Meili search indexes
.update-meilisearch-index: .update-meilisearch-index:
extends: .df-wiki-cli-run
stage: update-meilisearch-indexes stage: update-meilisearch-indexes
image: python:3.11-bullseye
variables: variables:
MEILI_HOST: "http://localhost:7700" 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: script:
- > - >
df-wiki-cli df-wiki-cli
...@@ -225,12 +236,10 @@ update-meilisearch-index:prod: ...@@ -225,12 +236,10 @@ update-meilisearch-index:prod:
############# get-meili-key ############### ############# get-meili-key ###############
.set-meili-env: .set-meili-env:
image: python:3.11-bullseye extends: .df-wiki-cli-run
stage: get-meili-key stage: get-meili-key
variables: variables:
MEILI_HOST: "http://localhost:7700" 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: script:
- > - >
df-wiki-cli df-wiki-cli
...@@ -262,10 +271,8 @@ set-meili-env:prod: ...@@ -262,10 +271,8 @@ set-meili-env:prod:
############################## ##############################
get-zotero: get-zotero:
image: python:3.11-bullseye extends: .df-wiki-cli-run
stage: get-data 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: script:
- df-wiki-cli articles --key ${ZOTERO_API_KEY} --output public/articles.json - df-wiki-cli articles --key ${ZOTERO_API_KEY} --output public/articles.json
artifacts: artifacts:
...@@ -275,10 +282,8 @@ get-zotero: ...@@ -275,10 +282,8 @@ get-zotero:
- if: $CI_COMMIT_BRANCH == "main" - if: $CI_COMMIT_BRANCH == "main"
get-pfam: get-pfam:
image: python:3.11-bullseye extends: .df-wiki-cli-run
stage: get-data 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: script:
- df-wiki-cli pfam --output public/pfam-a-hmm.csv - df-wiki-cli pfam --output public/pfam-a-hmm.csv
artifacts: artifacts:
......
import typer import typer
import sys
from typing_extensions import Annotated from typing_extensions import Annotated
from typing import Optional, List from typing import Optional, List
from pathlib import Path from pathlib import Path
from pydantic import BaseModel, ValidationError from pydantic import BaseModel, ValidationError
from pydantic_yaml import parse_yaml_raw_as, to_yaml_str
import frontmatter import frontmatter
from enum import Enum from enum import Enum
from rich.console import Console from rich.console import Console
...@@ -70,7 +70,9 @@ def lint( ...@@ -70,7 +70,9 @@ def lint(
# pprint(exc.errors(), expand_all=True) # pprint(exc.errors(), expand_all=True)
for err in exc.errors(): for err in exc.errors():
console.print( 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: else:
console.print("[green] Everything is alright") 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