-
Notifications
You must be signed in to change notification settings - Fork 11
159 lines (145 loc) · 5.83 KB
/
Copy pathci.yml
File metadata and controls
159 lines (145 loc) · 5.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: TOPAS-nBio CI
on:
push:
branches:
- main
- develop
paths-ignore:
- '*.md'
workflow_dispatch:
pull_request:
branches:
- main
- develop
paths-ignore:
- '*.md'
jobs:
docker-tests:
name: Docker Tests
runs-on: ubuntu-latest
env:
TOPAS_DOCKER_IMAGE: opentopas/opentopas:latest
G4DATA_DIR: ${{ github.workspace }}/.cache/GEANT4/G4DATA
TEST_SUITE_DIR: ${{ github.workspace }}/qi-topas-nbio
NRTEST_ENV: ${{ github.workspace }}/.cache/nrtest-env
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache Geant4 data
id: cache-g4data
uses: actions/cache@v4
with:
path: ${{ env.G4DATA_DIR }}
key: g4data-G4EMLOW-8.6.1-G4ENSDFSTATE-3.0
- name: Download Geant4 EMLOW & ENSDFSTATE datasets
if: steps.cache-g4data.outputs.cache-hit != 'true'
run: |
set -euo pipefail
mkdir -p "$G4DATA_DIR"
cd "$G4DATA_DIR"
curl -sSLO https://cern.ch/geant4-data/datasets/G4EMLOW.8.6.1.tar.gz
tar -xzf G4EMLOW.8.6.1.tar.gz
rm G4EMLOW.8.6.1.tar.gz
curl -sSLO https://cern.ch/geant4-data/datasets/G4ENSDFSTATE.3.0.tar.gz
tar -xzf G4ENSDFSTATE.3.0.tar.gz
rm G4ENSDFSTATE.3.0.tar.gz
- name: Pull OpenTOPAS Docker image
run: docker pull $TOPAS_DOCKER_IMAGE
- name: Download TOPAS docker launcher
run: |
curl -sSfL https://raw.githubusercontent.com/OpenTOPAS/OpenTOPAS/main/docker/topas-docker -o docker-run
chmod +x docker-run
- name: Install nrtest tooling
run: |
python -m venv "$NRTEST_ENV"
source "$NRTEST_ENV/bin/activate"
python -m pip install --upgrade pip
python -m pip install nrtest git+https://github.com/davidchall/nrtest-topas.git
- name: Fetch qi-topas-nbio tests (latest tag)
run: |
set -euo pipefail
if ! command -v jq >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y jq
fi
LATEST_TAG=$(curl -sS https://api.github.com/repos/topas-nbio/qi-topas-nbio/releases/latest | jq -r '.tag_name // empty')
if [ -z "$LATEST_TAG" ]; then
echo "Unable to determine latest release tag; falling back to main"
LATEST_TAG=main
fi
git clone --depth 1 --branch "$LATEST_TAG" https://github.com/topas-nbio/qi-topas-nbio.git "$TEST_SUITE_DIR"
- name: Configure nrtest app manifest
run: |
cat <<EOF > "$TEST_SUITE_DIR/apps/topas-docker.json"
{
"name": "topas",
"version": "$GITHUB_SHA",
"exe": "$GITHUB_WORKSPACE/.github/scripts/run-topas-docker.sh"
}
EOF
- name: Run qi-topas-nbio test suite
id: nrtest
env:
TOPAS_NBIO_ROOT: ${{ github.workspace }}
TOPAS_DOCKER_LAUNCHER: ${{ github.workspace }}/docker-run
G4DATA_DIR: ${{ env.G4DATA_DIR }}
run: |
set -euo pipefail
source "$NRTEST_ENV/bin/activate"
cd "$TEST_SUITE_DIR"
if [ -d benchmarks ]; then
find benchmarks -mindepth 1 -maxdepth 1 -type d -regex '.*/[0-9].*' -exec rm -rf {} +
fi
BENCHMARK_DIR="benchmarks/${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-$(date +%Y-%m-%d-%H%M%S)"
rm -rf "$BENCHMARK_DIR"
mkdir -p "$(dirname "$BENCHMARK_DIR")"
echo "benchmark_dir=$TEST_SUITE_DIR/$BENCHMARK_DIR" >> "$GITHUB_OUTPUT"
if ! nrtest execute apps/topas-docker.json tests/ -o "$BENCHMARK_DIR"; then
echo "::group::nrtest failing stdout/stderr"
while IFS= read -r -d '' log; do
rel_path=${log#"$TEST_SUITE_DIR"/}
echo "----- $rel_path -----"
tail -n 200 "$log" || true
done < <(find "$BENCHMARK_DIR" -type f \( -name stdout.txt -o -name stderr.txt -o -name '*.log' \) -print0)
echo "::endgroup::"
exit 1
fi
# - name: Compare output file sizes against baseline
# if: steps.nrtest.outputs.benchmark_dir != ''
# env:
# TEST_SUITE_DIR: ${{ env.TEST_SUITE_DIR }}
# run: |
# set -euo pipefail
# BASELINE_DIR="$TEST_SUITE_DIR/benchmarks/TOPAS-nBio-v4.0_2025Nov09"
# NEW_DIR="${{ steps.nrtest.outputs.benchmark_dir }}"
# if [ ! -d "$BASELINE_DIR" ]; then
# echo "::warning file=benchmarks::Baseline directory $BASELINE_DIR not found; skipping comparison step."
# exit 0
# fi
# status=0
# while IFS= read -r relpath; do
# base_file="$BASELINE_DIR/$relpath"
# new_file="$NEW_DIR/$relpath"
# if [ ! -f "$new_file" ]; then
# echo "::error file=$relpath::Missing new file for baseline artifact"
# status=1
# continue
# fi
# base_size=$(wc -c < "$base_file" | tr -d '[:space:]')
# new_size=$(wc -c < "$new_file" | tr -d '[:space:]')
# if [ "$base_size" != "$new_size" ]; then
# echo "::error file=$relpath::File size mismatch for $relpath (baseline=${base_size}B, new=${new_size}B)"
# status=1
# fi
# done < <(cd "$BASELINE_DIR" && find . -type f \( -name '*.phsp' -o -name '*.csv' -o -name '*.txt' -o -name '*.xyz' -o -name '*.out' \) -print | sed 's|^\./||')
# exit $status
- name: Upload nrtest benchmark
if: always() && steps.nrtest.outputs.benchmark_dir != ''
uses: actions/upload-artifact@v4
with:
name: nrtest-results-${{ github.run_id }}
path: ${{ steps.nrtest.outputs.benchmark_dir }}