close
Skip to content

GitHub actions: run phpcs, ruff, and the Python tests on every PR#18

Open
jeherve wants to merge 6 commits intom:mainfrom
jeherve:add/ci-phpcs-ruff-python-tests
Open

GitHub actions: run phpcs, ruff, and the Python tests on every PR#18
jeherve wants to merge 6 commits intom:mainfrom
jeherve:add/ci-phpcs-ruff-python-tests

Conversation

@jeherve
Copy link
Copy Markdown
Contributor

@jeherve jeherve commented Apr 8, 2026

Today there's no automated gate on pull requests; a reviewer has to remember to run phpcs, ruff, and the unittest suite by hand. This PR adds a GitHub Actions workflow that runs all three in parallel on every PR, so regressions get caught mechanically and human review can focus on intent rather than style.

What's in here

  • A new .github/workflows/ci.yml with three jobs: phpcs, ruff, and python-tests. They run in parallel with no dependency chain, so a phpcs failure doesn't hide Python feedback and vice versa.
  • The workflow runs on every PR.
  • A minimal pyproject.toml at the repo root so local ruff check produces the same output as CI. Python 3.12 target, 100-character lines, pycodestyle + pyflakes + import sorting.
  • A cleanup pass on the 19 ruff violations that surfaced the first time I ran the new config. All mechanical: import ordering, trailing whitespace on blank lines, and a handful of over-long lines wrapped by extracting a local or splitting a string literal. No behavior changes; the unittest suite still passes 83/83.

Of note

  • PHP 8.4 and Python 3.12, single versions only. phpcs is style-only so runtime version doesn't matter, and we can always add a matrix later if the need shows up.
  • Ruff runs with --output-format=github, which gets us inline PR annotations for free.
  • phpcs output stays in the Actions log. I considered piping it through cs2pr for inline annotations too, but that's a dependency I'd rather not introduce for a project this size.
  • Trigger is pull_request only, no push: main. Once branch protection is on, the merge commit on main came from a PR that already went green, so running CI a second time there just burns minutes.
  • No PHP test job yet; we don't have any PHP tests to run. That's a separate ticket.

Follow-up

We could then marking phpcs, ruff, and python-tests as required status checks in this repo's branch protection settings.

How I tested

I tested the workflow with a PR in my fork of this repo, and it was successful.

jeherve added 4 commits April 8, 2026 19:20
We're about to wire ruff into CI, and I want local runs to match what
CI will report. A pyproject.toml at the repo root is the simplest way
to get that; ruff picks it up automatically with no arguments.

The config is deliberately small: Python 3.12 target, 100-character
line length, and the pycodestyle, pyflakes, and import-sorting rule
groups. No custom ignores yet; we'll add them when a real violation
warrants it.
Running ruff against lib/ and tests/ for the first time surfaced 19
issues; none interesting, all mechanical. Fixing them now means the
new ci.yml ruff job will be green on the first run instead of landing
red and immediately needing a cleanup PR on top.

The fixes fall in three buckets: import ordering (handled by
ruff --fix), trailing whitespace on blank lines, and a handful of
lines over 100 characters that I wrapped by either extracting a local
variable or splitting a long string literal. No behavior changes;
the unittest suite still passes 83/83.
Until now there was no automated gate on pull requests; a reviewer had
to remember to run phpcs, ruff, and the unittest suite by hand. This
adds a GitHub Actions workflow that runs all three on every PR (and on
pushes to main, so the default branch status stays fresh).

Of note:

- Three parallel jobs, no dependency chain. A phpcs failure shouldn't
  hide Python feedback and vice versa.
- PHP 8.4 and Python 3.12, single versions only. phpcs is style-only
  so runtime version doesn't matter, and we can add a matrix later if
  the need shows up.
- Ruff runs with --output-format=github, which produces inline PR
  annotations for free.
- phpcs output stays in the Actions log. I considered piping it
  through cs2pr for inline annotations, but that adds a dependency
  I'd rather not introduce for a project this size.
- No PHP test job yet; we don't have any PHP tests to run. That's a
  separate ticket.

Marking the three jobs as required status checks is a one-time click
in branch protection settings, which I'll do after this merges.

Refs: ARC-1682
Once branch protection is on and everything lands through a PR, the
merge commit on main came from a PR that already went green. Running
CI a second time on that same SHA doesn't tell us anything new; it
just burns minutes. Leaving only pull_request as a trigger.

If someone ever needs to push directly to main, that's a branch
protection failure worth addressing at the source, not something CI
should paper over.
Comment thread .github/workflows/ci.yml Outdated
jeherve and others added 2 commits April 9, 2026 19:31
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
The previous commit indented the ruff-action step with 7 spaces
instead of 6, making GitHub reject the workflow with a YAML syntax
error. Also drop the setup-python step since ruff-action installs
ruff itself, and cache: pip would fail with no dependency file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants