-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mattsqd/feature/init
Initial code release
- Loading branch information
Showing
7 changed files
with
911 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_size = 4 | ||
indent_style = space | ||
|
||
[**.php] | ||
max_line_length = 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
vendor/ | ||
# Ignore ide files | ||
.vscode/ | ||
/.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Robo Validate Commands | ||
|
||
**A group of [Robo](https://robo.li) commands that run various validation tasks on local environments or pipelines** | ||
|
||
* Coding standards (``validate:coding-standards``) | ||
* Uses PHPCS to validate code. | ||
* Zero config for Drupal projects. | ||
* Composer lock (``validate:composer-lock``) | ||
* Ensures you don't get this message during ``composer install``: | ||
> Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them. | ||
* Commit messages (``validate:commit-messages``) | ||
* Validate commit messages against a regular expression. | ||
* Branch name (``validate:branch-name``) | ||
* Validate a branch name against a regular expression. | ||
* Note: This command has an optional single parameter which is the branch name if the current branch name cannot be determined automatically. | ||
* Run all the above (``validate:all)`` | ||
|
||
## Installing | ||
|
||
``composer require mattsqd/robovalidate`` | ||
|
||
## Usage | ||
|
||
Use `vendor/bin/robo` to execute Robo tasks. | ||
|
||
## Configuration | ||
|
||
There are two ways to configure the commands. | ||
1. Pass options to the command as they run. | ||
2. Create (or update) a robo.yml in your root directory that holds the options. | ||
|
||
Number two is the easiest as some options are arrays, and it gets very ugly trying to pass arrays at run time. | ||
|
||
All the options live under the `command.validate.options` namespace in robo.yml. | ||
|
||
Some commands share the same option, such as project-id. So changing it will affect all commands unless you move that key under the specific commands section. You can see an example of this with 'pattern' which is used in two commands. | ||
|
||
### Quick Start | ||
|
||
The quick start assumes: | ||
* This is a Drupal project using Drupal and DrupalPractice coding standards. | ||
* You want commit messages like: 'ABC-1234: A short message' and you're merging into origin/develop. | ||
* You want branches named like: main, develop, hotfix/3.3.1, release/3.3.0, and feature/ABC-123-a-short-message. | ||
* Your composer.lock lives in the root directory and composer lives at vendor/bin/composer. | ||
|
||
This can be configured by creating ``robo.yml`` in your project root with the following content: | ||
``` yml | ||
command: | ||
validate: | ||
options: | ||
project-id: ABC | ||
``` | ||
And run `vendor/bin/robo validate:all` | ||
|
||
If any of the above does not apply you can either: | ||
* Call individual commands instead of ``validate:all`` or | ||
* Configure your robo.yml as in robo.example.yml. | ||
|
||
Please see robo.example.yml for an example of the defaults configured explicitly. | ||
|
||
For each option, you only need to override the ones you want to change, you don't need to copy the entire file, although you can. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "mattsqd/robovalidate", | ||
"description": "A group of Robo commands that run various validation tasks on local environments or pipelines", | ||
"authors": [ | ||
{ | ||
"name": "mattsqd", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"RoboValidate\\": "src" | ||
} | ||
}, | ||
"type": "robo-tasks", | ||
"license": "GPL-2.0-or-later", | ||
"require": { | ||
"consolidation/robo": "^3.0.9 || ^4.0.1", | ||
"php": ">=8.0.17" | ||
}, | ||
"suggest": { | ||
"squizlabs/php_codesniffer": "Recommended if wanting to validate coding standards." | ||
}, | ||
"require-dev": { | ||
"squizlabs/php_codesniffer": "^3.6" | ||
}, | ||
"config": { | ||
"optimize-autoloader": true, | ||
"sort-packages": true, | ||
"platform": { | ||
"php": "8.0.17" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# These are the 'default' options if no options or robo.yml are in place. | ||
command: | ||
validate: | ||
# Used in 'validate:coding-standards' and 'validate:branch-name' | ||
options: | ||
# This is used as a token replacement. It is most useful for 'pattern' so | ||
# you can ensure that commit and branch names have a issue number in them | ||
# so that Jira, Github, or Gitlab know which commits and branches belong | ||
# to which issue. | ||
# For example, if you bitbucket issue was XZY-1234, you canmake project-id | ||
# XYZ. | ||
project-id: '' | ||
# Used in 'validate:coding-standards' | ||
# Requires https://github.com/squizlabs/PHP_CodeSniffer be installed. | ||
coding-standards: | ||
options: | ||
# This is initially configured for Drupal. However, this can be any PHPCS standard. | ||
# Individual PHPCS commands cannot use more than one standar, so this will cause | ||
# the same command to be run for each standard for each path. | ||
standards: | ||
- Drupal | ||
- DrupalPractice | ||
# This is required for non-Drupal projects. It will be in the form of: | ||
# path/to/files/a: | ||
# extensions: 'php,module,inc' | ||
# ignore: '*node_modules/*,*bower_components/*,*vendor/*,*.min.js,*.min.css' | ||
# path/to/files/b: {} | ||
# path/to/files/c: | ||
# standard: | ||
# - psr2 | ||
# The key is used as the path, and the value are the options passed to PHPCS. | ||
# If no options are given, as in 'b', then 'similar-options' will be used. | ||
# If any options are given, then similar options will not be used, so you must | ||
# add any options in 'similar-options' that should be there in addition to the | ||
# overrides. | ||
# The 'standard' is different. If it is not given, it will use the 'standards' option. | ||
# If it is given, it will override 'standards' option. | ||
# If 'standard' is only given, as in 'c' 'similar-options' WILL still be applied. | ||
paths: {} | ||
# These are the options passed to PHPCS if 'paths' does not set any options. | ||
# Please see https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options. | ||
similar-options: | ||
colors: '' | ||
extensions: 'php,module,inc,install,test,profile,theme,css,info' | ||
ignore: '*node_modules/*,*bower_components/*,*vendor/*,*.min.js,*.min.css' | ||
# Used in 'validate:composer-lock' | ||
composer-lock: | ||
# Can be set to a global location if needed. | ||
composer-path: 'vendor/bin/composer' | ||
# Only useful if composer.json lives in something besides the root directory. | ||
working-directory: './' | ||
# Used in 'validate:commit-messages' | ||
commit-messages: | ||
# This is the branch that the current branch is going to be merged into. | ||
target-branch: develop | ||
# The name of the git remote to pull the latest commits from. | ||
git-remote: origin | ||
# The regular expression that much match for all commits not in 'target-branch'. | ||
# Note how {$project_id} is not part of the pattern but replaced with whatever is | ||
# in 'project-id' before the regular expression is used. | ||
pattern: '/^{$project_id}-(\d{4}): /' | ||
# These next two describe how the commits should be formed. | ||
short-help: 'Commit messages must start with: ''{$project_id}-x:y''' | ||
long-help: | ||
- 'Where x is the ticket number.' | ||
- 'And y is a space.' | ||
- '' | ||
- 'How do I update my commit messages?' | ||
- 'See https://www.atlassian.com/git/tutorials/rewriting-history' | ||
- '' | ||
- 'After re-rewriting the history, you should --force-with-lease the push.' | ||
- 'https://stackoverflow.com/questions/52823692/git-push-force-with-lease-vs-force#:~:text=%2D%2Dforce%2Dwith%2Dlease%20is%20a%20safer%20option%20that%20will,elses%20work%20by%20force%20pushing.' | ||
# Used in 'validate:branch-name' | ||
branch-name: | ||
options: | ||
# The regular expression that must match the branch name. | ||
pattern: '/^feature\/{$project_id}-([\d]{1,})-(?!.*--)([a-z\d]{1})([a-z\d-]{3,})([a-z\d]{1})$/' | ||
# Show help messages if the branch name does not match. | ||
custom-help: | ||
- 'feature/{$project_id}-* where * can be:' | ||
- ' - Always lower case.' | ||
- ' - Starts and end with a letter or integer.' | ||
- ' - Contains letters, integers, or dashes (non-consecutive).' | ||
- ' - At least 5 characters long.' | ||
# These refer to all the possible branch names. There are 4 different types and they will be | ||
# described below. If you'd like to override any of these, you must put all back in that you'd like to | ||
# use, they will not be merged together. | ||
valid-branch-names: | ||
options: | ||
# Matches a branch named 'develop'. | ||
- 'explicit|develop' | ||
# Matches a branch named 'main'. | ||
- 'explicit|main' | ||
# Matches a custom regular expression found in $pattern. | ||
- 'custom|' | ||
# Matches a branch like: hotfix/2.1.3. | ||
- 'semantic|hotfix' | ||
# Matches a branch like (the last number MUST be a 0): release/2.1.0. | ||
- 'semantic_end_0|release' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file is used when contributing to check for coding standards. | ||
command: | ||
validate: | ||
coding-standards: | ||
options: | ||
paths: | ||
# Robo projects use psr2 standards. | ||
src: | ||
extensions: 'php' | ||
standard: psr2 |
Oops, something went wrong.