diff --git a/.gitignore b/.gitignore index 20ab5fb..ce388fa 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ node_modules/ public/ resources/ .deploy*/ + +# htmltest +tmp/ \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2aeec04..dd53b31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,28 +1,43 @@ variables: GIT_SUBMODULE_STRATEGY: recursive -test-links: - image: python:latest - script: - - python3 ./test_links.py +## GitLab defaults to: +# stages: +# - build +# - test +# - deploy -test-trailing-spaces: - script: - - ./test_trailing_spaces.sh - -test-build: - image: registry.gitlab.com/pages/hugo/hugo_extended - script: - - hugo - except: - - main - -pages: +build-site: + stage: build image: registry.gitlab.com/pages/hugo/hugo_extended script: - hugo artifacts: paths: - - public + - public + +test-html: + stage: test + image: + name: wjdp/htmltest:latest + entrypoint: [""] + cache: + key: htmltest-cache + paths: + - tmp/ + script: + - htmltest + +test-trailing-spaces: + stage: test + needs: [] # ok to run before build-site + script: + - ./test_trailing_spaces.sh + +# The GitLab Pages job must always be named "pages", and result in a "public" artifact. +# Our "public" artifact is created above, but GitLab jobs will fetch all artifacts from previous stages. +pages: + stage: deploy + script: ls -ld public only: - - main + - main diff --git a/.htmltest.yml b/.htmltest.yml new file mode 100644 index 0000000..339178b --- /dev/null +++ b/.htmltest.yml @@ -0,0 +1,11 @@ +# https://github.com/wjdp/htmltest?tab=readme-ov-file#wrench-configuration + +DirectoryPath: "public" +EnforceHTTPS: true +IgnoreURLs: +# - "example.com" +# - "^/misc/js/script.js$" +- "https://gitlab.com/lvra/lvra.gitlab.io/-/edit" +# IgnoreDirs: +# - "lib" +CacheExpires: "6h" \ No newline at end of file diff --git a/test_links.py b/test_links.py deleted file mode 100644 index 07e0a9a..0000000 --- a/test_links.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -from pathlib import Path -import re -from typing import List -from os.path import exists - - -def get_all_markdown_files(): - return Path("content").rglob("*.md") - - -def find_links(f: str) -> List[str]: - with open(f, "r") as fd: - content = fd.read() - return [ - link.lstrip("]").strip("()") for link in re.findall(r"\]\(\/[\w\/]+\)", content) - ] - - -def verify_link_exists(link: str) -> bool: - return exists(f"content{link}/_index.md") or exists(f'content{link.rstrip("/")}.md') - - -md_files = get_all_markdown_files() - -res = 0 -for f in md_files: - for link in find_links(f): - if not verify_link_exists(link): - print(f"E: {f}: {link} does not exist") - res = 1 - -exit(res)