From 6e173c87601eb39889efbd3e386f5a2828cc6633 Mon Sep 17 00:00:00 2001 From: Liam Mulhall Date: Tue, 13 Jan 2026 11:52:33 -0800 Subject: [PATCH 1/2] feat(common): Add Git SHA to footer https://github.com/ClinGen/hla-curation-interface/issues/52 --- .gitignore | 1 + infra/ansible/tasks/admin/git_sha.yml | 4 ++++ src/common/context_processors.py | 8 ++++++++ src/config/settings/base.py | 8 ++++++++ src/templates/partials/footer.html | 3 +++ 5 files changed, 24 insertions(+) create mode 100644 infra/ansible/tasks/admin/git_sha.yml create mode 100644 src/common/context_processors.py diff --git a/.gitignore b/.gitignore index 4229f3f5..66b296cb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ coverage.xml firebase-account-key* inventory.ini +version.txt .ansible/ .mypy_cache/ diff --git a/infra/ansible/tasks/admin/git_sha.yml b/infra/ansible/tasks/admin/git_sha.yml new file mode 100644 index 00000000..08fe104d --- /dev/null +++ b/infra/ansible/tasks/admin/git_sha.yml @@ -0,0 +1,4 @@ +- name: Generate shortened Git SHA + ansible.builtin.command: + chdir: "{{ repo_dir }}" + cmd: "git rev-parse --short HEAD > version.txt" diff --git a/src/common/context_processors.py b/src/common/context_processors.py new file mode 100644 index 00000000..ac543116 --- /dev/null +++ b/src/common/context_processors.py @@ -0,0 +1,8 @@ +"""Houses context processors used throughout the app.""" + +from django.conf import settings + + +def git_sha(request) -> dict: # noqa: ANN001 (Required to have the param.) + """Returns the shortened Git SHA.""" + return {"GIT_SHA": settings.GIT_SHA} diff --git a/src/config/settings/base.py b/src/config/settings/base.py index a796039a..d7b2c1dd 100644 --- a/src/config/settings/base.py +++ b/src/config/settings/base.py @@ -15,6 +15,13 @@ BASE_DIR = Path(__file__).resolve().parent.parent.parent +try: + version_file_path = Path(BASE_DIR / "version.txt") + with version_file_path.open(encoding="utf-8") as f: + GIT_SHA = f.read().strip() +except Exception: + GIT_SHA = "dev" + SECRET_KEY = os.getenv("SECRET_KEY") INSTALLED_APPS = [ @@ -63,6 +70,7 @@ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "common.context_processors.git_sha", ], }, }, diff --git a/src/templates/partials/footer.html b/src/templates/partials/footer.html index 4d54da81..0f1aabcd 100644 --- a/src/templates/partials/footer.html +++ b/src/templates/partials/footer.html @@ -51,5 +51,8 @@ The source code is subject to the MIT License.

+

+ {{ GIT_SHA }} +

From 2822ae23c9f76ba30e8e261bbd890981e5a86d4c Mon Sep 17 00:00:00 2001 From: Liam Mulhall Date: Tue, 13 Jan 2026 12:09:44 -0800 Subject: [PATCH 2/2] chore: Fix various CI issues https://github.com/ClinGen/hla-curation-interface/pull/53 --- src/common/context_processors.py | 2 +- src/publication/tests.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/context_processors.py b/src/common/context_processors.py index ac543116..7433bd83 100644 --- a/src/common/context_processors.py +++ b/src/common/context_processors.py @@ -3,6 +3,6 @@ from django.conf import settings -def git_sha(request) -> dict: # noqa: ANN001 (Required to have the param.) +def git_sha(request) -> dict: # noqa (Required to have the param.) """Returns the shortened Git SHA.""" return {"GIT_SHA": settings.GIT_SHA} diff --git a/src/publication/tests.py b/src/publication/tests.py index e39b30e2..a5e16a11 100644 --- a/src/publication/tests.py +++ b/src/publication/tests.py @@ -305,7 +305,9 @@ def test_shows_year_in_thead(self): response = self.client.get(self.url) soup = BeautifulSoup(response.content, "html.parser") year_label = ( - soup.find("label", {"for": "sort-publication-year-button"}).get_text().strip() + soup.find("label", {"for": "sort-publication-year-button"}) + .get_text() + .strip() ) self.assertEqual(year_label, "Year") year_button = soup.find(id="sort-publication-year-button") @@ -314,11 +316,11 @@ def test_shows_year_in_thead(self): def test_shows_title_in_tbody(self): response = self.client.get(self.url) soup = BeautifulSoup(response.content, "html.parser") - title = soup.find("tbody").find("tr").find_all("td")[4].get_text().strip() + title = soup.find("tbody").find("tr").find_all("td")[3].get_text().strip() self.assertEqual(title, "Diseases in grass type Pokémon in the Kanto region") def test_shows_added_in_tbody(self): response = self.client.get(self.url) soup = BeautifulSoup(response.content, "html.parser") - added_at = soup.find("tbody").find("tr").find_all("td")[5].get_text().strip() + added_at = soup.find("tbody").find("tr").find_all("td")[7].get_text().strip() self.assertIn("1990-01-01", added_at)