Skip to content

Commit 5231a36

Browse files
Copilotilaflott
andcommitted
Fix gather script arithmetic bug, restructure workflow to run tests first
Agent-Logs-Url: https://github.com/ilaflott/fremorizer/sessions/9a306387-45f9-4cd4-a4c3-16157ba3e367 Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
1 parent b2347b9 commit 5231a36

2 files changed

Lines changed: 54 additions & 32 deletions

File tree

.github/scripts/gather_test_outputs.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,24 @@ gather_files() {
6161
cmip_version="other"
6262
if [[ "${ncfile}" == *"CMIP6"* ]]; then
6363
cmip_version="cmip6"
64-
((cmip6_files++))
64+
cmip6_files=$((cmip6_files + 1))
6565
elif [[ "${ncfile}" == *"CMIP7"* ]]; then
6666
cmip_version="cmip7"
67-
((cmip7_files++))
67+
cmip7_files=$((cmip7_files + 1))
6868
else
6969
# Try to detect from file attributes using ncdump
7070
if command -v ncdump &> /dev/null; then
7171
if ncdump -h "${ncfile}" 2>/dev/null | grep -q 'mip_era = "CMIP7"'; then
7272
cmip_version="cmip7"
73-
((cmip7_files++))
73+
cmip7_files=$((cmip7_files + 1))
7474
elif ncdump -h "${ncfile}" 2>/dev/null | grep -q 'mip_era = "CMIP6"'; then
7575
cmip_version="cmip6"
76-
((cmip6_files++))
76+
cmip6_files=$((cmip6_files + 1))
7777
else
78-
((other_files++))
78+
other_files=$((other_files + 1))
7979
fi
8080
else
81-
((other_files++))
81+
other_files=$((other_files + 1))
8282
fi
8383
fi
8484

@@ -95,7 +95,7 @@ gather_files() {
9595
# Add to manifest
9696
echo "${ncfile} -> ${cmip_version}/${unique_name}" >> "${MANIFEST}"
9797

98-
((total_files++))
98+
total_files=$((total_files + 1))
9999

100100
echo " found: ${ncfile}"
101101
echo " -> ${cmip_version}/${unique_name}"

.github/workflows/wcrp_compliance_check.yml

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,46 +57,35 @@ jobs:
5757
conda-forge::pyyaml \
5858
conda-forge::pytest
5959
60-
- name: Install cc-plugin-wcrp
61-
run: |
62-
pip install cc-plugin-wcrp
63-
64-
- name: Configure esgvoc controlled vocabularies
65-
run: |
66-
esgvoc config add cordex-cmip6
67-
esgvoc config add cmip7
68-
esgvoc config set project:branch=esgvoc
69-
esgvoc install
70-
71-
- name: Verify cc-plugin-wcrp installation
72-
run: |
73-
echo "Listing available compliance-checker plugins..."
74-
compliance-checker -l
75-
7660
- name: Install fremorizer
7761
run: |
7862
pip install .
7963
64+
# ── generate test outputs (moved earlier, most fragile step) ──
8065
- name: Run tests to generate output files
66+
id: run_tests
8167
run: |
8268
echo "Running test suite to generate NetCDF outputs..."
69+
echo "Using --basetemp=tmp/pytest_basetemp to preserve pytest temp artifacts"
8370
echo ""
8471
8572
echo "=========================================="
8673
echo "Running CMIP6 basic tests..."
8774
echo "=========================================="
88-
pytest fremorizer/tests/test_cmor_run_subtool.py -v || true
75+
pytest fremorizer/tests/test_cmor_run_subtool.py -v \
76+
--basetemp=tmp/pytest_basetemp || true
8977
9078
echo ""
9179
echo "=========================================="
9280
echo "Running extended test examples..."
9381
echo "=========================================="
94-
pytest fremorizer/tests/test_cmor_run_subtool_further_examples.py -v || true
82+
pytest fremorizer/tests/test_cmor_run_subtool_further_examples.py -v \
83+
--basetemp=tmp/pytest_basetemp || true
9584
9685
echo ""
9786
echo "Test execution complete."
98-
continue-on-error: true
9987
88+
# ── gather and categorize outputs ──
10089
- name: Gather test outputs into centralized directory
10190
id: gather_outputs
10291
run: |
@@ -115,6 +104,44 @@ jobs:
115104
echo "cmip7_count=${cmip7_files}" >> $GITHUB_OUTPUT
116105
echo "other_count=${other_files}" >> $GITHUB_OUTPUT
117106
107+
echo ""
108+
echo "Summary: total=${total_files} cmip6=${cmip6_files} cmip7=${cmip7_files} other=${other_files}"
109+
110+
- name: Verify outputs were gathered
111+
if: steps.gather_outputs.outputs.file_count == '0'
112+
run: |
113+
echo "::warning::No NetCDF files were found after running tests"
114+
echo "This may indicate that tests did not run successfully or outputs were not generated"
115+
echo ""
116+
echo "Checking known test output directories for debugging..."
117+
echo "--- fremorizer/tests/test_files/outdir ---"
118+
find fremorizer/tests/test_files/outdir -name "*.nc" -type f 2>/dev/null || echo "(empty or missing)"
119+
echo "--- fremorizer/tests/test_files/outdir_ppan_only ---"
120+
find fremorizer/tests/test_files/outdir_ppan_only -name "*.nc" -type f 2>/dev/null || echo "(empty or missing)"
121+
echo "--- tmp/pytest_basetemp ---"
122+
find tmp/pytest_basetemp -name "*.nc" -type f 2>/dev/null || echo "(empty or missing)"
123+
124+
# ── install cc-plugin-wcrp (after tests, since it's not needed until now) ──
125+
- name: Install cc-plugin-wcrp
126+
if: steps.gather_outputs.outputs.file_count != '0'
127+
run: |
128+
pip install cc-plugin-wcrp
129+
130+
- name: Configure esgvoc controlled vocabularies
131+
if: steps.gather_outputs.outputs.file_count != '0'
132+
run: |
133+
esgvoc config add cordex-cmip6
134+
esgvoc config add cmip7
135+
esgvoc config set project:branch=esgvoc
136+
esgvoc install
137+
138+
- name: Verify cc-plugin-wcrp installation
139+
if: steps.gather_outputs.outputs.file_count != '0'
140+
run: |
141+
echo "Listing available compliance-checker plugins..."
142+
compliance-checker -l
143+
144+
# ── run WCRP compliance checks ──
118145
- name: Run WCRP compliance checks on CMIP6 outputs
119146
if: steps.gather_outputs.outputs.cmip6_count != '0'
120147
run: |
@@ -190,6 +217,7 @@ jobs:
190217
fi
191218
done
192219
220+
# ── reports and artifacts ──
193221
- name: Generate summary report
194222
if: steps.gather_outputs.outputs.file_count != '0'
195223
run: |
@@ -227,9 +255,3 @@ jobs:
227255
name: wcrp-compliance-reports
228256
path: tmp/wcrp_compliance_reports/
229257
retention-days: 30
230-
231-
- name: Check if any files were tested
232-
if: steps.gather_outputs.outputs.file_count == '0'
233-
run: |
234-
echo "::warning::No NetCDF files were found to check for WCRP compliance"
235-
echo "This may indicate that tests did not run successfully or outputs were not generated"

0 commit comments

Comments
 (0)