diff --git a/.github/workflows/CI-unittests.yml b/.github/workflows/CI-unittests.yml index 9e01717163..b2c1499657 100644 --- a/.github/workflows/CI-unittests.yml +++ b/.github/workflows/CI-unittests.yml @@ -21,7 +21,44 @@ on: types: [published] jobs: + check_unit_test_files: + runs-on: ubuntu-latest + + defaults: + run: + shell: bash -leo pipefail {0} + + steps: + - name: checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Python setup + uses: actions/setup-python@v6 + with: + python-version: "3.12" + check-latest: true + + - name: Check unit test files exist + run: | + python - <<'PY' + from pathlib import Path + src_root = Path("src/simtools") + test_root = Path("tests/unit_tests") + missing = [] + for path in src_root.rglob("*.py"): + rel = path.relative_to(src_root) + if path.name in {"__init__.py", "_version.py"} or rel.parts[0] == "applications": + continue + if not (test_root / rel.parent / f"test_{path.stem}.py").exists(): + missing.append(str(rel)) + if missing: + raise SystemExit("Modules without unit tests:\n" + "\n".join(sorted(missing))) + PY + unit_tests: + needs: check_unit_test_files runs-on: ${{ matrix.os }} strategy: fail-fast: false diff --git a/docs/changes/2193.maintenance.md b/docs/changes/2193.maintenance.md new file mode 100644 index 0000000000..62bd813d0f --- /dev/null +++ b/docs/changes/2193.maintenance.md @@ -0,0 +1 @@ +Add CI tests to ensure that every simtools Python module has a corresponding unit test module. diff --git a/tests/unit_tests/configuration/test_defaults.py b/tests/unit_tests/configuration/test_defaults.py new file mode 100644 index 0000000000..c105c4019d --- /dev/null +++ b/tests/unit_tests/configuration/test_defaults.py @@ -0,0 +1,23 @@ +import simtools.configuration.defaults as defaults + + +def test_corsika_defaults(): + """Test default CORSIKA configuration constants.""" + assert defaults.CORSIKA_PATH == "/workdir/simulation_software/corsika7" + assert ( + defaults.CORSIKA_INTERACTION_TABLE_PATH + == "/workdir/external/simpipe/simulation_software/corsika7-interaction-tables/interaction-tables/" + ) + assert defaults.CORSIKA_HE_INTERACTION == "epos" + assert defaults.CORSIKA_LE_INTERACTION == "urqmd" + + +def test_simulation_software_defaults(): + """Test simulation software default values.""" + assert defaults.CURVED_ATMOSPHERE_MIN_ZENITH_ANGLE_DEG == 65 + assert defaults.SIMULATION_SOFTWARE_CHOICES == ( + "corsika", + "sim_telarray", + "corsika_sim_telarray", + ) + assert defaults.SIMULATION_SOFTWARE_DEFAULT == "corsika_sim_telarray" diff --git a/tests/unit_tests/production_configuration/test_calculate_statistical_uncertainties_grid.py b/tests/unit_tests/production_configuration/test_calculate_statistical_uncertainties_grid_point.py similarity index 100% rename from tests/unit_tests/production_configuration/test_calculate_statistical_uncertainties_grid.py rename to tests/unit_tests/production_configuration/test_calculate_statistical_uncertainties_grid_point.py