42 Commits

Author SHA1 Message Date
Paolo Tranquilli
377fb00dea Merge branch 'main' into redsun82/cargo-upgrade-3 2025-06-23 12:26:15 +02:00
Paolo Tranquilli
5b4c566f06 Cargo: fix Cargo.lock file 2025-06-20 18:27:49 +02:00
Paolo Tranquilli
24cfc840a6 Merge branch 'main' into redsun82/mad-generator 2025-06-18 16:53:43 +02:00
Paolo Tranquilli
fe1e562f8d CI: fix python version
Turns out this is important for the black formatting tool to work
correctly. The formatting won't generally change between python versions
(it only depends on `black`'s version), but the formatted code needs to
be parseable by the system python version. One script uses
```python
def foo[T](x: T) -> T:
```
syntax, which is only supported in Python 3.12 and later.

Running `pre-commit` will now require a python 3.12 installation (which
is already what we mandate for internal developer environment setup).
The error in case of absence of such a version is pretty clear though.
2025-06-13 18:19:30 +02:00
Paolo Tranquilli
5df292c286 MaD generator: apply black formatting to all sources 2025-06-13 08:47:07 +02:00
Paolo Tranquilli
14d48e9d58 Add black pre-commit hook
This switched `codegen` from the `autopep8` formatting to the `black`
one, and applies it to `bulk_mad_generator.py` as well. We can enroll
more python scripts to it in the future.
2025-06-10 12:25:39 +02:00
Paolo Tranquilli
0b1f89a02e Rust: add ast-generator to pre-commit trigger of rust codegen 2025-03-31 13:11:45 +02:00
Paolo Tranquilli
c113503b41 Rust: fix doc typo 2024-12-03 15:18:17 +01:00
Paolo Tranquilli
95b32fb541 Pre-commit: bump up autopep8 check version and fix formatting 2024-09-16 14:03:48 +02:00
Paolo Tranquilli
38c25f96e5 Rust: add linting pre-commit hook 2024-09-10 10:22:45 +02:00
Paolo Tranquilli
d8f37cf1f9 Rust: add codegen pre commit hook 2024-09-09 12:05:28 +02:00
Paolo Tranquilli
7e1290aa74 Rust: reuse shared rust trap library 2024-08-30 16:08:37 +02:00
Paolo Tranquilli
3da6cee6ef Merge branch 'main' into rust-experiment 2024-08-30 10:30:43 +02:00
Paolo Tranquilli
590a146b49 Rust: some basic extraction of function names (with locations!) 2024-08-29 17:58:50 +02:00
Cornelius Riemenschneider
3ac8108c4a Address review. 2024-08-23 17:26:05 +02:00
Paolo Tranquilli
f125e732b0 Go: disable pre-commit hook 2024-05-13 09:27:35 +02:00
Paolo Tranquilli
5c74bebe6c Merge pull request #16317 from github/redsun82/go
Go: add bazel build
2024-05-06 16:55:58 +02:00
Paolo Tranquilli
92b3eda12d Bazel: move buildifier out of root BUILD
See https://github.com/github/codeql/pull/16428 for details as to why
this is necessary.
2024-05-06 16:00:05 +02:00
Paolo Tranquilli
ca2d94b297 Fix go pattern in .pre-commit-config.yaml 2024-05-02 15:15:45 +02:00
Paolo Tranquilli
c8b02241af Merge branch 'main' into redsun82/go 2024-04-26 15:59:17 +02:00
Paolo Tranquilli
19b2e56d02 Go: group BUILD and dbscheme generation target 2024-04-26 13:38:10 +02:00
Paolo Tranquilli
393f6b7666 Go: add gazelle-generated BUILD files 2024-04-25 08:53:26 +02:00
Paolo Tranquilli
9f5782b67b Bazel: introduce buildifier formatting
This introduces tooling and enforcement for formatting bazel files.

The tooling is provided as a bazel run target from
[keith/buildifier-prebuilt](https://github.com/keith/buildifier-prebuilt).

This is used in a [`pre-commit`](https://pre-commit.com/) hook for those
having that installed. In turn this is used in a CI check. Relying on a
`pre-commit` action gives us easy checking that buildifying did not
change anything in the files and printing the diff, without having to
hand-roll the check ourselves.

This enforcement will make usage of gazelle easier, as gazelle itself
might reformat files, even outside of `go`. Having them properly
formatted will allow gazelle to leave them unchanged, without needing
to configure awkward exclude directives.
2024-04-24 15:49:48 +02:00
Paolo Tranquilli
33b6ce7365 Swift: update formatting to clang-format 17.0.6
Also, added a format check in `swift.yml`.
2024-01-25 13:58:14 +01:00
Alex Denisov
d744b218f6 Misc: add bazel buildifer pre-commit hook 2023-06-30 13:07:04 +02:00
Paolo Tranquilli
6352399645 Swift: fix all upstream headers for C++20 2023-06-28 08:25:29 +02:00
Paolo Tranquilli
92197bf9f2 Codegen: fix autopep8 pre-commit hook 2023-03-29 15:57:45 +02:00
Paolo Tranquilli
cdd4e8021b Move swift/codegen to misc/codegen 2023-02-27 09:46:48 +01:00
Paolo Tranquilli
2cd58817d7 Swift: skip QL code generation on untouched files
This is a developer QoL improvement, where running codegen will skip
writing (and especially formatting) any files that were not changed.

**Why?** While code generation in itself was pretty much instant, QL
formatting of generated code was starting to take a long time. This made
unconditionally running codegen quite annoying, for example before each
test run as part of an IDE workflow or as part of the pre-commit hook.

**How?** This was not completely straightforward as we could not work
with the contents of the file prior to code generation as that was
already post-processed by the QL formatting, so we had no chance of
comparing the output of template rendering with that. We therefore store
the hashes of the files _prior_ to QL formatting in a checked-in file
(`swift/ql/.generated.list`). We can therefore load those hashes at
the beginning of code generation, use them to compare the template
rendering output and update them in this special registry file.

**What else?** We also extend this mechanism to detect accidental
modification of generated files in a more robust way. Before this patch,
we were doing it with a rough regexp based heuristic. Now, we just store
the hashes of the files _after_ QL formatting in the same checked file,
so we can check that and stop generation if a generated file was
modified, or a stub was modified without removing the `// generated`
header.
2022-11-18 16:56:01 +01:00
Paolo Tranquilli
c2171c01e1 Swift: remove double newlines in schema
While PEP8 mandates those, they look bad in the schema file.

`autopep8` already ignores those, and they were single newlines at some
point until an overeager IDE has "fixed" them at some point without me
realizing.

Also, the pre-commit configuration was updated to take `schema.py` into
account.
2022-11-15 15:00:30 +01:00
Paolo Tranquilli
4702271102 Swift: add cfg.swift to AST tests 2022-11-03 18:16:53 +01:00
Paolo Tranquilli
7334b4e03a Swift: autopep8 all python files
Additionally set up a pre-commit hook and a CI check for that.
2022-06-23 17:13:56 +02:00
Paolo Tranquilli
c9f48da569 Swift: add --quiet to codegen 2022-06-20 18:03:59 +02:00
Paolo Tranquilli
946e1f498a Swift: generate getParent implementation
By explicitly marking children in the `schema.yml` file, an internal
`getAChild` predicate is implemented, that is in turn used in `AstNode`
to implement `getParent`.

This is yet to be used in the control flow library to replace the
hand-rolled implementation.

A further, more complex step is to use the same information to fully
generate the core implementation of `PrintAst` (including the
accessor string). This will be done later.

The `parent` tests use the same swift code as the extractor tests, and
this is currently enforced by `sync-files.py`. Notice that `qltest.sh`
had to be modified to deal with multiple files, which was not working
yet.
2022-06-01 14:32:58 +02:00
Paolo Tranquilli
773ef62406 Swift: added trapgen
This checks in the trapgen script generating trap entries in C++.

The codegen suite has been slightly reorganized, moving the templates
directory up one level and chopping everything into smaller bazel
packages. Running tests is now done via
```
bazel run //swift/codegen/test
```

With respect to the PoC, the nested `codeql::trap` namespace has been
dropped in favour of a `Trap` prefix (or suffix in case of entries)
within the `codeql` namespace. Also, generated C++ code is not checked
in in git any more, and generated during build. Finally, labels get
printed in hex in the trap file.

`TrapLabel` is for the moment only default-constructible, so only one
single label is possible. `TrapArena`, that is responsible for creating
disjoint labels will come in a later commit.
2022-04-28 12:01:59 +02:00
Paolo Tranquilli
7f0476049f Swift: removed spurious mock import 2022-04-27 09:11:14 +02:00
Paolo Tranquilli
f171ce6341 Swift: add unit tests to code generation
Tests can be run with
```
bazel test //swift/codegen:tests
```

Coverage can be checked installing `pytest-cov` and running
```
pytest --cov=swift/codegen swift/codegen/test
```
2022-04-27 08:24:11 +02:00
Paolo Tranquilli
de0fa9e456 Swift: QL generation script
Also added code generation to the swift checks.
2022-04-25 13:23:36 +02:00
Paolo Tranquilli
64496b4c97 Swift: cleanup and some docstrings for codegen
Also added code generation and clang formatting to the pre-commit
configuration.
2022-04-14 11:27:41 +02:00
Paolo Tranquilli
11c1b6a8a3 fix typo in .pre-commit-config.yaml 2022-02-24 11:46:19 +01:00
Paolo Tranquilli
9667315d49 pre-commit: add qhelp check
Also the instructions on customizing `pre-commit`'s behaviour have been
updated to use the `--config` option.
2022-02-24 10:55:53 +01:00
Paolo Tranquilli
33cce2b5ac add pre-commit configuration
This enables use of the `pre-commit` framework to run quick pre-commit
checks. In particular this allows to automatically fix:
* trailing white spaces
* absence or multiple newlines at the end of files
* QL code formatting
* file sync

More could be added in the future: anything that can be checked fast
can be added in the configuration (for example well-formedness of
`qldoc` files).

This is a purely opt-in feature. Instructions for enabling it and
possibly configuring its behaviour are in `pre-commit-hook-setup.md`.
2022-02-22 17:40:07 +01:00