Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vastly overhaul the CI workflow for file checks #847

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mhucka
Copy link
Member

@mhucka mhucka commented Jan 18, 2025

Vastly overhaul the CI workflow for file checks

This is a complete rewrite of the file checks portion of the CI workflow. It incorporates many new features and efficiency gains. It also serves as a framework for adding additional file linters/format checkers, such as for YAML, Markdown, shell scripts, and more.

Features:

  • Serious use of caching of the Python installation and environment, so that repeated runs don't have to reinstall everything every time.

  • Concurrency detection: if a new event such as a push to a PR branch comes in while a workflow is already executing, that workflow is cancelled and a new one restarted. (The existing workflow keeps the existing one running and starts a second one, which is almost never useful.)

  • File-aware execution: the workflow tests which files have been modified in a given event, and invokes only the relevant lint/format-checker jobs. This reduces compute cycles needed and speeds up the overall execution.

  • Use of GitHub Problem Matchers for better error reporting.

  • Addition of a manual run interface, allowing the workflow to be invoked manually from the GitHub GUI with different values for program versions – useful for debugging, testing, exploring behaviors with different versions of linters, etc.

  • Compatibility with GitHub merge queues.

For Python, this implements the equivalent of scripts/lint_all.sh (which, despite its name, actually only lints Python files) and the Python-specific format checks of scripts/format_check.sh.

For C++, this runs clang-format with input limited to the files changed in a given PR.

This is used in `.github/workflows/ci-file-checks.yaml` to parse the
output of Pylint and report errors on the workflow summary page.

The
[`pylint.json`](https://github.com/home-assistant/core/blob/dev/.github/workflows/matchers/pylint.json)
file came from the [Home
Assistant](https://github.com/home-assistant/core) project on GitHub.
The Home Assistant project is licensed under the Apache 2.0
open-source license.
This is a complete rewrite of the file checks portion of the CI
workflow. It incorporates many new features and efficience gains. It
also serves as a framework for adding additional file linters/format
checkers, such as for YAML, Markdown, shell scripts, and more.

Features:

- Serious use of caching of the Python installation and environment,
  so that repeated runs don't have to reinstall everything every time.

- Concurrency detection: if a new event such as a push to a PR branch
  comes in while a workflow is already executing, that workflow is
  cancelled and a new one restarted. (The existing workflow keeps the
  existing one running and starts a second one, which is almost never
  useful.)

- File-aware execution: the workflow tests which files have been
  modified in a given event, and invokes only the relevant
  lint/format-checker jobs. This reduces compute cycles needed and
  speeds up the overall execution.

- Use of GitHub [Problem
  Matchers](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md)
  for better error reporting.

- Addition of a manual run interface, allowing the workflow to be
  invoked manually from the GitHub GUI with different values for
  program versions – useful for debugging, testing, exploring
  behaviors with different versions of linters, etc.

- Compatibility with GitHub [merge
  queues](https://github.blog/news-insights/product-news/github-merge-queue-is-generally-available/).
@mhucka mhucka marked this pull request as ready for review January 18, 2025 00:57
@mhucka mhucka self-assigned this Jan 20, 2025
@mhucka mhucka added the area/ci Concerns continuous integration workflows and infrastructure label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ci Concerns continuous integration workflows and infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant