diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 38db175d5e..dade932f82 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,6 +3,8 @@ name: deploy documentation (only on push to main branch) on: push: branches: main + # Add option to deploy manually, e.g. because there is a new EESSI test suite release and we want updated API docs + workflow_dispatch: # Declare default permissions as read only. permissions: read-all jobs: @@ -28,5 +30,23 @@ jobs: pip list | grep mkdocs mkdocs --version + # Make sure to also deploy auto-generated API docs for test suite + # For that, we need the repo to be available under eessi/test-suite + - name: checkout test suite + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 + with: + repository: eessi/test-suite + # Path is needed, otherwise this will overwrite the checkout action that cloned the docs repo + path: test-suite + # Make sure to fetch tags, so we can checkout a particular release + fetch-tags: True + # Generate docs for latest release + run: | + cd eessi/tests-suite + # This assumes we stick to a version-tagging scheme vX.Y.Z + LATEST_VERSION=$(git tag | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1) + # Use the latest release by default + git checkout $LATEST_VERSION + - name: build tutorial run: make test && make deploy diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c83061278c..af9ff83724 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,6 +30,25 @@ jobs: # config: '/lint/config/changelog.yml' # args: '.' + + # Make sure to also test deployment of auto-generated API docs for test suite + # For that, we need the repo to be available under eessi/test-suite + - name: checkout test suite + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 + with: + repository: eessi/test-suite + # Path is needed, otherwise this will overwrite the checkout action that cloned the docs repo + path: test-suite + # Make sure to fetch tags, so we can checkout a particular release + fetch-tags: True + # Generate docs for latest release + run: | + cd eessi/tests-suite + # This assumes we stick to a version-tagging scheme vX.Y.Z + LATEST_VERSION=$(git tag | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1) + # Use the latest release by default + git checkout $LATEST_VERSION + - name: install mkdocs + plugins run: | pip install -r requirements.txt diff --git a/docs/adding_software/debugging_failed_builds.md b/docs/adding_software/debugging_failed_builds.md index 87236a56b6..a71d7b6da0 100644 --- a/docs/adding_software/debugging_failed_builds.md +++ b/docs/adding_software/debugging_failed_builds.md @@ -227,7 +227,7 @@ eb --easystack eessi-2023.06-eb-4.8.1-2021b.yml --robot After some time, this build fails while trying to build `Plumed`, and we can access the build log to look for clues on why it failed. ## Building an individual package -First, prepare the environment by following the [Starting the EESSI software environment][#starting-the-eessi-software-environment] and [Configure EasyBuild](#configure-easybuild) above. +First, prepare the environment by following the [Starting the EESSI software environment](#starting-the-eessi-software-environment) and [Configure EasyBuild](#configure-easybuild) above. In our [example PR](https://github.com/EESSI/software-layer/pull/360), the individual package that was added to `eessi-2023.06-eb-4.8.1-2021b.yml` was `LAMMPS-23Jun2022-foss-2021b-kokkos.eb`. To mimic the build behaviour, we'll also have to (re)use any options that are listed in the easystack file for `LAMMPS-23Jun2022-foss-2021b-kokkos.eb`, in this case the option `--from-pr 19000`. Thus, to build, we run: ``` diff --git a/docs/generate_eessi_testsuite_api_docs.py b/docs/generate_eessi_testsuite_api_docs.py new file mode 100644 index 0000000000..2aa11bf3c9 --- /dev/null +++ b/docs/generate_eessi_testsuite_api_docs.py @@ -0,0 +1,50 @@ +""" +Generate the code reference pages. +Based off https://mkdocstrings.github.io/recipes/#automatic-code-reference-pages +""" + +from pathlib import Path + +import mkdocs_gen_files + +TEST_SUITE = "test-suite/test-suite" + +# build a navigation for the menu and a dictionary of navigations for each section +nav = mkdocs_gen_files.Nav() + +# Loop through all python files in test-suite/eessi +for path in sorted(Path(f"{TEST_SUITE}/eessi/").rglob("*.py")): + # Get the relative filename, without .py suffix + module_path = path.relative_to(TEST_SUITE).with_suffix("") + + # define the corresponding (relative) markdown filename + doc_path = path.relative_to(TEST_SUITE).with_suffix(".md") + + # Specify the full corresponding markdown filename, including a testsuite_api subdir + # so that we don't have these API docs scattered in the root of the EESSI docs repo + full_doc_path = Path("testsuite_api/", doc_path) + + # If something is an __init__, use the directory name as the name of the python module instead of the filename + parts = list(module_path.parts) + if parts[-1] == "__init__": + parts = parts[:-1] + # Skip the __main__, if there is one. This is not part of the API + elif parts[-1] == "__main__": + continue + + # Add an entry for this module to the navigation + nav[parts] = doc_path.as_posix() + + # Create the markdown file + with mkdocs_gen_files.open(full_doc_path, "w") as fd: + # identifier is something like eessi.foo.bar + identifier = ".".join(parts) + fd.write(f"::: {identifier}") + + # This maps the generated .md file to the source .py, so that you can have an "Edit on GitHub" button + # that links to the Python code + mkdocs_gen_files.set_edit_path(full_doc_path, path) + + # Create the api/summary.md file and write the full navigation tree into it so it can be used as a site sidebar +with mkdocs_gen_files.open("testsuite_api/summary.md", "w") as nav_file: + nav_file.writelines(nav.build_literate_nav()) diff --git a/mkdocs.yml b/mkdocs.yml index 9a36f88409..0d81c8543c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -56,6 +56,7 @@ nav: - Available tests: test-suite/available-tests.md - Writing tests: test-suite/writing-portable-tests.md - Release notes: test-suite/release-notes.md + - API documentation: testsuite_api/ - Known issues and workarounds: - v2023.06: known_issues/eessi-2023.06.md - Adding software to EESSI: @@ -103,6 +104,24 @@ plugins: gpu.md: site_specific_config/gpu.md # Enable our custom plugin for json-ld metadata - inject_ld_json + # link to any Markdown heading + - autorefs + # api automatics documentation + - mkdocstrings: + default_handler: python + handlers: + python: + paths: [test-suite/test-suite] + options: + docstring_style: sphinx + docstring_section_style: spacy + show_source: false + - gen-files: + scripts: + - docs/generate_eessi_testsuite_api_docs.py + - literate-nav: + nav_file: summary.md + - section-index markdown_extensions: # enable adding HTML attributes and CSS classes - attr_list diff --git a/requirements.txt b/requirements.txt index 9ee841f53d..2bda7fc5b2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,8 @@ mkdocs-git-revision-date-localized-plugin mkdocs-toc-sidebar-plugin mkdocs-macros-plugin ./mkdocs-ldjson-plugin +mkdocs-autorefs +mkdocstrings[python] +mkdocs-gen-files +mkdocs-literate-nav +mkdocs-section-index