diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 82523f270552883aa67177063732a8cc91539951..a6af4eb50b3846b091608fcc275410f0a586f804 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -146,8 +146,8 @@ Autobranch: local branch=$2 local force_branch=$3 - local worktree=$(mktemp -d --suffix "${branch}-repo") - local patch=$(mktemp --suffix "$branch.patch") + local worktree=$(mktemp -d --suffix "-${branch}-repo") + local patch=$(mktemp --suffix "-$branch.patch") lisa-combine-gitlab-mr --server "$CI_SERVER_HOST" --repo "$CI_PROJECT_PATH" --project-id "$CI_PROJECT_ID" --api-url "$CI_API_V4_URL" --api-token "$GITLAB_REPO_TOKEN" --mr-label "$label" --branch "$force_branch" && @@ -193,7 +193,7 @@ pages: publish: doc/public rules: - - if: $CI_PIPELINE_SOURCE == "web" && $WEB_SKIP_AUTOBRANCH == "False" + - if: $CI_PIPELINE_SOURCE == "web" && $WEB_SKIP_PAGES == "False" - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH before_script: @@ -210,45 +210,69 @@ pages: script: - | function lisa_python() { - "$LISA_PYTHON" "$@" + "$LISA_PYTHON" "$@" } - set -e + function audit() { + lisa_python -m pip install --upgrade pip-audit + pip-audit || exit 1 + } - # Ensure we have up to date versions of every pre-installed packages - lisa_python -m pip freeze --exclude-editable --all | cut -f1 -d '=' > "$packages" - lisa_python -m pip install --upgrade -r "$packages" + function upgrade_packages() { + packages=$(mktemp) + # Ensure we have up to date versions of every pre-installed packages + lisa_python -m pip freeze --local --exclude-editable --all | cut -f1 -d '=' > "$packages" + lisa_python -m pip install --upgrade -r "$packages" + } - lisa_python -m pip install --upgrade pip-audit - pip-audit || exit 1 + function make_venv() { + local venv=$(mktemp -d --suffix '-venv') + lisa_python -m venv "$venv" && source "$venv/bin/activate" + upgrade_packages + } - - | + set -ex # Avoid using /tmp since it's probably in tmpfs and would consume RAM export TMPDIR=$(readlink -f .)/tmp mkdir -p "$TMPDIR" + + make_venv + audit + + - | out="$(readlink -f .)/doc/public" - fn build_branch() { + function build_branch() { local branch=$1 - local worktree=$(mktemp -d) - git fetch "$branch" + local worktree=$(mktemp -d --suffix "-worktree-$branch") + git fetch origin "$branch" git worktree add "$worktree" --checkout "$branch" ( set -e cd "$worktree" sudo ./install_base.sh --install-doc-extras - source init_env + + make_venv + lisa_python -m pip install -r ./devmode_requirements.txt + audit + export LC_ALL=C - sphinx-build -b html -n --no-color -W --keep-going -T -j auto . "$out/$branch" + sphinx-build -b html -n --no-color -W --keep-going -T -j auto ./doc "$out/$branch" ) } build_branch main &> main_stdout & build_branch preview &> preview_stdout & build_branch release &> release_stdout & - wait + echo '================================================================================' + echo 'MAIN:' cat main_stdout + echo '================================================================================' + echo 'PREVIEW:' cat preview_stdout + echo '================================================================================' + echo 'RELEASE:' cat release_stdout + diff --git a/doc/conf.py b/doc/conf.py index a2a2ef0194b09435d7e208d0a33e2c16b438e197..4bc0d537a85b6b32b30b93135f617134e593b838 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -24,6 +24,7 @@ import inspect import importlib import types import contextlib +from pathlib import Path from sphinx.domains.python import PythonDomain @@ -42,6 +43,7 @@ from lisa._doc.helpers import ( DocPlotConf, get_xref_type, ) +HOME = Path(LISA_HOME).resolve() # This ugly hack is required because by default TestCase.__module__ is # equal to 'case', so sphinx replaces all of our TestCase uses to @@ -60,7 +62,7 @@ def prepare(): def run(cmd, **kwargs): return subprocess.run( cmd, - cwd=LISA_HOME, + cwd=HOME, **kwargs, ) @@ -86,13 +88,13 @@ def prepare(): script = textwrap.dedent( """ - source init_env >&2 && + source ./init_env >&2 && python -c 'import os, json; print(json.dumps(dict(os.environ)))' """ ) out = subprocess.check_output( ['bash', '-c', script], - cwd=LISA_HOME, + cwd=HOME, # Reset the environment, including LISA_HOME to allow sourcing without # any issue env=source_env, @@ -486,7 +488,7 @@ class CustomPythonDomain(PythonDomain): def setup(app): app.add_domain(CustomPythonDomain, override=True) - plot_conf_path = os.path.join(LISA_HOME, 'doc', 'plot_conf.yml') + plot_conf_path = os.path.join(HOME, 'doc', 'plot_conf.yml') plot_conf = DocPlotConf.from_yaml_map(plot_conf_path) autodoc_process_analysis_plots_handler = functools.partial( autodoc_process_analysis_plots, diff --git a/shell/lisa_shell b/shell/lisa_shell index 6abb7d7eaff0222546bad40de179ec0370aead20..9a0e034939ccb2ccd789241c01f736c4513c782b 100755 --- a/shell/lisa_shell +++ b/shell/lisa_shell @@ -215,6 +215,7 @@ function _lisa-copy-git-hook { # Avoid overriding existing hooks unless they are provided by LISA if [[ ! -e "$dst" ]] || grep -q 'LISA-HOOK' "$dst"; then + mkdir -p "$(basename "$dst")" && cp -v "$src" "$dst" else echo "WARNING: Could not install git hook, as it is user-provided: $src => $dst"