From 6061efcabd15400251aee3d0ae5bba1d392a59b7 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Thu, 8 Jan 2026 16:52:50 +0000 Subject: [PATCH 01/16] free two r deps --- environment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index bb0e313b4d..fb821509f3 100644 --- a/environment.yml +++ b/environment.yml @@ -123,5 +123,5 @@ dependencies: - r-yaml # R packages needed for development - r-git2r # dependency of lintr - - r-lintr ==3.1.2 - - r-styler ==1.10.3 + - r-lintr + - r-styler From 16e8c6b98e8f7af40d990e7f3d17735220fcb1d1 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Thu, 8 Jan 2026 16:52:59 +0000 Subject: [PATCH 02/16] run GHA --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f3ab374432..b692e206f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,7 @@ on: push: branches: - main + - free_some_deps schedule: - cron: "0 0 * * *" From fb39f5fafe3f000454ccb106f4933d247d2eb1fb Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Fri, 9 Jan 2026 13:42:11 +0000 Subject: [PATCH 03/16] pin r-base --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index fb821509f3..5b41a94995 100644 --- a/environment.yml +++ b/environment.yml @@ -96,7 +96,7 @@ dependencies: # R and dependencies - cdo - - r-base >=3.5 + - r-base >=4.4 - r-abind - r-akima - r-climdex.pcic From 7df166906ae0c09dbeb035be39fdc3ed8b097f41 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Mon, 19 Jan 2026 13:03:43 +0000 Subject: [PATCH 04/16] remove lintr and styler and dep for R env --- environment.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/environment.yml b/environment.yml index 5b41a94995..78cce2bad4 100644 --- a/environment.yml +++ b/environment.yml @@ -121,7 +121,3 @@ dependencies: - r-spei - r-udunits2 - r-yaml - # R packages needed for development - - r-git2r # dependency of lintr - - r-lintr - - r-styler From 7de30def999d1747e661c6e38672145b19faedbc Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Mon, 19 Jan 2026 13:04:40 +0000 Subject: [PATCH 05/16] re-turn on R linting via pre-commit --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a16e16fbca..e58c301dbd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,11 +42,11 @@ repos: # entry: nclcodestyle # language: system # files: '\.(ncl|NCL)$' - # - repo: https://github.com/lorenzwalthert/precommit/ # Checks for R - # rev: 'v0.4.2' - # hooks: - # - id: style-files # styler - # - id: lintr + - repo: https://github.com/lorenzwalthert/precommit/ # Checks for R + rev: 'v0.4.2' + hooks: + - id: style-files # styler + - id: lintr # - repo: https://github.com/codespell-project/codespell # rev: 'v2.3.0' # hooks: From d26a66fdc8788a7ec375fd79086539cd7e9d30c5 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Mon, 19 Jan 2026 13:14:31 +0000 Subject: [PATCH 06/16] skip precommit run in OSX --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b692e206f8..7084ef753f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -102,8 +102,6 @@ jobs: run: conda list - name: Check dependencies are compatible run: pip check - - name: Check code quality - run: pre-commit run -a - name: Run tests run: pytest -n 2 -m "not installation" 2>&1 | tee test_osx_artifacts_python_${{ matrix.python-version }}/test_report.txt - name: Upload artifacts From 70430d4c7e8a630f625724b863b7c7ca49a4e924 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Mon, 19 Jan 2026 13:29:39 +0000 Subject: [PATCH 07/16] try 0.3.2 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e58c301dbd..5f61813c64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: # language: system # files: '\.(ncl|NCL)$' - repo: https://github.com/lorenzwalthert/precommit/ # Checks for R - rev: 'v0.4.2' + rev: 'v0.3.2' hooks: - id: style-files # styler - id: lintr From 4cdb832b6f9b9d844f17859cf39bf2e1802d94b5 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Mon, 19 Jan 2026 13:37:23 +0000 Subject: [PATCH 08/16] 0.3.2 is too old, trying 0.4.0 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f61813c64..971b1bcfbd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: # language: system # files: '\.(ncl|NCL)$' - repo: https://github.com/lorenzwalthert/precommit/ # Checks for R - rev: 'v0.3.2' + rev: 'v0.4.0' hooks: - id: style-files # styler - id: lintr From a08ca4fd817eb32c81fe41fb161a0c5860105b90 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Mon, 19 Jan 2026 13:43:05 +0000 Subject: [PATCH 09/16] keep 0.4.0 but turn off lintr --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 971b1bcfbd..67c6230c59 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,7 +46,7 @@ repos: rev: 'v0.4.0' hooks: - id: style-files # styler - - id: lintr + # - id: lintr # - repo: https://github.com/codespell-project/codespell # rev: 'v2.3.0' # hooks: From a2c5d63cfe354d3c901fa912e9a64ff6df96fa0a Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Wed, 21 Jan 2026 15:08:25 +0000 Subject: [PATCH 10/16] bring back pre-commit config file to original state --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 67c6230c59..a16e16fbca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,11 +42,11 @@ repos: # entry: nclcodestyle # language: system # files: '\.(ncl|NCL)$' - - repo: https://github.com/lorenzwalthert/precommit/ # Checks for R - rev: 'v0.4.0' - hooks: - - id: style-files # styler - # - id: lintr + # - repo: https://github.com/lorenzwalthert/precommit/ # Checks for R + # rev: 'v0.4.2' + # hooks: + # - id: style-files # styler + # - id: lintr # - repo: https://github.com/codespell-project/codespell # rev: 'v2.3.0' # hooks: From 88f3e410bb308b76514e0415e8cf0892869b0d53 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Wed, 21 Jan 2026 15:17:12 +0000 Subject: [PATCH 11/16] add to docs --- doc/sphinx/source/community/code_documentation.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/sphinx/source/community/code_documentation.rst b/doc/sphinx/source/community/code_documentation.rst index 82bd72dbfb..7aa5bb9864 100644 --- a/doc/sphinx/source/community/code_documentation.rst +++ b/doc/sphinx/source/community/code_documentation.rst @@ -274,12 +274,11 @@ R ~ Best practices for R code are described in `The tidyverse style -guide `__. We check adherence to this -style guide by using -`lintr `__ on -CircleCI. Please use `styler `__ to -automatically format your code according to this style guide. In the -future we would also like to make use of +guide `__. We currently don't check adherence +to this, but we strongly encourage any new R diagnostic to be checked against the +style guide by using `lintr `__. +Please use `styler `__ to automatically format your code according +to this style guide. In the future we would also like to make use of `goodpractice `__ to assess the quality of R code. From 605fe08d2c9cda1c9ba60692ae40cc48aca43a48 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Wed, 21 Jan 2026 15:49:59 +0000 Subject: [PATCH 12/16] turn off lintr test in linux too --- tests/unit/test_lint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_lint.py b/tests/unit/test_lint.py index afaf3ae730..fc652db24f 100644 --- a/tests/unit/test_lint.py +++ b/tests/unit/test_lint.py @@ -51,8 +51,8 @@ def test_nclcodestyle(): @pytest.mark.installation @pytest.mark.skipif( - sys.platform == "darwin", - reason="ESMValTool R not supported on OSX", + sys.platform == "darwin" or sys.platform == "linux", + reason="ESMValTool R not supported on OSX; turned off on Linux", ) def test_r_lint(monkeypatch): """Test R lint.""" From fdddae6c562945b129c5caf40274e3b7ee1daf9f Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Thu, 22 Jan 2026 11:25:35 +0100 Subject: [PATCH 13/16] Remove outdated test Update docs Re-enable pre-commit in GHA --- .github/workflows/test.yml | 2 ++ .../source/community/code_documentation.rst | 20 ++++++++++- tests/unit/test_lint.py | 36 ------------------- 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7084ef753f..6ad3d824ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,6 +50,8 @@ jobs: run: conda list - name: Check dependencies are compatible run: pip check + - name: Check code quality + run: pre-commit run -a - name: Check NCL run: ncl -V - name: Check code quality diff --git a/doc/sphinx/source/community/code_documentation.rst b/doc/sphinx/source/community/code_documentation.rst index 7aa5bb9864..f7d62816a5 100644 --- a/doc/sphinx/source/community/code_documentation.rst +++ b/doc/sphinx/source/community/code_documentation.rst @@ -278,7 +278,25 @@ guide `__. We currently don't check adherence to this, but we strongly encourage any new R diagnostic to be checked against the style guide by using `lintr `__. Please use `styler `__ to automatically format your code according -to this style guide. In the future we would also like to make use of +to this style guide. To run these tools, uncomment these lines: + +.. literalinclude:: ../../../../.pre-commit-config.yaml + :language: yaml + :start-at: # - repo: https://github.com/lorenzwalthert/precommit/ # Checks for R + :end-at: - id: lintr + +and run the commands: + +.. code-block:: bash + + pre-commit run style-files --files esmvaltool/diag_scripts/your_script.R + pre-commit run lintr --files esmvaltool/diag_scripts/your_script.R + +These pre-commit hooks have been disabled by default because over the past few +years all diagnostics that have been contributed were written in Python. +However, if R contributions pick up again, we would be happy to enable these +pre-commit hooks again. +In the future we would also like to make use of `goodpractice `__ to assess the quality of R code. diff --git a/tests/unit/test_lint.py b/tests/unit/test_lint.py index fc652db24f..296bea0197 100644 --- a/tests/unit/test_lint.py +++ b/tests/unit/test_lint.py @@ -1,13 +1,8 @@ """Lint tests.""" -import os -import subprocess -import sys import textwrap from pathlib import Path -import pytest - import esmvaltool from esmvaltool.utils.nclcodestyle import nclcodestyle @@ -47,34 +42,3 @@ def test_nclcodestyle(): ) assert success, "Your NCL code does not follow our formatting standards." - - -@pytest.mark.installation -@pytest.mark.skipif( - sys.platform == "darwin" or sys.platform == "linux", - reason="ESMValTool R not supported on OSX; turned off on Linux", -) -def test_r_lint(monkeypatch): - """Test R lint.""" - monkeypatch.setenv("LINTR_COMMENT_BOT", "FALSE") - package_root = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - checker = os.path.join(package_root, "tests", "unit", "check_r_code.R") - try: - output = subprocess.check_output( - ("Rscript", checker, package_root), - stderr=subprocess.STDOUT, - universal_newlines=True, - ) - print(output) - return - except subprocess.CalledProcessError as ex: - print( - textwrap.dedent(""" - Your R code does not follow our formatting standards. - - Please fix the following issues: - """), - ) - print(ex.output) - - assert False, "Your R code does not follow our formatting standards." From ffa8401ff6a7fad454343dda722ec2fcca8de5c4 Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Thu, 22 Jan 2026 11:27:02 +0100 Subject: [PATCH 14/16] Move pre-commit run to the right place --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ad3d824ee..b692e206f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,8 +50,6 @@ jobs: run: conda list - name: Check dependencies are compatible run: pip check - - name: Check code quality - run: pre-commit run -a - name: Check NCL run: ncl -V - name: Check code quality @@ -104,6 +102,8 @@ jobs: run: conda list - name: Check dependencies are compatible run: pip check + - name: Check code quality + run: pre-commit run -a - name: Run tests run: pytest -n 2 -m "not installation" 2>&1 | tee test_osx_artifacts_python_${{ matrix.python-version }}/test_report.txt - name: Upload artifacts From 6952ee3cfa494d0a80489ba27baed7c7b9f7296e Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Thu, 22 Jan 2026 13:06:24 +0000 Subject: [PATCH 15/16] unrun GHA tests --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b692e206f8..f3ab374432 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,6 @@ on: push: branches: - main - - free_some_deps schedule: - cron: "0 0 * * *" From 2f0d750d8c83435b02659c1e31df7412e38c13e0 Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Thu, 22 Jan 2026 14:46:59 +0100 Subject: [PATCH 16/16] Add caption --- doc/sphinx/source/community/code_documentation.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/sphinx/source/community/code_documentation.rst b/doc/sphinx/source/community/code_documentation.rst index f7d62816a5..819cc3371c 100644 --- a/doc/sphinx/source/community/code_documentation.rst +++ b/doc/sphinx/source/community/code_documentation.rst @@ -284,6 +284,7 @@ to this style guide. To run these tools, uncomment these lines: :language: yaml :start-at: # - repo: https://github.com/lorenzwalthert/precommit/ # Checks for R :end-at: - id: lintr + :caption: R configuration in ``.pre-commit-config.yaml``. and run the commands: