swift-format is available in the Xcode 16 Beta and homebrew.
We will need some extra docs to tell Linux developers how to get it on
their distribution.
This also makes use of the fact that you can pass git diff a colon
delimited pattern to include ':*pattern' or exclude ':!*pattern'
matching files, which is pretty neat.
This adds a new script for linting WebIDL files, and adds it to the set
of scripts Meta/lint-ci.sh runs. Initially, this script does just one
thing: normalizes IDL definition lines so they start with four spaces.
This script only checks Tests/AK, and verifies that all source files
that match Tests/AK/*.cpp are listed in the CMakeLists.txt.
This is a bit excessive. We don't have this check for any other test
files. This sort of error will definitely ™️ be caught in review.
When markdown-check is built, it outputs hundreds of lines of "ignoring
this and that link because reasons". This is extremely not helpful when
trying to figure out exactly which check failed on your commit. Also
remove the timing numbers from lint-ci.sh These are just noise and also
don't help to figure out which pre-commit check failed. Ideally the
output on fail should be "[OK]: Check A" for all the passing checks and
"[FAIL] Check N" with the required context for the failed check.
On macOS, CMake incorrectly tries to add and/or remove rpaths from files
that it has already processed when it performs installation. Setting the
rpaths during the build process ensures that they are only set once, and
as a bonus, makes installation slightly more performant.
Fixes#10055.
Some systems don't have /usr/bin/time available, and during most runs
of lint-ci we don't actually care that much about the exact timing.
Therefore, let's just remove it. It's easy enough to add back in, if
someone wants to investigate an issue.
I totally overlooked that /usr/bin/time is not universal, which broke
some systems. This commit instead calls 'time', allowing either a shell
built-in to kick in, or a (potentially different) binary be found
anywhere in the PATH.
This was apparently never used by anyone except me, and currently
fails silently.
The script originally allowed easy inspection of potentially missing
resources, but that seems no longer useful. Even after restoring the
script to a working state, I found nothing with it.
A somewhat usable version might be available at
https://github.com/BenWiederhake/serenity/tree/historic/lint-missing-resources.sh
However, there seems to be no interest in the script, so it is better to
remove it.
Verifies that emoji filenames:
- Contain only uppercase letters, numbers, +, and _
- Use _ and a separator between codepoints, not +
- Do not include the U+FE0F emoji presentation specifier
This uses optipng to check how much size can be reduced on PNG files. If
that's more than 2 KiB for at least one file, the check fails. As with
other checks, it doesn't run if optipng is not installed.
Now that the GML formatter is both perserving comments and also mostly
agrees to the existing GML style, it can be used to auto-format all the
GML files in the system. This commit does not only contain the scripts
for running the formatting on CI and the pre-commit hook, but also
initially formats all the existing GML files so that the hook is
successfull.
On my machine, this script took about 3.4 seconds, and was responsible
for essentially all of the time taken by the precommit hook.
The script is a faithful 1:1 reimplementation, even the regexes are
identical. And yet, it takes about 0.02 seconds, making the pre-commit
hook lightning fast again. Apparently python is just faster in this
case.
Fun fact:
- Just reading all ~4000 files took bash about 1.2 seconds
- Checking the license took another 1.8 seconds in total
- Checking for math.h took another 0.4 seconds in total
- Checking for '#pragma once' took another 0.4 seconds in total
The timing is highly load-dependent, so they don't exactly add up to 3.4
seconds. However, it's good enough to determine that bash is no longer
fit for the purpose of this script.
Most of the existing lint-ing shell scripts have the ability
to only run on the files which have actually changed.
The new port lint-ing script doesn't have this functionality
unfortunately. This forces us to lint ALL the ports on every
single change to any other file in the system if you have
the pre-commit hook setup for your git clone locally.
Instead we can use pre-commit's feature to only run a hook
if certain files have changed to reduce the situations in
which we would run the Meta/lint-ports.py script.
The bash version takes around 15 seconds to run; that is way too slow.
This python3 version should take less than one second to run. :^)
Also, the script will now also check .py files and .txt CMake files.
This should speed up pre-commit a bit as only files that are staged will
be processed, and clang-format and shellcheck are only invoked once, not
for every file. When no arguments are given (e.g. on CI), it still uses
'git ls-files'.
Problem:
- The first lint check that fails results in all subsequent checks not
being run.
Solution:
- Run all the lint checks aggregating the number of failures.
- Return a non-0 exit code if any have failed.
Problem:
- It is possible for a new test file to be added to the `AK/Tests`
directory without being added to the corresponding
`CMakeLists.txt`. This results in the tests not being run.
Solution:
- As part of CI linting, verify that all the `AK/Tests/Test*.cpp`
files are mentioned in the `CMakeLists.txt`.