Skip to content

Commit 45ea975

Browse files
committed
DIGITAL-99: Allow all validation commands to run during validate:all.
1 parent 1496ad2 commit 45ea975

File tree

5 files changed

+84
-24
lines changed

5 files changed

+84
-24
lines changed

.github/workflows/validation-run.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,23 @@ jobs:
4949
run: |
5050
# Initialize status variables to 0
5151
status1=0
52-
status2=0
53-
status3=0
54-
status4=0
55-
status5=0
5652
57-
# Run all commands and capture their exit statuses
58-
vendor/bin/robo validate:branch-name ${{ steps.extract_branch.outputs.branch }} || status1=$? || status1=0
59-
vendor/bin/robo validate:composer-lock || status3=$? || status3=0
60-
vendor/bin/robo validate:coding-standards || status2=$? || status2=0
61-
set -x
62-
vendor/bin/twig-cs-fixer lint || status4=$? || status4=0
63-
vendor/bin/phpstan --memory-limit=-1 --no-progress || status5=$? || status5=0
64-
set +x;
53+
ROBO_VALIDATE_BRANCH_NAME=${{ steps.extract_branch.outputs.branch }} vendor/bin/robo validate:all non_pr
6554
66-
# Exit with a non-zero status if any command failed
67-
if [ "$status1" -ne 0 ] || [ "$status2" -ne 0 ] || [ "$status3" -ne 0 ] || [ "$status4" -ne 0 ] || [ "$status5" -ne 0 ]; then
55+
# Exit with a non-zero status if the command failed
56+
if [ "$status1" -ne 0 ]; then
6857
exit 1
6958
fi
7059
7160
- name: Validate pull requests
7261
if: github.event_name == 'pull_request'
7362
run: |
74-
vendor/bin/robo validate:commit-messages --target-branch="${{ github.base_ref }}" --current-branch="${{ github.head_ref }}"
63+
# Initialize status variables to 0
64+
status1=0
65+
66+
ROBO_VALIDATE_TARGET_BRANCH="${{ github.base_ref }}" ROBO_VALIDATE_CURRENT_BRANCH="${{ github.head_ref }}" vendor/bin/robo validate:all only_pr
67+
68+
# Exit with a non-zero status if the command failed
69+
if [ "$status1" -ne 0 ]; then
70+
exit 1
71+
fi

RoboFile.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,57 @@ public function reTagRelease(
273273
return new ResultData();
274274
}
275275

276+
/**
277+
* Run PHPStan validation.
278+
*
279+
* @command validate:phpstan
280+
*/
281+
public function validatePhpstan(): ResultData
282+
{
283+
if (!$this->taskExec('vendor/bin/phpstan')
284+
->option('memory-limit', '-1', '=')
285+
->run()->wasSuccessful()) {
286+
$this->printError('PHPStan errors found');
287+
return new ResultData(ResultData::EXITCODE_ERROR);
288+
}
289+
$this->sayWithWrapper('SUCCESS: No PHPStan errors found.');
290+
return new ResultData();
291+
}
292+
293+
/**
294+
* Run Twig validation.
295+
*
296+
* @command validate:twig
297+
*/
298+
public function validateTwig(): ResultData
299+
{
300+
if (!$this->taskExec('vendor/bin/twig-cs-fixer')
301+
->arg('lint')
302+
->run()->wasSuccessful()) {
303+
$this->printError('Twig errors found. Use vendor/bin/twig-cs-fixer lint --fix to automatically fix.');
304+
return new ResultData(ResultData::EXITCODE_ERROR);
305+
}
306+
$this->sayWithWrapper('SUCCESS: No PHPStan errors found.');
307+
return new ResultData();
308+
}
309+
310+
/**
311+
* Say a message but with a '---' wrapper around it.
312+
*/
313+
protected function sayWithWrapper($message)
314+
{
315+
$this->say('');
316+
$this->say(str_repeat('-', strlen($message)));
317+
$this->say($message);
318+
$this->say(str_repeat('-', strlen($message)));
319+
$this->say('');
320+
}
321+
322+
/**
323+
* Print an error message.
324+
*/
325+
protected function printError($message)
326+
{
327+
$this->yell($message, 40, 'red');
328+
}
276329
}

composer.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ d0ca998c567e8cc218ee57bb5c9b6679|cathybaptista|feature/DIGITAL-119-configure-ima
7272
6b5963bf3c6740285c129be6d6273aed|cathybaptista|feature/DIGITAL-119-configure-images|Thu Feb 6 11:06:14 EST 2025|./composer.sh require drupal/edit_media_modal
7373
caeb4cc7f30e1f80c7425f9c3fcf8a98|Oscar Merida|feature/DIGITAL-89-linkit|Wed Feb 5 16:40:40 EST 2025|./composer.sh require drupal/linkit:^7.0
7474
c063010712247ba9dfd709c97fccb648|Oscar Merida|feature/DIGITAL-89-linkit|Thu Feb 6 16:27:25 EST 2025|./composer.sh require drupal/linkit:^7.0
75+
baf396b85c3bcb4a0f123cfa702e1088|Matt Poole|feature/DIGITAL-99-robo-standards|Mon Feb 10 14:12:29 EST 2025|./composer.sh update mattsqd/robovalidate

robo.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ command:
2222
- 'semantic_end_0|release'
2323
# Matches a branch named 'stage' (MOD FROM DEFAULTS).
2424
- 'explicit|stage'
25+
all:
26+
options:
27+
commands:
28+
- {robo_command: 'validate:coding-standards', label: 'Coding Standards'}
29+
- {robo_command: 'validate:composer-lock', label: 'Composer Lock File'}
30+
- {robo_command: 'validate:commit-messages', label: 'Commit Messages', only_pr: 1}
31+
- {robo_command: 'validate:branch-name', label: 'Branch Name'}
32+
- {robo_command: 'validate:phpstan', label: 'PHP Stan'}
33+
- {robo_command: 'validate:twig', label: 'Twig Standards'}

0 commit comments

Comments
 (0)