Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
51b03f1e
Commit
51b03f1e
authored
Sep 17, 2020
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `ci_if_parenthesis_enabled` feature flag
This removes a feature flag for proven feature.
parent
4b82e445
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
133 deletions
+19
-133
config/feature_flags/development/ci_if_parenthesis_enabled.yml
...g/feature_flags/development/ci_if_parenthesis_enabled.yml
+0
-7
lib/gitlab/ci/features.rb
lib/gitlab/ci/features.rb
+0
-4
lib/gitlab/ci/pipeline/expression/lexer.rb
lib/gitlab/ci/pipeline/expression/lexer.rb
+1
-19
lib/gitlab/ci/pipeline/expression/parser.rb
lib/gitlab/ci/pipeline/expression/parser.rb
+1
-27
spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb
spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb
+1
-18
spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
+16
-58
No files found.
config/feature_flags/development/ci_if_parenthesis_enabled.yml
deleted
100644 → 0
View file @
4b82e445
---
name
:
ci_if_parenthesis_enabled
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37574
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/238174
group
:
group::ci
type
:
development
default_enabled
:
true
\ No newline at end of file
lib/gitlab/ci/features.rb
View file @
51b03f1e
...
...
@@ -39,10 +39,6 @@ module Gitlab
::
Feature
.
enabled?
(
:ci_bulk_insert_on_create
,
project
,
default_enabled:
true
)
end
def
self
.
ci_if_parenthesis_enabled?
::
Feature
.
enabled?
(
:ci_if_parenthesis_enabled
,
default_enabled:
true
)
end
# NOTE: The feature flag `disallow_to_create_merge_request_pipelines_in_target_project`
# is a safe switch to disable the feature for a parituclar project when something went wrong,
# therefore it's not supposed to be enabled by default.
...
...
lib/gitlab/ci/pipeline/expression/lexer.rb
View file @
51b03f1e
...
...
@@ -24,26 +24,8 @@ module Gitlab
Expression
::
Lexeme
::
Or
].
freeze
# To be removed with `ci_if_parenthesis_enabled`
LEGACY_LEXEMES
=
[
Expression
::
Lexeme
::
Variable
,
Expression
::
Lexeme
::
String
,
Expression
::
Lexeme
::
Pattern
,
Expression
::
Lexeme
::
Null
,
Expression
::
Lexeme
::
Equals
,
Expression
::
Lexeme
::
Matches
,
Expression
::
Lexeme
::
NotEquals
,
Expression
::
Lexeme
::
NotMatches
,
Expression
::
Lexeme
::
And
,
Expression
::
Lexeme
::
Or
].
freeze
def
self
.
lexemes
if
::
Gitlab
::
Ci
::
Features
.
ci_if_parenthesis_enabled?
LEXEMES
else
LEGACY_LEXEMES
end
LEXEMES
end
MAX_TOKENS
=
100
...
...
lib/gitlab/ci/pipeline/expression/parser.rb
View file @
51b03f1e
...
...
@@ -15,12 +15,7 @@ module Gitlab
def
tree
results
=
[]
tokens
=
if
::
Gitlab
::
Ci
::
Features
.
ci_if_parenthesis_enabled?
tokens_rpn
else
legacy_tokens_rpn
end
tokens
=
tokens_rpn
tokens
.
each
do
|
token
|
case
token
.
type
...
...
@@ -78,27 +73,6 @@ module Gitlab
output
.
concat
(
operators
.
reverse
)
end
# To be removed with `ci_if_parenthesis_enabled`
def
legacy_tokens_rpn
output
=
[]
operators
=
[]
@tokens
.
each
do
|
token
|
case
token
.
type
when
:value
output
.
push
(
token
)
when
:logical_operator
if
operators
.
any?
&&
token
.
lexeme
.
precedence
>=
operators
.
last
.
lexeme
.
precedence
output
.
push
(
operators
.
pop
)
end
operators
.
push
(
token
)
end
end
output
.
concat
(
operators
.
reverse
)
end
end
end
end
...
...
spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb
View file @
51b03f1e
...
...
@@ -90,24 +90,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexer do
end
with_them
do
context
'when ci_if_parenthesis_enabled is enabled'
do
before
do
stub_feature_flags
(
ci_if_parenthesis_enabled:
true
)
end
it
{
is_expected
.
to
eq
(
tokens
)
}
end
context
'when ci_if_parenthesis_enabled is disabled'
do
before
do
stub_feature_flags
(
ci_if_parenthesis_enabled:
false
)
end
it
do
expect
{
subject
}
.
to
raise_error
described_class
::
SyntaxError
end
end
it
{
is_expected
.
to
eq
(
tokens
)
}
end
end
end
...
...
spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
View file @
51b03f1e
...
...
@@ -3,10 +3,6 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Ci
::
Pipeline
::
Expression
::
Parser
do
before
do
stub_feature_flags
(
ci_if_parenthesis_enabled:
true
)
end
describe
'#tree'
do
context
'validates simple operators'
do
using
RSpec
::
Parameterized
::
TableSyntax
...
...
@@ -31,36 +27,15 @@ RSpec.describe Gitlab::Ci::Pipeline::Expression::Parser do
context
'when combining && and OR operators'
do
subject
{
described_class
.
seed
(
'$VAR1 == "a" || $VAR2 == "b" && $VAR3 == "c" || $VAR4 == "d" && $VAR5 == "e"'
).
tree
}
context
'when parenthesis engine is enabled'
do
before
do
stub_feature_flags
(
ci_if_parenthesis_enabled:
true
)
end
it
'returns operations in a correct order'
do
expect
(
subject
.
inspect
)
.
to
eq
(
'or(or(equals($VAR1, "a"), and(equals($VAR2, "b"), equals($VAR3, "c"))), and(equals($VAR4, "d"), equals($VAR5, "e")))'
)
end
end
context
'when parenthesis engine is disabled (legacy)'
do
before
do
stub_feature_flags
(
ci_if_parenthesis_enabled:
false
)
end
it
'returns operations in a invalid order'
do
expect
(
subject
.
inspect
)
.
to
eq
(
'or(equals($VAR1, "a"), and(equals($VAR2, "b"), or(equals($VAR3, "c"), and(equals($VAR4, "d"), equals($VAR5, "e")))))'
)
end
it
'returns operations in a correct order'
do
expect
(
subject
.
inspect
)
.
to
eq
(
'or(or(equals($VAR1, "a"), and(equals($VAR2, "b"), equals($VAR3, "c"))), and(equals($VAR4, "d"), equals($VAR5, "e")))'
)
end
end
context
'when using parenthesis'
do
subject
{
described_class
.
seed
(
'(($VAR1 == "a" || $VAR2 == "b") && $VAR3 == "c" || $VAR4 == "d") && $VAR5 == "e"'
).
tree
}
before
do
stub_feature_flags
(
ci_if_parenthesis_enabled:
true
)
end
it
'returns operations in a correct order'
do
expect
(
subject
.
inspect
)
.
to
eq
(
'and(or(and(or(equals($VAR1, "a"), equals($VAR2, "b")), equals($VAR3, "c")), equals($VAR4, "d")), equals($VAR5, "e"))'
)
...
...
@@ -96,38 +71,21 @@ RSpec.describe Gitlab::Ci::Pipeline::Expression::Parser do
end
context
'when parenthesis are unmatched'
do
context
'when parenthesis engine is enabled'
do
before
do
stub_feature_flags
(
ci_if_parenthesis_enabled:
true
)
end
where
(
:expression
)
do
[
'$VAR == ('
,
'$VAR2 == ("aa"'
,
'$VAR2 == ("aa"))'
,
'$VAR2 == "aa")'
,
'(($VAR2 == "aa")'
,
'($VAR2 == "aa"))'
]
end
with_them
do
it
'raises a ParseError'
do
expect
{
described_class
.
seed
(
expression
).
tree
}
.
to
raise_error
Gitlab
::
Ci
::
Pipeline
::
Expression
::
Parser
::
ParseError
end
end
where
(
:expression
)
do
[
'$VAR == ('
,
'$VAR2 == ("aa"'
,
'$VAR2 == ("aa"))'
,
'$VAR2 == "aa")'
,
'(($VAR2 == "aa")'
,
'($VAR2 == "aa"))'
]
end
context
'when parenthesis engine is disabled'
do
before
do
stub_feature_flags
(
ci_if_parenthesis_enabled:
false
)
end
it
'raises an SyntaxError'
do
expect
{
described_class
.
seed
(
'$VAR == ('
).
tree
}
.
to
raise_error
Gitlab
::
Ci
::
Pipeline
::
Expression
::
Lexer
::
SyntaxError
with_them
do
it
'raises a ParseError'
do
expect
{
described_class
.
seed
(
expression
).
tree
}
.
to
raise_error
Gitlab
::
Ci
::
Pipeline
::
Expression
::
Parser
::
ParseError
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment