Skip to content

Commit d94ec34

Browse files
authored
Add Copilot setup instructions and workflow configuration (#1195)
1 parent 5be35bb commit d94ec34

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
This is a php based project. php 8.3 is the minimum version required to run this project.
2+
php 8.4 features are not used in this project. codeception is used for testing.
3+
4+
## Key Guidelines
5+
- Do not modify `composer.json` or `composer.lock` files.
6+
7+
## Code Standards
8+
9+
- Use symfony coding standards.
10+
- Follow PSR-12 for PHP code style.
11+
- Use spaces for indentation (4 spaces per indent level).
12+
- Use camelCase for variable and method names, and PascalCase for class names. Constants should be in uppercase with underscores.
13+
- Use single quotes for strings unless interpolation is needed.
14+
- Use `===` for comparisons and avoid using `==` unless necessary.
15+
- Make new classes final unless they are intended to be extended.
16+
- Dont add '@param' to methods unless the parameter type is not clear from the method signature.
17+
- Dont add '@return' to methods unless the return type is not clear from the method signature.
18+
- Follow the principle of least surprise, meaning that code should be easy to understand and follow common conventions.
19+
- Follow the principle of return early, meaning that if a function can return early, it should do so to avoid deep nesting.
20+
- Use dependency injection for classes and services.
21+
- Use interfaces for classes that are intended to be used as services.
22+
- Use interfaces for dependency injection to allow for easier testing and mocking.
23+
- Avoid using static methods and properties unless absolutely necessary.
24+
- Use contructor injection for dependencies.
25+
- Avoid using global state and singletons.
26+
- Use constructer promotion for class properties.
27+
- Follow the principle of minimal visibility, meaning that class properties and methods should be as private as possible.
28+
- Use interfaces for classes that are intended to be used as services.
29+
- Avoid using abstract classes unless absolutely necessary.
30+
- Add a `@throws` annotation to methods that can throw exceptions, and document the exceptions that can be thrown.
31+
- Add a new line at the end of each file. Use UTF-8 encoding for files.
32+
- Use `null` coalescing operator (`??`) for default values when applicable.
33+
- Use `match` expressions for simple value comparisons.
34+
- Use `array_map`, `array_filter`, and `array_reduce` for array transformations instead of loops when applicable.
35+
- Use `declare(strict_types=1);` at the top of each file to enforce strict typing.
36+
37+
## Repository Structure
38+
39+
- Use the `src/` directory for application code.
40+
- Use the `tests/Unit` directory for unit tests.
41+
- Use the `config/` directory for configuration files.
42+
- Use the `public/` directory for public assets and entry points.
43+
- Use the `vendor/` directory for third-party dependencies managed by Composer.
44+
- Use the `translations/` directory for translation files.
45+
- Use the `doc/` directory for documentation files.
46+
47+
## Testing
48+
49+
- Use Codeception for testing.
50+
- Follow the Codeception documentation for writing tests.
51+
- Write unit tests for new functionality. Use mocks and stubs where applicable.
52+
- Use `codeception.dist.yml` for Codeception configuration.
53+
- Run tests using `vendor/bin/codecept run` command.
54+
55+
## Documentation
56+
57+
- Use `@deprecated` annotation for deprecated methods or classes.
58+
- Use `@example` annotation for providing examples of usage.
59+
- Keep documentation up to date with code changes.
60+
- Suggest changes to the `doc/` folder when appropriate
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "Copilot Setup Steps"
2+
3+
# Automatically run the setup steps when they are changed to allow for easy validation, and
4+
# allow manual testing through the repository's "Actions" tab
5+
on:
6+
workflow_dispatch:
7+
push:
8+
paths:
9+
- .github/workflows/copilot-setup-steps.yml
10+
pull_request:
11+
paths:
12+
- .github/workflows/copilot-setup-steps.yml
13+
14+
jobs:
15+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
16+
copilot-setup-steps:
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: read
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: "Install PHP"
27+
uses: "shivammathur/setup-php@v2"
28+
with:
29+
php-version: "8.3"
30+
31+
- name: Install SSH Key # this is necessary for Composer to be able to clone source from pimcore/ee-pimcore
32+
uses: shimataro/ssh-key-action@v2
33+
with:
34+
key: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
35+
known_hosts: ".... we add this in the next step ;-)"
36+
37+
- name: "Add authentication for private pimcore packages"
38+
run: |
39+
composer config repositories.private-packagist '{"type": "composer", "url": "https://repo.pimcore.com/github-actions/", "canonical": true}'
40+
composer config --global --auth http-basic.repo.pimcore.com github-actions ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
41+
42+
- name: "Install dependencies with Composer"
43+
uses: "ramsey/composer-install@v3"

0 commit comments

Comments
 (0)