diff --git a/.github/workflows/update_available_software.yml b/.github/workflows/update_available_software.yml index 633769f29..85b666804 100644 --- a/.github/workflows/update_available_software.yml +++ b/.github/workflows/update_available_software.yml @@ -1,5 +1,6 @@ name: Update overview of available software in EESSI on: + pull_request: workflow_dispatch: schedule: # run every 4 hours @@ -34,6 +35,7 @@ jobs: cp docs/available_software/data/json_data.json docs/available_software/data/json_data.json.orig cp docs/available_software/data/json_data_detail.json docs/available_software/data/json_data_detail.json.orig + export TIME_GENERATED_TEMPLATE="{{ generated_time }}" python scripts/available_software/available_software.py git status @@ -47,6 +49,7 @@ jobs: else echo "JSON files in docs/available_software/data have been changed, PR should be opened" echo "json_data_changed=yes" >> $GITHUB_OUTPUT + ./scripts/update_generated_time.sh mkdocs.yml fi # remove original JSON files, or they'll end up in the PR being opened diff --git a/mkdocs.yml b/mkdocs.yml index 78b552aff..68f6c9a8b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -118,11 +118,14 @@ markdown_extensions: - pymdownx.emoji: emoji_index: !!python/name:material.extensions.emoji.twemoji emoji_generator: !!python/name:material.extensions.emoji.to_svg + # Enable macros so we can use global variables + - macros extra: # add links in bottom right social: - icon: fontawesome/brands/twitter link: https://twitter.com/eessi_hpc + generated_time: "Wed, 07 Aug 2024 at 17:08:54 CEST" extra_javascript: # mermaid diagram - https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs diff --git a/requirements.txt b/requirements.txt index cc56811d9..c4e40dd4e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ mkdocs-material mkdocs-redirects mkdocs-git-revision-date-localized-plugin mkdocs-toc-sidebar-plugin +mkdocs-macros-plugin diff --git a/scripts/available_software/available_software.py b/scripts/available_software/available_software.py index 273856b07..efd6b75bf 100644 --- a/scripts/available_software/available_software.py +++ b/scripts/available_software/available_software.py @@ -408,8 +408,14 @@ def generate_detail_pages(json_path, dest_path) -> None: data = json.load(json_data) all_targets = data["targets"] + + time_generated_template = os.environ.get('TIME_GENERATED_TEMPLATE') for software, content in data["software"].items(): - generate_software_detail_page(software, content, data["time_generated"], all_targets, dest_path) + if time_generated_template: + time_generated = time_generated_template + else: + time_generated = data["time_generated"] + generate_software_detail_page(software, content, time_generated, all_targets, dest_path) # -------------------------------------------------------------------------------------------------------- diff --git a/scripts/available_software/tests/data/test_md_template_detailed_science_sol.md b/scripts/available_software/tests/data/test_md_template_detailed_science_sol.md new file mode 100644 index 000000000..d879e0955 --- /dev/null +++ b/scripts/available_software/tests/data/test_md_template_detailed_science_sol.md @@ -0,0 +1,25 @@ +--- +hide: + - toc +--- + +science +======= + +# Available modules + + +The overview below shows which science installations are available per target architecture in EESSI, ordered based on software version (new to old). + +To start using science, load one of these modules using a `module load` command like: + +```shell +module load science/7.2.0 +``` + +*(This data was automatically generated on {{ generated_date }})* + +| |aarch64/generic|x86_64/amd/zen2| +| :---: | :---: | :---: | +|science/7.2.0|x|x| +|science/5.3.0|x|x| diff --git a/scripts/available_software/tests/test_md.py b/scripts/available_software/tests/test_md.py index 007824fbf..02fc16142 100644 --- a/scripts/available_software/tests/test_md.py +++ b/scripts/available_software/tests/test_md.py @@ -1,7 +1,9 @@ from mdutils.mdutils import MdUtils from available_software import get_unique_software_names, modules_eessi, generate_table_data, generate_module_table +from available_software import generate_detail_pages import os import filecmp +import shutil class TestMarkdown: @@ -22,6 +24,8 @@ def setup_class(cls): def teardown_class(cls): if os.path.exists("test_simple.md"): os.remove("test_simple.md") + if os.path.exists("detailed_md"): + shutil.rmtree("detailed_md") # --------------------------- # Markdown tests @@ -41,3 +45,11 @@ def test_md_simple(self): md_file.create_md_file() assert os.path.exists("test_simple.md") assert filecmp.cmp(self.path + "/data/test_md_simple_sol.md", "test_simple.md") + + def test_md_detailed_template(self): + os.environ["TIME_GENERATED_TEMPLATE"] = "{{ generated_date }}" + os.mkdir('detailed_md') + generate_detail_pages(self.path + "/data/test_json_simple_sol_detail.json", 'detailed_md') + del os.environ["TIME_GENERATED_TEMPLATE"] + assert os.path.exists("detailed_md/science.md") + assert filecmp.cmp(self.path + "/data/test_md_template_detailed_science_sol.md", "detailed_md/science.md") diff --git a/scripts/update_generated_time.sh b/scripts/update_generated_time.sh new file mode 100755 index 000000000..dde38e02d --- /dev/null +++ b/scripts/update_generated_time.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Get the new date +NEW_DATE="$(date '+%a, %d %b %Y at %H:%M:%S %Z')" +# Inject it into the target file +sed -i 's/\(generated_time: "\)[^"]*\(".*\)/\1'"${NEW_DATE}"'\2/' $1