Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gitlab_templates
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
gitlab_templates
Commits
ccdc0787
Commit
ccdc0787
authored
1 month ago
by
Jonathan Smith
Committed by
Fran Garcia-Linares
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3508450
by jonathan1055: run-local-checks should ignore vendor and node_modules
parent
0ea8352c
No related branches found
No related tags found
1 merge request
!333
#3508450 Improvments to run-local-checks
Pipeline
#440618
passed
3 weeks ago
Stage: test
Changes
2
Pipelines
10
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/run-local-checks.sh
+9
-5
9 additions, 5 deletions
scripts/run-local-checks.sh
scripts/unformatted-links.php
+15
-13
15 additions, 13 deletions
scripts/unformatted-links.php
with
24 additions
and
18 deletions
scripts/run-local-checks.sh
+
9
−
5
View file @
ccdc0787
#!/bin/bash
# Launch from the root of this project: "./scripts/run-local-checks.sh [fix] [clean]".
# Launch from the root of this project: "./scripts/run-local-checks.sh [fix]
[debug]
[clean]".
#
# Optional arguments:
# fix - to run the fixer options of eslint and phpcs.
# debug - to show verbose output.
# clean - to remove the installed software and files copied from assets.
#
# Helper script to run all the checks that will be run via GitLab CI.
...
...
@@ -25,13 +26,16 @@ php scripts/prepare-cspell.php
npm
install
composer
install
EXIT_CODE
=
0
npx cspell
--show-suggestions
--show-context
--no-progress
--dot
{
**
,.
**
}
||
EXIT_CODE
=
$((
EXIT_CODE+1
))
NO_PROGRESS
=
$(
[[
"
$1
"
==
"debug"
]]
&&
echo
""
||
echo
"--no-progress"
)
;
npx cspell
--show-suggestions
--show-context
--dot
$NO_PROGRESS
{
**
,.
**
}
||
EXIT_CODE
=
$((
EXIT_CODE+1
))
ESLINT_FIX
=
$(
[[
"
$1
"
==
"fix"
]]
&&
echo
"--fix"
||
echo
""
)
;
npx eslint
--no-error-on-unmatched-pattern
--ext
=
.yml
$ESLINT_FIX
.
&&
echo
"ESLint passed."
||
EXIT_CODE
=
$((
EXIT_CODE+1
))
DEBUG
=
$(
[[
"
$1
"
==
"debug"
]]
&&
echo
"--debug"
||
echo
""
)
;
npx eslint
--no-error-on-unmatched-pattern
--ignore-pattern
=
vendor
--ignore-pattern
=
node_modules
--ext
=
.yml
$DEBUG
$ESLINT_FIX
.
&&
echo
"ESLint passed."
||
EXIT_CODE
=
$((
EXIT_CODE+1
))
[[
"
$1
"
==
"fix"
]]
&&
vendor/bin/phpcbf
--colors
scripts/
*
.php
-s
vendor/bin/phpcs
--colors
scripts/
*
.php
-s
&&
echo
"PHPCS passed."
||
EXIT_CODE
=
$((
EXIT_CODE+1
))
VERBOSE
=
$(
[[
"
$1
"
==
"debug"
]]
&&
echo
"-v"
||
echo
""
)
;
vendor/bin/phpcs
--colors
scripts/
*
.php
-s
$VERBOSE
&&
echo
"PHPCS passed."
||
EXIT_CODE
=
$((
EXIT_CODE+1
))
shellcheck scripts/
*
.sh
&&
echo
"Shellcheck passed."
||
EXIT_CODE
=
$((
EXIT_CODE+1
))
php scripts/unformatted-links.php
||
EXIT_CODE
=
$((
EXIT_CODE+1
))
php scripts/unformatted-links.php
$VERBOSE
||
EXIT_CODE
=
$((
EXIT_CODE+1
))
[[
"
$EXIT_CODE
"
!=
0
]]
&&
echo
-e
"
\n
===========================
\n
Number of failed checks:
$EXIT_CODE
\n
===========================
\n
"
||
echo
"= All OK ="
# Clean up all files that were copied.
...
...
This diff is collapsed.
Click to expand it.
scripts/unformatted-links.php
+
15
−
13
View file @
ccdc0787
...
...
@@ -7,56 +7,58 @@
* Arguments:
* -p --path path Path to search in. Default is 'docs'. Do not include *.
* Partial paths will be matched.
* -v --verbose Show verbose debug output.
* -d --debug Show debug output.
* -v --verbose Show more verbose detailed output.
*/
// Get the options.
$options
=
getopt
(
'p:v'
,
[
'path:'
,
'verbose'
]);
$quiet
=
!
array_key_exists
(
'v'
,
$options
)
&&
!
array_key_exists
(
'verbose'
,
$options
);
$options
=
getopt
(
'p:dv'
,
[
'path:'
,
'debug'
,
'verbose'
]);
$verbose
=
array_key_exists
(
'v'
,
$options
)
||
array_key_exists
(
'verbose'
,
$options
);
$debug
=
$verbose
||
array_key_exists
(
'd'
,
$options
)
||
array_key_exists
(
'debug'
,
$options
);
$path
=
$options
[
'p'
]
??
$options
[
'path'
]
??
'./docs'
;
$quiet
?:
print
"
quiet=
$quiet
\n
path=
$path
\n
"
;
!
$debug
?:
print
"
path=
$path
\n
debug=
$debug
\n
verbose=
$verbose
\n
"
;
$found
=
0
;
$code_block
=
FALSE
;
// Allow for optional / before second { } pattern for partial paths.
$files
=
array_values
(
array_unique
(
glob
(
$path
.
'{,/}{*.md,**/*.md}'
,
GLOB_BRACE
)));
$quiet
?:
print
".md files found: "
.
count
(
$files
)
.
"
\n
"
.
print_r
(
$files
,
TRUE
)
.
"
\n
"
;
!
$debug
?:
print
".md files found: "
.
count
(
$files
)
.
"
\n
"
.
print_r
(
$files
,
TRUE
)
.
"
\n
"
;
foreach
(
$files
as
$f
=>
$filename
)
{
$lines
=
file
(
$filename
);
$quiet
?:
print
"===== file
{
$f
}
=
{
$filename
}
\n
lines="
.
print_r
(
$lines
,
TRUE
)
.
PHP_EOL
;
!
$verbose
?:
print
"===== file
{
$f
}
=
{
$filename
}
\n
lines="
.
print_r
(
$lines
,
TRUE
)
.
PHP_EOL
;
foreach
(
$lines
as
$lnum
=>
$text
)
{
switch
(
TRUE
)
{
// Detect when a code block begins and ends.
case
strstr
(
$text
,
"```"
)
:
$code_block
=
!
$code_block
;
$quiet
?:
print
$lnum
.
' $code_block changed to '
.
(
$code_block
?
'true'
:
'false'
)
.
' in: '
.
$text
;
!
$verbose
?:
print
$lnum
.
' $code_block changed to '
.
(
$code_block
?
'true'
:
'false'
)
.
' in: '
.
$text
;
break
;
// If the line does not contain http or we are still in a code block then
// move on to the next line.
case
!
stristr
(
$text
,
'http'
)
||
$code_block
:
$quiet
?:
print
$lnum
.
' No http or still in code block in: '
.
$text
;
!
$verbose
?:
print
$lnum
.
' No http or still in code block in: '
.
$text
;
break
;
// If the http is part of an inline code block then it is OK.
case
preg_match
(
'/`.*http.*`/'
,
$text
,
$matches
)
:
$quiet
?:
print
$lnum
.
' Found inline code with http so ignore: '
.
$text
;
$quiet
?:
print_r
(
$matches
,
TRUE
);
!
$verbose
?:
print
$lnum
.
' Found inline code with http so ignore: '
.
$text
;
!
$verbose
?:
print_r
(
$matches
,
TRUE
);
break
;
// If the http link is properly formatted with [text](url) then it is OK.
// Note that this only checking the markup, not validating the url format.
case
preg_match
(
'/\[.+\]\(http.+\)/'
,
$text
,
$matches
)
:
$quiet
?:
print
$lnum
.
' Link is correctly formatted in '
.
$text
.
'$matches='
.
print_r
(
$matches
,
TRUE
)
.
PHP_EOL
;
!
$verbose
?:
print
$lnum
.
' Link is correctly formatted in '
.
$text
.
'$matches='
.
print_r
(
$matches
,
TRUE
)
.
PHP_EOL
;
break
;
// Report all remaining 'http' as these are formatted incorrectly.
default
:
print
str_repeat
(
'-'
,
80
)
.
"
\n
$filename
:"
.
(
$lnum
+
1
)
.
"
\n
$text
"
;
$found
++
;
$quiet
?:
print
$lnum
.
' Found bad link in '
.
$text
.
'$found='
.
$found
.
PHP_EOL
;
!
$verbose
?:
print
$lnum
.
' Found bad link in '
.
$text
.
'$found='
.
$found
.
PHP_EOL
;
break
;
}
...
...
@@ -65,5 +67,5 @@ foreach ($files as $f => $filename) {
$found
>
0
?
print
str_repeat
(
'-'
,
80
)
.
"
\n
To fix these links use the syntax: [text to show](url)
\n
"
:
NULL
;
print
"Unformatted links: Files searched in
{
$path
}
: "
.
count
(
$files
)
.
", Issues found:
{
$found
}
\n
"
;
$exit_code
=
$found
?
1
:
0
;
$quiet
?:
print
"Ending with exit_code
{
$exit_code
}
"
.
PHP_EOL
;
!
$debug
?:
print
"Ending with exit_code
{
$exit_code
}
"
.
PHP_EOL
;
exit
(
$exit_code
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment