Skip to content

Commit 97c23d4

Browse files
Merge pull request #228 from OpenTOPAS/bot-helper
helper script to check topas version
2 parents 6e327b8 + 6adf29c commit 97c23d4

7 files changed

Lines changed: 182 additions & 15 deletions

.github/workflows/Dockerfile.topas.workflow

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
FROM debian:12
55

66
LABEL maintainer="Jose Ramos-Mendez <Jose.RamosMendez@ucsf.edu>" \
7-
description="Docker image for TOPAS v4.2.0 (Geant4 11.3.2, GDCM 2.6.8)"
7+
description="Docker image for TOPAS v4.2.1 (Geant4 11.3.2, GDCM 2.6.8)"
88

99
# -----------------------------
1010
# Base dependencies
@@ -21,7 +21,7 @@ RUN apt-get update && \
2121
# -----------------------------
2222
# Environment paths
2323
# -----------------------------
24-
ARG TOPAS_VERSION=v4.2.0
24+
ARG TOPAS_VERSION=v4.2.1
2525
ENV TOPAS_VERSION=${TOPAS_VERSION} \
2626
APP_HOME=/Applications
2727
RUN mkdir -p $APP_HOME

OpenTOPAS_quickStart_Debian.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# QuickStart Guide for OpenTOPAS: TOol for PArticle Simulation
22
This file details the steps to be followed by <ins>Debian 10, 11 or 12</ins> in order to install OpenTOPAS and launch your first simulation.
33

4-
These instructions target TOPAS version **v4.2.0** built against Geant4 **v11.3.2**.
4+
These instructions target **v4.2.1** built against Geant4 **v11.3.2**.
55

66
> [!TIP]
77
> The directory path setting proposed in this quickStart guide sets a local installation at the home directory (path defined by `$HOME` environment variable).
@@ -139,7 +139,7 @@ Downloading and installing OpenTOPAS and GDCM.
139139
cd $HOME/Applications/TOPAS
140140
git clone https://github.com/OpenTOPAS/OpenTOPAS.git
141141
cd OpenTOPAS
142-
git checkout v4.2.0
142+
git checkout v4.2.1
143143

144144
8.1.b Alternatively, you can download OpenTOPAS manually. For a manual download, go to the OpenTOPAS GitHub [website](https://github.com/OpenTOPAS/OpenTOPAS/tree/master), click on the green tab named `<> Code` and `Download ZIP`. Create a directory called `TOPAS` in your `$HOME/Applications` directory, move the compressed folder into this directory, and decompress the file. To follow the following commands, rename the decompressed folder `OpenTOPAS-main` as `OpenTOPAS`. You should have the directory `$HOME/Applications/TOPAS/Open-TOPAS`
145145

@@ -235,9 +235,9 @@ The OpenTOPAS tests are located [here](https://github.com/OpenTOPAS/qi-opentopas
235235
pip3 install nrtest
236236
pip3 install git+https://github.com/davidchall/nrtest-topas.git
237237

238-
Modify the `apps/topas-v4.2.0.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
238+
Modify the `apps/topas-v4.2.1.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
239239

240-
nrtest execute apps/topas-v4.2.0.json tests/ -o benchmarks/todayDate
240+
nrtest execute apps/topas-v4.2.1.json tests/ -o benchmarks/todayDate
241241

242242
Comparisons can also be made with the following command:
243243

OpenTOPAS_quickStart_MacOS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# QuickStart Guide for OpenTOPAS: TOol for PArticle Simulation
22
This file details the steps to be followed by <ins>Mac users</ins> in order to install OpenTOPAS and launch your first simulation.
33

4-
These instructions target TOPAS version **v4.2.0** built against Geant4 **v11.3.2**.
4+
These instructions target **v4.2.1** built against Geant4 **v11.3.2**.
55

66
> [!WARNING]
77
> We recommend macOS version 14.0 (Sonoma) or higher. Furthermore following these instructions are solely responsability of the end user.
@@ -155,7 +155,7 @@ Downloading and installing OpenTOPAS and GDCM.
155155
cd /Applications/TOPAS
156156
git clone https://github.com/OpenTOPAS/OpenTOPAS.git
157157
cd OpenTOPAS
158-
git checkout v4.2.0
158+
git checkout v4.2.1
159159

160160
7.2. Next, check if the /Applications/GDCM already exists (GDCM is already installed). If so, rename the directory to GDCM-OLD (or another name) using the following command.
161161

@@ -256,9 +256,9 @@ The OpenTOPAS tests are located [here](https://github.com/OpenTOPAS/qi-opentopas
256256
pip3 install nrtest
257257
pip3 install git+https://github.com/davidchall/nrtest-topas.git
258258

259-
Modify the `apps/topas-v4.2.0.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
259+
Modify the `apps/topas-v4.2.1.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
260260

261-
nrtest execute apps/topas-v4.2.0.json tests/ -o benchmarks/todayDate
261+
nrtest execute apps/topas-v4.2.1.json tests/ -o benchmarks/todayDate
262262

263263
Comparisons can also be made with the following command:
264264

OpenTOPAS_quickStart_WSL.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# QuickStart Guide for WSL
22
This page details the steps to be followed by <ins>Windows users</ins> in order to install OpenTOPAS in <ins>WSL</ins> and launch your first simulation.
33

4-
These instructions target TOPAS version **v4.2.0** built against Geant4 **v11.3.2**.
4+
These instructions target **v4.2.1** built against Geant4 **v11.3.2**.
55

66
> [!WARNING]
77
> We recommend Windows 11 or higher since it includes all the visualization libraries built in. We take no responsibility if users encounter an issue with their PCs while following this guide.
@@ -176,7 +176,7 @@ Then, download OpenTOPAS from the GitHub repository using:
176176
cd ~/Applications/TOPAS
177177
git clone https://github.com/OpenTOPAS/OpenTOPAS.git
178178
cd OpenTOPAS
179-
git checkout v4.2.0
179+
git checkout v4.2.1
180180

181181
Compile GDCM as follows:
182182

@@ -264,9 +264,9 @@ The OpenTOPAS tests are located [here](https://github.com/OpenTOPAS/qi-opentopas
264264
pip3 install nrtest
265265
pip3 install git+https://github.com/davidchall/nrtest-topas.git
266266

267-
Modify the `apps/topas-v4.2.0.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
267+
Modify the `apps/topas-v4.2.1.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
268268

269-
nrtest execute apps/topas-v4.2.0.json tests/ -o benchmarks/todayDate
269+
nrtest execute apps/topas-v4.2.1.json tests/ -o benchmarks/todayDate
270270

271271
Comparisons can also be made with the following command:
272272

docker/README.Docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TOPAS Docker
22

3-
This repository provides Docker recipes and helper scripts for (re)building and running TOPAS (OpenTOPAS v4.1.1, Geant4 11.1.3, GDCM 2.6.8) on macOS or Linux. Use it to keep Geant4 data outside the container while iterating on parameter files, extensions, or visualization workflows.
3+
This repository provides Docker recipes and helper scripts for (re)building and running TOPAS (OpenTOPAS v4.2.1, Geant4 11.1.3, GDCM 2.6.8) on macOS or Linux. Use it to keep Geant4 data outside the container while iterating on parameter files, extensions, or visualization workflows.
44

55
## Run Simulations
66
Mount your Geant4 data and simulation files from the host:

scripts/check-topas-version.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cmake_file="$root/CMakeLists.txt"
6+
7+
version="$(
8+
python3 - "$cmake_file" <<'PY'
9+
import re
10+
import sys
11+
12+
text = open(sys.argv[1], "r", encoding="utf-8").read()
13+
14+
def get(name: str) -> str:
15+
match = re.search(rf"set\s*\(\s*{name}\s+([0-9]+)\s*\)", text)
16+
if not match:
17+
raise SystemExit(f"Missing {name} in {sys.argv[1]}")
18+
return match.group(1)
19+
20+
major = get("TOPAS_VERSION_MAJOR")
21+
minor = get("TOPAS_VERSION_MINOR")
22+
patch = get("TOPAS_VERSION_PATCH")
23+
print(f"{major}.{minor}.{patch}")
24+
PY
25+
)"
26+
27+
tag="v${version}"
28+
29+
python3 - "$tag" \
30+
"$root/OpenTOPAS_quickStart_Debian.md" \
31+
"$root/OpenTOPAS_quickStart_MacOS.md" \
32+
"$root/OpenTOPAS_quickStart_WSL.md" \
33+
"$root/docker/README.Docker.md" \
34+
"$root/.github/workflows/Dockerfile.topas.workflow" <<'PY'
35+
import re
36+
import sys
37+
from pathlib import Path
38+
39+
tag = sys.argv[1]
40+
paths = [Path(p) for p in sys.argv[2:]]
41+
errors = []
42+
43+
def expect_all_equal(values, label, path):
44+
if not values:
45+
errors.append(f"{path}: missing {label}")
46+
return
47+
unique = sorted(set(values))
48+
if unique != [tag]:
49+
errors.append(f"{path}: {label} {unique} != {tag}")
50+
51+
for path in paths:
52+
text = path.read_text(encoding="utf-8")
53+
if path.name.startswith("OpenTOPAS_quickStart_"):
54+
version_line = re.findall(
55+
r"(?:TOPAS version|target) \*\*(v\d+\.\d+\.\d+)\*\*",
56+
text,
57+
)
58+
checkout_tags = re.findall(r"\bgit checkout (v\d+\.\d+\.\d+)\b", text)
59+
app_tags = re.findall(r"\bapps/topas-(v\d+\.\d+\.\d+)\.json\b", text)
60+
expect_all_equal(version_line, "TOPAS version", path)
61+
expect_all_equal(checkout_tags, "git checkout tag", path)
62+
expect_all_equal(app_tags, "apps/topas tag", path)
63+
elif path.name == "Dockerfile.topas.workflow":
64+
desc_tags = re.findall(r"TOPAS (v\d+\.\d+\.\d+)", text)
65+
arg_tags = re.findall(r"ARG TOPAS_VERSION=(v\d+\.\d+\.\d+)", text)
66+
expect_all_equal(desc_tags, "description tag", path)
67+
expect_all_equal(arg_tags, "ARG TOPAS_VERSION", path)
68+
elif path.name == "README.Docker.md":
69+
docker_tags = re.findall(r"OpenTOPAS (v\d+\.\d+\.\d+)", text)
70+
expect_all_equal(docker_tags, "OpenTOPAS tag", path)
71+
72+
if errors:
73+
print("TOPAS version mismatch detected:")
74+
for err in errors:
75+
print(f"- {err}")
76+
raise SystemExit(1)
77+
78+
print(f"TOPAS version references are consistent: {tag}")
79+
PY

scripts/update-topas-version.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cmake_file="$root/CMakeLists.txt"
6+
7+
version="$(
8+
python3 - "$cmake_file" <<'PY'
9+
import re
10+
import sys
11+
12+
text = open(sys.argv[1], "r", encoding="utf-8").read()
13+
14+
def get(name: str) -> str:
15+
match = re.search(rf"set\s*\(\s*{name}\s+([0-9]+)\s*\)", text)
16+
if not match:
17+
raise SystemExit(f"Missing {name} in {sys.argv[1]}")
18+
return match.group(1)
19+
20+
major = get("TOPAS_VERSION_MAJOR")
21+
minor = get("TOPAS_VERSION_MINOR")
22+
patch = get("TOPAS_VERSION_PATCH")
23+
print(f"{major}.{minor}.{patch}")
24+
PY
25+
)"
26+
27+
tag="v${version}"
28+
29+
python3 - "$tag" \
30+
"$root/OpenTOPAS_quickStart_Debian.md" \
31+
"$root/OpenTOPAS_quickStart_MacOS.md" \
32+
"$root/OpenTOPAS_quickStart_WSL.md" \
33+
"$root/docker/README.Docker.md" \
34+
"$root/.github/workflows/Dockerfile.topas.workflow" <<'PY'
35+
import re
36+
import sys
37+
from pathlib import Path
38+
39+
tag = sys.argv[1]
40+
paths = [Path(p) for p in sys.argv[2:]]
41+
42+
for path in paths:
43+
text = path.read_text(encoding="utf-8")
44+
updated = text
45+
if path.name.startswith("OpenTOPAS_quickStart_"):
46+
updated = re.sub(
47+
r"(TOPAS version \*\*)v\d+\.\d+\.\d+(\*\*)",
48+
r"\1" + tag + r"\2",
49+
updated,
50+
)
51+
updated = re.sub(
52+
r"(target )\\1v\d+\.\d+\.\d+\\2",
53+
r"\1**" + tag + r"**",
54+
updated,
55+
)
56+
updated = re.sub(
57+
r"\bgit checkout v\d+\.\d+\.\d+\b",
58+
f"git checkout {tag}",
59+
updated,
60+
)
61+
updated = re.sub(
62+
r"\bapps/topas-v\d+\.\d+\.\d+\.json\b",
63+
f"apps/topas-{tag}.json",
64+
updated,
65+
)
66+
elif path.name == "Dockerfile.topas.workflow":
67+
updated = re.sub(
68+
r"TOPAS v\d+\.\d+\.\d+",
69+
f"TOPAS {tag}",
70+
updated,
71+
)
72+
updated = re.sub(
73+
r"ARG TOPAS_VERSION=v\d+\.\d+\.\d+",
74+
f"ARG TOPAS_VERSION={tag}",
75+
updated,
76+
)
77+
elif path.name == "README.Docker.md":
78+
updated = re.sub(
79+
r"OpenTOPAS v\d+\.\d+\.\d+",
80+
f"OpenTOPAS {tag}",
81+
updated,
82+
)
83+
84+
if updated != text:
85+
path.write_text(updated, encoding="utf-8")
86+
PY
87+
88+
echo "Updated TOPAS version references to ${tag}."

0 commit comments

Comments
 (0)