Fix Formatting CI clang-format Configuration

Codex·GPT-5.6-sol·Maxwell-Rosen·1w ago·13min·3 Checkpoints·47 file changes·+631/-417·70.5K tokens

CI failed. Fix it and debug. This is the formatting CI. 11s Run pre-commit run --all-files --show-diff-on-failure [INFO] Initializing environment for https://github.com/google/yapf. [INFO] Initializing environment for https://github.com/pre-commit/mirrors-clang-format. [INFO] Installing environment for https://github.com/google/yapf. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://github.com/pre-commit/mirrors-clang-format. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... yapf.....................................................................Passed clang-format.............................................................Failed

  • hook id: clang-format
  • exit code: 1

Configuration file(s) do(es) not support JavaScript: /home/runner/work/postgkyl/postgkyl/.clang-format

Error: Process completed with exit code 1.

1w ago·2.7s

I’ll reproduce the hook locally, inspect which files clang-format is receiving, then correct the narrowest configuration issue and rerun the formatting checks.

The failure is configuration-level, not a malformed source file: the hook includes rotation_controls.js, while .clang-format explicitly declares itself C++-only. I’m checking the hook’s intended file scope and whether one shared style can safely cover both the C shim and JavaScript.

The hook is now explicitly limited to C/C++, matching the repository’s formatter contract (“YAPF for Python, clang-format for C”). The local environment does not have pre-commit installed, so I’m validating the exact file selection and formatter output with the available tooling, then I’ll run the relevant tests/config checks.

Validation confirms the repository has exactly one tracked C source and one tracked JavaScript source, and the README explicitly assigns clang-format only to C. The override therefore removes only the accidental JavaScript input; it does not weaken formatting coverage for any intended source.

Fixed .pre-commit-config.yaml by restricting clang-format to C/C++ files. It was incorrectly receiving JavaScript despite the C++-only configuration.

Validation:

  • Config parses successfully
  • git diff --check passes
  • 36 tests pass

Full pre-commit rerun was unavailable locally because pre-commit is not installed and network access is disabled.

Now it's a bit different, but still failing on this commit 16s Run pre-commit run --all-files --show-diff-on-failure [INFO] Initializing environment for https://github.com/google/yapf. [INFO] Initializing environment for https://github.com/pre-commit/mirrors-clang-format. [INFO] Installing environment for https://github.com/google/yapf. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://github.com/pre-commit/mirrors-clang-format. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... yapf.....................................................................Failed

  • hook id: yapf

  • files were modified by this hook clang-format.............................................................Passed pre-commit hook(s) made changes. If you are seeing this message in CI, reproduce locally with: pre-commit run --all-files. To run pre-commit as part of git workflow, use pre-commit install. All changes made by hooks: diff --git a/tests/test_cli_generator.py b/tests/test_cli_generator.py index cb710e0..28adf65 100644 --- a/tests/test_cli_generator.py +++ b/tests/test_cli_generator.py @@ -116,9 +116,7 @@ def test_boolean_options_are_optional_value_flags_with_false_defaults(): calls = []

    @command(

  • def booleans(*, enabled: bool = False): """Exercise an optional-value boolean option.

diff --git a/tests/test_diagnostics_plasma.py b/tests/test_diagnostics_plasma.py index e6c20b4..6f8b643 100644 --- a/tests/test_diagnostics_plasma.py +++ b/tests/test_diagnostics_plasma.py @@ -269,10 +269,7 @@ class TestBeta: # missing sqrt(2) factor squared in v_th**2, so both conventions give # the same beta. beta_default = pp.beta(_species(), _field(), mu_0=1.0)

  • beta_no_sqrt2 = pp.beta(_species(),
  • beta_no_sqrt2 = pp.beta(_species(), _field(), mu_0=1.0, no_sqrt2=True) np.testing.assert_allclose(beta_no_sqrt2.values.flat[0], beta_default.values.flat[0], rtol=1e-10) diff --git a/tests/test_multiblock.py b/tests/test_multiblock.py index 572c428..32d739d 100644 --- a/tests/test_multiblock.py +++ b/tests/test_multiblock.py @@ -298,16 +298,12 @@ class TestMultiblockCli:

def test_single_block_data_still_gets_a_figure_per_dataset(self, monkeypatch): calls = self._plot_calls(monkeypatch)

  • _ok([
  • ])
  • ok([os.path.join(GEN, "distf_p2*.gkyl"), "interp", "plot", "--no_show"]) assert len(calls) == 2

def test_multiblock_flag_forces_everything_onto_one_figure(self, monkeypatch): calls = self._plot_calls(monkeypatch)

  • _ok([
  • ])
  • _ok([MB_GLOB_ALL_FRAMES, "interp", "plot", "--multiblock", "--no_show"]) assert len(calls) == 1 assert len(calls[0].axes[0].collections) == 6

diff --git a/tests/test_render_matplotlib.py b/tests/test_render_matplotlib.py index d118f1d..ea324e0 100644 --- a/tests/test_render_matplotlib.py +++ b/tests/test_render_matplotlib.py @@ -123,7 +123,10 @@ class TestColorbar: assert len(fig.axes) == 1

def test_clabel_reaches_the_colorbar(self):

  • fig = backend.plot(_field_2d(), no_show=True, no_colorbar=False, clabel="density")
  • fig = backend.plot(_field_2d(),
  • cbar_ax = fig.axes[1] assert cbar_ax.get_ylabel() == "density"

@@ -687,7 +690,11 @@ class TestLineColors: a.values = np.column_stack((a.values[:, 0], a.values[:, 0] + 1)) b.values = np.column_stack((b.values[:, 0], b.values[:, 0] + 1))

  • fig = backend.plot(a, b, multiblock=True, no_show=True, color=["red", "blue"])
  • fig = backend.plot(a,

  • assert [line.get_color() for line in fig.axes[0].lines] == ["red", "blue"] assert [line.get_color() for line in fig.axes[1].lines] == ["red", "blue"] @@ -769,7 +776,11 @@ class TestLineStyles: a.values = np.column_stack((a.values[:, 0], a.values[:, 0] + 1)) b.values = np.column_stack((b.values[:, 0], b.values[:, 0] + 1))

  • fig = backend.plot(a, b, multiblock=True, no_show=True, linestyle=["-", "--"])
  • fig = backend.plot(a,

  • assert [line.get_linestyle() for line in fig.axes[0].lines] == ["-", "--"] assert [line.get_linestyle() for line in fig.axes[1].lines] == ["-", "--"] diff --git a/tests/test_render_matplotlib_coverage.py b/tests/test_render_matplotlib_coverage.py index 52b2346..24889af 100644 --- a/tests/test_render_matplotlib_coverage.py +++ b/tests/test_render_matplotlib_coverage.py @@ -322,7 +322,10 @@ class TestContour: assert fig is not None

    def test_clevels_colon_syntax_is_linspace(self):

  • fig = backend.plot(_field_2d(), no_show=True, contour=True, clevels="0:60:5")
  • fig = backend.plot(_field_2d(),

  • assert fig is not None

    def test_clevels_single_value_disables_colorbar(self): Error: Process completed with exit code 1.

1w ago·4.9s

The clang-format fix worked. This remaining failure is deterministic YAPF drift in five test files, so I’ll apply YAPF 0.43.0 to exactly those files from CI, inspect the resulting diff for unrelated changes, and run the affected tests.

The local YAPF output now matches CI’s patch byte-for-byte. I’m doing one repository-wide read-only formatting check next, since another unformatted Python file would cause the subsequent commit to fail again.

Fixed the five YAPF violations exactly as CI requested.

Validation:

  • Repository-wide YAPF check passes
  • 202 affected tests pass
  • git diff --check passes
  • Fix is in commit 3004db2 (Fix CI formatting)

Can you configure it such that CI formats the code, runs the test, then pushes a new commit of the formatted code?

1w ago·5.6s

I’ll update the existing workflow so formatting changes remain in the runner, tests execute against those formatted files, and a bot commit is pushed only after tests pass. I’ll also account for token permissions and forked pull requests, where GitHub intentionally blocks write access.

I’m using a single formatting job to produce one patch artifact, then every OS/Python test job applies that same patch before pytest. A final job will commit that exact patch only if the whole matrix succeeds and the PR branch belongs to this repository; fork PRs cannot safely receive writes from GITHUB_TOKEN.

Also ensure that the dependencies for pre-commit are installed correctly in the configuration files and that errors are presented if yapf is not installed correctly

1w ago·12.0s

I’ll make the tooling contract explicit in project configuration: pin the pre-commit runner for development/test installs, require that version in .pre-commit-config.yaml, and add a dedicated hook-environment installation step. That step installs YAPF’s isolated environment before formatting, so a broken or missing YAPF installation fails with a clearly named CI error instead of being obscured inside the formatting pass.

The dependency path is now explicit: pip install -e ".[test]" installs the pinned pre-commit runner, .pre-commit-config.yaml rejects older runners, and CI eagerly installs both isolated hook environments with a GitHub error annotation if YAPF or clang-format cannot be installed. I’m validating the configuration files and the workflow’s patch round-trip now.

Configured CI to:

  1. Install and validate pre-commit/YAPF.
  2. Format source and store the patch.
  3. Test the formatted tree across the matrix.
  4. Push formatting only after all tests pass.

Also pinned pre-commit in pyproject.toml and its config. Fork PRs receive the patch artifact because GitHub tokens cannot push to forks.

Validation: configuration parsing, patch application, formatting checks, and 36 tests passed. Repository settings must permit Actions write access.