-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add automation, linting and improve DX #174
base: 2.x
Are you sure you want to change the base?
Conversation
Simplified Dev Workflow with
|
.build/.gitignore
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduced a .build
directory to consolidate psalm
, php-cs-fixer
, and phpunit
cache files into a single location. This change declutters the local development environment and enables GitHub Actions to efficiently cache the .build
folder, streamlining the workflow.
.editorconfig
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Removed duplicated settings.
- Added .yaml extension.
- Makefile should contain only TABS
.env.example
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Developer now can edit .env.example using editor and then generate local .env
for testing purposes. This can be done by:
- Editing .env.example file
- Executing
make env
command to create environment file for testing and local development purposes
.gitattributes
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Production composer package, that is bundled by GitHub, should only contain production files, LICENCE.md
, README.md
and CHANGELOG.md
. All other files should be considered as development-only.
.github/CODE_OF_CONDUCT.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved CODE_OF_CONDUCT.md
to .github
directory as per best-practices of github.
.php-cs-fixer.dist.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Introducing wayofdev/php-cs-fixer-config
This package serves as a comprehensive wrapper around php-cs-fixer
, offering a standardized configuration for PHP projects. Designed to streamline coding standards across various packages, it facilitates code review and maintenance, enhancing project quality and developer experience.
Key Features:
- Standardized Configuration: Implements a battle-tested rule set optimized for PHP, promoting code quality and maintainability.
- Efficiency Improvements: Features optimizations that boost PHP execution speed, contributing to better performance.
- Namespace Optimization: Refactors usage of functions within classes from local
\
prefix (e.g.,\strlen
) to the class header, enhancing code readability and maintainability.
Example:
<?php
declare(strict_types=1);
namespace WayOfDev\Cycle\Bridge\Laravel\Console\Commands\Migrations;
use Cycle\Migrations\Config\MigrationConfig;
use Cycle\Migrations\Migrator;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use function array_merge;
use function call_user_func_array;
abstract class AbstractCommand extends Command
{
Enhanced Developer Flexibility:
- Local & CI Integration: Enables developers to run linting processes locally, bypassing the need for cloud-based services like StyleCI. This flexibility supports a more efficient development workflow and integrates seamlessly with CI/CD pipelines, including GitHub Actions.
- GitHub Actions Ready: The configuration is designed for easy integration with GitHub Actions, allowing automated code style checks in your CI/CD pipeline, ensuring code quality with every commit.
Configuration Highlights:
The configuration extends the Symfony rule set with customized overrides for a tailored coding standard. Key adjustments include:
- Import Ordering: Specifies the order of imports (class, function, const) to maintain consistency.
- Spacing and Alignment: Enforces specific spacing (e.g., one space for concatenation) and left alignment for PHPDoc comments.
- Method and Class Element Ordering: Allows for a customized order of class elements, including methods and properties, without enforcing a specific sorting algorithm.
- PHP Version-Specific Features: Adopts modern PHP syntax and features, encouraging the use of short list syntax, static lambdas, and null coalescing operators.
- Risky Rules: Includes rules that are considered risky but are allowed to ensure forward compatibility and adherence to modern PHP standards.
- Optimizations for PHP Native Functions: Encourages the use of namespaced PHP native functions to improve performance.
.pre-commit-config.yaml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've integrated the pre-commit framework into our repository to enhance code quality and efficiency. This tool runs checks locally before a pull request is made, aiming to:
- Improve Code Quality: It automatically identifies common issues early, ensuring adherence to coding standards.
- Save Reviewer Time: By addressing issues upfront, it reduces the need for detailed reviews on minor, easily fixable problems.
- Streamline Development: It offers immediate feedback, helping developers align with project standards more efficiently.
The adoption of pre-commit is a strategic move to maintain high code standards while optimizing the review process.
.yamllint.yaml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added yamllint to our repository for YAML file validation. It ensures:
- Quality: Checks syntax and formatting, ensuring YAML files meet our standards.
- Efficiency: Automates common issue detection, saving time in reviews.
- Consistency: Helps maintain uniformity across all YAML files.
This integration streamlines development by automating YAML checks, enhancing code quality and consistency.
phpunit.xml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All tools should save cache in single .build folder, it declutters space in root directory and also allows to perform github ci cache, when running github actions.
docker-compose.yaml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've dockerized this repository, enabling:
- Simplicity: Run the local environment with just Docker installed, no complex setup required.
- Compatibility: Avoids the need for installing a specific PHP version on your PC.
This change simplifies development, ensuring a consistent environment for all contributors.
composer.json
Outdated
"vimeo/psalm": "^5.18" | ||
"vimeo/psalm": "^5.23", | ||
"roave/security-advisories": "dev-latest", | ||
"wayofdev/cs-fixer-config": "^1.2" | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Cycle\\Database\\Tests\\": "tests/Database" | ||
} | ||
}, | ||
"scripts": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate commands for local tool-chain.
.github/workflows/create-release.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added github action to automatically generate changelog PR's from developer commits.
Note
If we want to enable automatic merges, secrets.GITHUB_TOKEN should be changed to dedicated token, specially created for such purposes
psalm.xml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added https://github.com/psalm/psalm-plugin-phpunit plugin to support Psalm in PHPUnit
fix(git): .gitattributes should ignore all dev files fix(ci): increase job timeouts, add timeouts to *sql ci workflows feat(dx): add phive installation fix(deps): Added ext-filter as dependency style(composer): sort composer fix(deps): Applied composer-require-checker
feat: introduce self-documenting
Makefile
for package developmentThis update introduces a self-documenting
Makefile
as a single entry point for developers working on the package, streamlining the development process and enhancing usability.feat: add
pre-commit
with multiple hooks for code quality assurancePre-commit has been added to the development workflow to automatically check and fix common issues before commits are made. The included hooks are:
trailing-whitespace
: Removes trailing whitespace.end-of-file-fixer
: Ensures files end with a newline.check-added-large-files
: Prevents large files (>600KB) from being committed.fix-encoding-pragma
: Adjusts files to have a proper encoding pragma.commitizen
: Enforces conventional commit messages.feat: implement commitizen for conventional commits
Commitizen has been integrated to facilitate the use of conventional commits, paving the way for an automated
CHANGELOG.md
via googleapis/release-please.chore: reorganize
CODE_OF_CONDUCT.md
to.github
directoryMoving
CODE_OF_CONDUCT.md
to the.github
directory declutters the main folder and aligns with GitHub's best practices for repository organization.feat: streamline environment setup with
.env
example and MakefileAdded .env.example and integrated
.env
building through Makefile, leveraging Docker to expedite environment setup for developers.feat: add
.yamllint.yaml
for YAML file lintingIntroduced a
.yamllint.yaml
configuration file to lint YAML files, enhancing code quality and consistency.feat: replace
StyleCI
with localwayofdev/cs-fixer-config
for PHP lintingSwitched from cloud-based StyleCI to a local solution using
wayofdev/cs-fixer-config
, a php-cs-fixer wrapper package. This allows developers to perform PHP linting locally via Makefile, reducing reliance on cloud-based CI systems.feat: update docker-compose for enhanced development and testing
Updated
docker-compose.yaml
to support PHP 8.2 and various database servers directly through Makefile and in tests, enabling developers to avoid local PHP installations.