Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gitlab-ci
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
gitlab-ci
Commits
98dd456a
Commit
98dd456a
authored
2 years ago
by
Grzegorz Rola
Browse files
Options
Downloads
Patches
Plain Diff
Feature/version cohesion
parent
9aff031b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
gitlab-ci-1.2.yml
+1
-25
1 addition, 25 deletions
gitlab-ci-1.2.yml
includes/tests/version-cohesion.yml
+49
-0
49 additions, 0 deletions
includes/tests/version-cohesion.yml
with
50 additions
and
25 deletions
gitlab-ci-1.2.yml
+
1
−
25
View file @
98dd456a
...
...
@@ -32,6 +32,7 @@ include:
-
'
/includes/tests/lint.yml'
-
'
/includes/tests/unit.yml'
-
'
/includes/metrics.yml'
-
'
/includes/tests/version-cohesion.yml'
-
'
/includes/tests/codeception-integration.yml'
-
'
/includes/tests/codeception.yml'
-
'
/includes/tests/codeception-parallel.yml'
...
...
@@ -39,28 +40,3 @@ include:
-
'
/includes/tests/integration.yml'
-
'
/includes/deploy.yml'
-
'
/includes/pages.yml'
check version cohesion
:
stage
:
tests
tags
:
-
deploy
rules
:
-
if
:
$IS_LIBRARY
when
:
never
-
if
:
$CI_COMMIT_TAG
script
:
# official semver regex: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
-
SEMVER_REGEX="(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"
-
SEMVER_PART="(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"
-
if [[ "$(grep -h 'Version:' *.php | grep -oP $SEMVER_REGEX)" != "$CI_COMMIT_REF_NAME" ]]; then exit 1; fi
-
if [[ "$(grep -h '$plugin_version' *.php | grep -oP $SEMVER_REGEX)" != "$CI_COMMIT_REF_NAME" ]]; then exit 1; fi
-
|
if [[ -f readme.txt ]]; then
# skip check if it's preproduction version
if [[ "$(echo $CI_COMMIT_REF_NAME | grep -oP $SEMVER_PART)" ]]; then
exit 0
else
if [[ "$(grep -h 'Stable tag:' readme.txt | grep -oP $SEMVER_REGEX)" != "$CI_COMMIT_REF_NAME" ]]; then exit 1; fi
fi
fi
This diff is collapsed.
Click to expand it.
includes/tests/version-cohesion.yml
0 → 100644
+
49
−
0
View file @
98dd456a
.template
:
&job-check-version-cohesion
stage
:
tests
variables
:
PLUGIN_VERSION
:
${CI_COMMIT_REF_NAME}
tags
:
-
deploy
before_script
:
-
echo "Plugin version from tag ${PLUGIN_VERSION}"
script
:
# official semver regex: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
-
SEMVER_REGEX="(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"
-
SEMVER_PART="(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"
-
echo "Checking plugin version in plugin header"
-
if [[ "$(grep -h 'Version:' *.php | grep -oP $SEMVER_REGEX)" != "$PLUGIN_VERSION" ]]; then exit 1; fi
-
echo "Checking plugin version in variable"
-
if [[ "$(grep -h '$plugin_version' *.php | grep -oP $SEMVER_REGEX)" != "$PLUGIN_VERSION" ]]; then exit 1; fi
-
|
if [[ -f readme.txt ]]; then
# skip check if it's preproduction version
if [[ "$(echo $PLUGIN_VERSION | grep -oP $SEMVER_PART)" ]]; then
exit 0
else
echo "Checking plugin version in readme.txt"
if [[ "$(grep -h 'Stable tag:' readme.txt | grep -oP $SEMVER_REGEX)" != "$PLUGIN_VERSION" ]]; then exit 1; fi
fi
fi
check version cohesion tag
:
<<
:
*job-check-version-cohesion
except
:
variables
:
-
$IS_LIBRARY
-
$IS_NPM_LIBRARY
only
:
refs
:
-
tags
check version cohesion
:
<<
:
*job-check-version-cohesion
allow_failure
:
true
except
:
variables
:
-
$IS_LIBRARY
-
$IS_NPM_LIBRARY
refs
:
-
tags
before_script
:
-
PLUGIN_VERSION=`grep -h 'Version' *.php | grep -oE '([0-9]+.?)+'`
-
echo "Plugin version from plugin file ${PLUGIN_VERSION}"
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