From 69d81ef4816119ce21ca4c88922d931594fc41fd Mon Sep 17 00:00:00 2001 From: Herbert Roth Date: Tue, 8 Jul 2025 14:32:24 +0200 Subject: [PATCH] Add Copilot setup instructions and workflow configuration --- .github/copilot-instructions.md | 60 +++++++++++++++++++++++ .github/workflows/copilot-setup-steps.yml | 43 ++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 .github/copilot-instructions.md create mode 100644 .github/workflows/copilot-setup-steps.yml diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 000000000..04bce20a3 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,60 @@ +This is a php based project. php 8.3 is the minimum version required to run this project. +php 8.4 features are not used in this project. codeception is used for testing. + +## Key Guidelines + - Do not modify `composer.json` or `composer.lock` files. + +## Code Standards + + - Use symfony coding standards. + - Follow PSR-12 for PHP code style. + - Use spaces for indentation (4 spaces per indent level). + - Use camelCase for variable and method names, and PascalCase for class names. Constants should be in uppercase with underscores. + - Use single quotes for strings unless interpolation is needed. + - Use `===` for comparisons and avoid using `==` unless necessary. + - Make new classes final unless they are intended to be extended. + - Dont add '@param' to methods unless the parameter type is not clear from the method signature. + - Dont add '@return' to methods unless the return type is not clear from the method signature. + - Follow the principle of least surprise, meaning that code should be easy to understand and follow common conventions. + - Follow the principle of return early, meaning that if a function can return early, it should do so to avoid deep nesting. + - Use dependency injection for classes and services. + - Use interfaces for classes that are intended to be used as services. + - Use interfaces for dependency injection to allow for easier testing and mocking. + - Avoid using static methods and properties unless absolutely necessary. + - Use contructor injection for dependencies. + - Avoid using global state and singletons. + - Use constructer promotion for class properties. + - Follow the principle of minimal visibility, meaning that class properties and methods should be as private as possible. + - Use interfaces for classes that are intended to be used as services. + - Avoid using abstract classes unless absolutely necessary. + - Add a `@throws` annotation to methods that can throw exceptions, and document the exceptions that can be thrown. + - Add a new line at the end of each file. Use UTF-8 encoding for files. + - Use `null` coalescing operator (`??`) for default values when applicable. + - Use `match` expressions for simple value comparisons. + - Use `array_map`, `array_filter`, and `array_reduce` for array transformations instead of loops when applicable. + - Use `declare(strict_types=1);` at the top of each file to enforce strict typing. + +## Repository Structure + + - Use the `src/` directory for application code. + - Use the `tests/Unit` directory for unit tests. + - Use the `config/` directory for configuration files. + - Use the `public/` directory for public assets and entry points. + - Use the `vendor/` directory for third-party dependencies managed by Composer. + - Use the `translations/` directory for translation files. + - Use the `doc/` directory for documentation files. + +## Testing + + - Use Codeception for testing. + - Follow the Codeception documentation for writing tests. + - Write unit tests for new functionality. Use mocks and stubs where applicable. + - Use `codeception.dist.yml` for Codeception configuration. + - Run tests using `vendor/bin/codecept run` command. + +## Documentation + + - Use `@deprecated` annotation for deprecated methods or classes. + - Use `@example` annotation for providing examples of usage. + - Keep documentation up to date with code changes. + - Suggest changes to the `doc/` folder when appropriate \ No newline at end of file diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 000000000..7332ff362 --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,43 @@ +name: "Copilot Setup Steps" + +# Automatically run the setup steps when they are changed to allow for easy validation, and +# allow manual testing through the repository's "Actions" tab +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +jobs: + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. + copilot-setup-steps: + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.3" + + - name: Install SSH Key # this is necessary for Composer to be able to clone source from pimcore/ee-pimcore + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }} + known_hosts: ".... we add this in the next step ;-)" + + - name: "Add authentication for private pimcore packages" + run: | + composer config repositories.private-packagist '{"type": "composer", "url": "https://repo.pimcore.com/github-actions/", "canonical": true}' + composer config --global --auth http-basic.repo.pimcore.com github-actions ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }} + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v3"