From dce31b8f154fdd55650ff17e0326650f4cfc13ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sawicz?= Date: Wed, 17 Dec 2025 15:42:30 +0100 Subject: [PATCH 1/2] pre-commit: bootstrap Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .github/workflows/pre-commit.yaml | 26 +++++++++++++++++ .pre-commit-config.yaml | 33 ++++++++++++++++++++++ .pymarkdown.json | 46 +++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 .github/workflows/pre-commit.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 .pymarkdown.json diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 00000000..60fe7d01 --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,26 @@ +name: PreCommit + +on: + pull_request: + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + PreCommit: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 + with: + python-version: 3.x + - uses: pre-commit/action@v3.0.1 + - uses: pre-commit-ci/lite-action@v1.1.0 + if: always() + with: + msg: "pre-commit: apply automatic fixes" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..f90aa082 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +# Recommended workflow: +# - `git add --verbose --patch` to stage changes +# - `git commit` to commit them +# - rinse and repeat, if pre-commit wants / applied changes + +exclude: ^COPYING + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-added-large-files + +- repo: https://github.com/executablebooks/mdformat + rev: 0.7.22 + hooks: + - id: mdformat + additional_dependencies: + - mdformat-black + - mdformat-beautysh + - mdformat-gfm + - mdformat-myst + - setuptools # Necessary until beautysh fix their stuff, see: https://github.com/hukkin/mdformat/issues/442 + +- repo: https://github.com/jackdewinter/pymarkdown + rev: v0.9.32 + hooks: + - id: pymarkdown + args: + - --config=.pymarkdown.json + - fix diff --git a/.pymarkdown.json b/.pymarkdown.json new file mode 100644 index 00000000..2c4c669d --- /dev/null +++ b/.pymarkdown.json @@ -0,0 +1,46 @@ +{ + "plugins": { + "selectively_enable_rules": true, + "heading-style": { + "enabled": true, + "style": "atx" + }, + "commands-show-output": { + "enabled": true + }, + "no-missing-space-atx": { + "enabled": true + }, + "blanks-around-headings": { + "enabled": true + }, + "heading-start-left": { + "enabled": true + }, + "no-trailing-punctuation": { + "enabled": true, + "punctuation": ".,;。,;" + }, + "blanks-around-fences": { + "enabled": true, + "list_items": false + }, + "blanks-around-lists": { + "enabled": true + }, + "hr-style": { + "enabled": true + }, + "no-empty-links": { + "enabled": true + }, + "no-alt-text": { + "enabled": true + } + }, + "extensions": { + "front-matter" : { + "enabled" : true + } + } +} From 1a6b4387301f9d92bd63d905021a0e36fb9472cd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:47:29 +0000 Subject: [PATCH 2/2] pre-commit: apply automatic fixes --- .github/.jira_sync_config.yaml | 1 - .github/copilot-instructions.md | 15 ++++++++++++--- .github/workflows/spread.yml | 2 +- debian/copyright | 1 - src/main.cpp | 1 - src/protocol/gtk-primary-selection.xml | 2 +- src/protocol/input-method-unstable-v1.xml | 2 +- src/protocol/input-method-unstable-v2.xml | 2 +- tests/text_input_v2_with_input_method_v1.cpp | 2 +- tools/make_release_tarball | 1 - 10 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/.jira_sync_config.yaml b/.github/.jira_sync_config.yaml index 0aba85a9..da3de6d9 100644 --- a/.github/.jira_sync_config.yaml +++ b/.github/.jira_sync_config.yaml @@ -10,4 +10,3 @@ settings: - Testing label_mapping: enhancement: Story - diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 2006973d..422493d2 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -5,6 +5,7 @@ **What is WLCS**: A protocol-conformance test suite for Wayland compositors. Unlike previous test suites that use protocol extensions, WLCS uses compositor-provided integration modules loaded as shared libraries (.so files). Tests run in-process with the compositor, enabling easier debugging and consistent timing. **Core Components**: + - `include/wlcs/display_server.h`: Integration API that compositors must implement (`WlcsServerIntegration`, `WlcsDisplayServer` structs) - `src/`: Test infrastructure (test runner, client/server helpers, protocol wrappers) - `tests/`: Protocol conformance tests for wl_compositor, xdg_shell, layer_shell, input methods, etc. @@ -15,10 +16,12 @@ ## Test Infrastructure **Base Classes** (see `include/in_process_server.h`): + - `InProcessServer`: GTest fixture that creates a `Server` instance. Use `SetUp()/TearDown()` explicitly - `StartedInProcessServer`: Auto-starts the server in constructor. Most tests inherit from this **Creating Test Clients**: + ```cpp wlcs::Client client{the_server()}; // Creates Wayland client connection wlcs::Surface surface{client}; // Creates wl_surface @@ -26,6 +29,7 @@ client.roundtrip(); // Block until server processes requests ``` **Simulating Input** (see `include/wlcs/pointer.h`, `include/wlcs/touch.h`): + ```cpp auto pointer = the_server().create_pointer(); pointer.move_to(100, 200); // Absolute coordinates @@ -46,16 +50,19 @@ touch.up(); Follow the [Canonical Mir C++ Guide](https://canonical-mir.readthedocs-hosted.com/stable/contributing/reference/cppguide/). **Requirements**: + - C++20 required (`CMAKE_CXX_STANDARD 20`) - Strict warnings: `-Werror` enabled by default (toggle with `WLCS_FATAL_COMPILE_WARNINGS`) **Key Conventions**: + - Headers use include guards (`#ifndef WLCS_*_H_`) - Wayland objects wrapped in RAII types (see `WlHandle` in `wl_handle.h`) - Helper timeouts: `wlcs::helpers::a_short_time()` (for negative tests), `wlcs::helpers::a_long_time()` (for operation timeouts) - Test structure: Arrange (create surfaces/clients), Act (inject input/commit), Assert (check window focus/position) **Testing Protocol Errors**: Use `expect_protocol_error.h` to verify compositor rejects invalid client requests: + ```cpp EXPECT_PROTOCOL_ERROR(client, &interface_name, error_code, { // code that should trigger error @@ -65,12 +72,14 @@ EXPECT_PROTOCOL_ERROR(client, &interface_name, error_code, { ## Common Tasks **Adding Protocol Tests**: + 1. Add `.xml` to `src/protocol/` if not present -2. Create wrapper class in `include/` (follow pattern from `layer_shell_v1.h`) -3. Implement wrapper in `src/` (generate protocol bindings in CMake) -4. Write tests in `tests/` inheriting from `StartedInProcessServer` +1. Create wrapper class in `include/` (follow pattern from `layer_shell_v1.h`) +1. Implement wrapper in `src/` (generate protocol bindings in CMake) +1. Write tests in `tests/` inheriting from `StartedInProcessServer` **Protocol Version Handling**: Use `VersionSpecifier` (see `version_specifier.h`) to bind interfaces: + ```cpp auto shell = client.bind_if_supported(wlcs::AtLeast(2)); ``` diff --git a/.github/workflows/spread.yml b/.github/workflows/spread.yml index 8a06c814..61ddc369 100644 --- a/.github/workflows/spread.yml +++ b/.github/workflows/spread.yml @@ -48,7 +48,7 @@ jobs: - name: Set up Spread run: | - set -euo pipefail + set -euo pipefail sudo snap install spread-mir-ci sudo snap run lxd init --auto diff --git a/debian/copyright b/debian/copyright index fa4f0942..d4940fa0 100644 --- a/debian/copyright +++ b/debian/copyright @@ -70,4 +70,3 @@ License: GPL-2+ . On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". - diff --git a/src/main.cpp b/src/main.cpp index b77c79b8..5ca18254 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -97,4 +97,3 @@ int main(int argc, char** argv) } return EXIT_SUCCESS; } - diff --git a/src/protocol/gtk-primary-selection.xml b/src/protocol/gtk-primary-selection.xml index aee85c22..c2ae8baa 100644 --- a/src/protocol/gtk-primary-selection.xml +++ b/src/protocol/gtk-primary-selection.xml @@ -222,4 +222,4 @@ - \ No newline at end of file + diff --git a/src/protocol/input-method-unstable-v1.xml b/src/protocol/input-method-unstable-v1.xml index 473f6516..cff24d62 100644 --- a/src/protocol/input-method-unstable-v1.xml +++ b/src/protocol/input-method-unstable-v1.xml @@ -302,4 +302,4 @@ - \ No newline at end of file + diff --git a/src/protocol/input-method-unstable-v2.xml b/src/protocol/input-method-unstable-v2.xml index 62be9d94..9e5ee6ba 100644 --- a/src/protocol/input-method-unstable-v2.xml +++ b/src/protocol/input-method-unstable-v2.xml @@ -96,7 +96,7 @@ - Notification that no focused text input currently needs an active + Notification that no focused text input currently needs an active input method on this seat. This event marks the zwp_input_method_v2 object as inactive. The diff --git a/tests/text_input_v2_with_input_method_v1.cpp b/tests/text_input_v2_with_input_method_v1.cpp index 54168d17..6584f556 100644 --- a/tests/text_input_v2_with_input_method_v1.cpp +++ b/tests/text_input_v2_with_input_method_v1.cpp @@ -320,4 +320,4 @@ TEST_F(TextInputV2WithInputMethodV1Test, input_method_can_set_direction) input_method_context->serial, direction); app_client_wait_for_input_client_roundtrip([&]() { return has_received_text_direction; }); -} \ No newline at end of file +} diff --git a/tools/make_release_tarball b/tools/make_release_tarball index 92c0c4e0..4e97ae51 100755 --- a/tools/make_release_tarball +++ b/tools/make_release_tarball @@ -61,4 +61,3 @@ fi mv $SCRATCH_DIR/$VERSIONED_NAME.tar.xz . echo "$VERSIONED_NAME.tar.xz successfully created and tested" -