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
bd88dfaf
Commit
bd88dfaf
authored
Jan 12, 2021
by
Lin Jen-Shin
Committed by
Albert Salim
Jan 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `.rb` as the script name so it can be required
parent
8744311a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
18 deletions
+40
-18
.gitlab/ci/review.gitlab-ci.yml
.gitlab/ci/review.gitlab-ci.yml
+3
-3
danger/frozen_string/Dangerfile
danger/frozen_string/Dangerfile
+24
-5
scripts/api/cancel_pipeline.rb
scripts/api/cancel_pipeline.rb
+0
-0
scripts/api/download_job_artifact.rb
scripts/api/download_job_artifact.rb
+0
-0
scripts/api/get_job_id.rb
scripts/api/get_job_id.rb
+0
-0
scripts/api/play_job.rb
scripts/api/play_job.rb
+6
-3
scripts/rspec_helpers.sh
scripts/rspec_helpers.sh
+5
-5
scripts/utils.sh
scripts/utils.sh
+2
-2
No files found.
.gitlab/ci/review.gitlab-ci.yml
View file @
bd88dfaf
...
@@ -38,7 +38,7 @@ review-build-cng:
...
@@ -38,7 +38,7 @@ review-build-cng:
-
BUILD_TRIGGER_TOKEN=$REVIEW_APPS_BUILD_TRIGGER_TOKEN ./scripts/trigger-build cng
-
BUILD_TRIGGER_TOKEN=$REVIEW_APPS_BUILD_TRIGGER_TOKEN ./scripts/trigger-build cng
# When the job is manual, review-deploy is also manual and we don't want people
# When the job is manual, review-deploy is also manual and we don't want people
# to have to manually start the jobs in sequence, so we do it for them.
# to have to manually start the jobs in sequence, so we do it for them.
-
'
[
-z
$CI_JOB_MANUAL
]
||
scripts/api/play_job
--job-name
"review-deploy"'
-
'
[
-z
$CI_JOB_MANUAL
]
||
scripts/api/play_job
.rb
--job-name
"review-deploy"'
.review-workflow-base
:
.review-workflow-base
:
extends
:
extends
:
...
@@ -78,8 +78,8 @@ review-deploy:
...
@@ -78,8 +78,8 @@ review-deploy:
-
disable_sign_ups || (delete_release && exit 1)
-
disable_sign_ups || (delete_release && exit 1)
# When the job is manual, review-qa-smoke is also manual and we don't want people
# When the job is manual, review-qa-smoke is also manual and we don't want people
# to have to manually start the jobs in sequence, so we do it for them.
# to have to manually start the jobs in sequence, so we do it for them.
-
'
[
-z
$CI_JOB_MANUAL
]
||
scripts/api/play_job
--job-name
"review-qa-smoke"'
-
'
[
-z
$CI_JOB_MANUAL
]
||
scripts/api/play_job
.rb
--job-name
"review-qa-smoke"'
-
'
[
-z
$CI_JOB_MANUAL
]
||
scripts/api/play_job
--job-name
"review-performance"'
-
'
[
-z
$CI_JOB_MANUAL
]
||
scripts/api/play_job
.rb
--job-name
"review-performance"'
after_script
:
after_script
:
# Run seed-dast-test-data.sh only when DAST_RUN is set to true. This is to pupulate review app with data for DAST scan.
# Run seed-dast-test-data.sh only when DAST_RUN is set to true. This is to pupulate review app with data for DAST scan.
# Set DAST_RUN to true when jobs are manually scheduled.
# Set DAST_RUN to true when jobs are manually scheduled.
...
...
danger/frozen_string/Dangerfile
View file @
bd88dfaf
# frozen_string_literal: true
# frozen_string_literal: true
FILE_EXTENSION
=
".rb"
FILE_EXTENSION
=
".rb"
MAGIC_COMMENT
=
"# frozen_string_literal: true"
FROZEN_STRING_MAGIC_COMMENT
=
"# frozen_string_literal: true"
SHEBANG_COMMENT
=
"#!"
def
get_files_with_no_magic_comment
(
files
)
def
get_files_with_no_magic_comment
(
files
)
files
.
select
do
|
file
|
files
.
select
do
|
path
|
file
.
end_with?
(
FILE_EXTENSION
)
&&
path
.
end_with?
(
FILE_EXTENSION
)
&&
!
File
.
open
(
file
,
&
:gets
)
&
.
start_with?
(
MAGIC_COMMENT
)
file_has_frozen_string_magic_comment?
(
path
)
end
end
end
end
def
file_has_frozen_string_magic_comment?
(
path
)
File
.
open
(
path
)
do
|
file
|
first_line
=
file
.
gets
line_has_frozen_string_magic_comment?
(
first_line
)
||
(
line_has_shebang?
(
first_line
)
&&
line_has_frozen_string_magic_comment?
(
file
.
gets
))
end
end
def
line_has_frozen_string_magic_comment?
(
line
)
line
&
.
start_with?
(
FROZEN_STRING_MAGIC_COMMENT
)
end
def
line_has_shebang?
(
line
)
line
&
.
start_with?
(
SHEBANG_COMMENT
)
end
files_to_fix
=
get_files_with_no_magic_comment
(
git
.
added_files
)
files_to_fix
=
get_files_with_no_magic_comment
(
git
.
added_files
)
if
files_to_fix
.
any?
if
files_to_fix
.
any?
...
@@ -20,7 +39,7 @@ if files_to_fix.any?
...
@@ -20,7 +39,7 @@ if files_to_fix.any?
markdown
(
<<~
MARKDOWN
)
markdown
(
<<~
MARKDOWN
)
## Enable Frozen String Literal
## Enable Frozen String Literal
The following files should have `
#{
MAGIC_COMMENT
}
` on the first line:
The following files should have `
#{
FROZEN_STRING_
MAGIC_COMMENT
}
` on the first line:
*
#{
files_to_fix
.
map
{
|
path
|
"`
#{
path
}
`"
}
.join("
\n
* ")}
*
#{
files_to_fix
.
map
{
|
path
|
"`
#{
path
}
`"
}
.join("
\n
* ")}
MARKDOWN
MARKDOWN
...
...
scripts/api/cancel_pipeline
→
scripts/api/cancel_pipeline
.rb
View file @
bd88dfaf
File moved
scripts/api/download_job_artifact
→
scripts/api/download_job_artifact
.rb
View file @
bd88dfaf
File moved
scripts/api/get_job_id
→
scripts/api/get_job_id
.rb
View file @
bd88dfaf
File moved
scripts/api/play_job
→
scripts/api/play_job
.rb
View file @
bd88dfaf
...
@@ -14,7 +14,6 @@ class PlayJob
...
@@ -14,7 +14,6 @@ class PlayJob
}.
freeze
}.
freeze
def
initialize
(
options
)
def
initialize
(
options
)
@project
=
options
.
delete
(
:project
)
@options
=
options
@options
=
options
Gitlab
.
configure
do
|
config
|
Gitlab
.
configure
do
|
config
|
...
@@ -24,14 +23,18 @@ class PlayJob
...
@@ -24,14 +23,18 @@ class PlayJob
end
end
def
execute
def
execute
job
=
JobFinder
.
new
(
project
,
options
.
slice
(
:api_token
,
:pipeline_id
,
:job_name
).
merge
(
scope:
'manual'
)).
execute
job
=
JobFinder
.
new
(
options
.
slice
(
:project
,
:api_token
,
:pipeline_id
,
:job_name
).
merge
(
scope:
'manual'
)).
execute
Gitlab
.
job_play
(
project
,
job
.
id
)
Gitlab
.
job_play
(
project
,
job
.
id
)
end
end
private
private
attr_reader
:project
,
:options
attr_reader
:options
def
project
options
[
:project
]
end
end
end
if
$0
==
__FILE__
if
$0
==
__FILE__
...
...
scripts/rspec_helpers.sh
View file @
bd88dfaf
...
@@ -7,14 +7,14 @@ function retrieve_tests_metadata() {
...
@@ -7,14 +7,14 @@ function retrieve_tests_metadata() {
local
test_metadata_job_id
local
test_metadata_job_id
# Ruby
# Ruby
test_metadata_job_id
=
$(
scripts/api/get_job_id
--project
"
${
project_path
}
"
-q
"status=success"
-q
"ref=master"
-q
"username=gitlab-bot"
-Q
"scope=success"
--job-name
"update-tests-metadata"
)
test_metadata_job_id
=
$(
scripts/api/get_job_id
.rb
--project
"
${
project_path
}
"
-q
"status=success"
-q
"ref=master"
-q
"username=gitlab-bot"
-Q
"scope=success"
--job-name
"update-tests-metadata"
)
if
[[
!
-f
"
${
KNAPSACK_RSPEC_SUITE_REPORT_PATH
}
"
]]
;
then
if
[[
!
-f
"
${
KNAPSACK_RSPEC_SUITE_REPORT_PATH
}
"
]]
;
then
scripts/api/download_job_artifact
--project
"
${
project_path
}
"
--job-id
"
${
test_metadata_job_id
}
"
--artifact-path
"
${
KNAPSACK_RSPEC_SUITE_REPORT_PATH
}
"
||
echo
"{}"
>
"
${
KNAPSACK_RSPEC_SUITE_REPORT_PATH
}
"
scripts/api/download_job_artifact
.rb
--project
"
${
project_path
}
"
--job-id
"
${
test_metadata_job_id
}
"
--artifact-path
"
${
KNAPSACK_RSPEC_SUITE_REPORT_PATH
}
"
||
echo
"{}"
>
"
${
KNAPSACK_RSPEC_SUITE_REPORT_PATH
}
"
fi
fi
if
[[
!
-f
"
${
FLAKY_RSPEC_SUITE_REPORT_PATH
}
"
]]
;
then
if
[[
!
-f
"
${
FLAKY_RSPEC_SUITE_REPORT_PATH
}
"
]]
;
then
scripts/api/download_job_artifact
--project
"
${
project_path
}
"
--job-id
"
${
test_metadata_job_id
}
"
--artifact-path
"
${
FLAKY_RSPEC_SUITE_REPORT_PATH
}
"
||
echo
"{}"
>
"
${
FLAKY_RSPEC_SUITE_REPORT_PATH
}
"
scripts/api/download_job_artifact
.rb
--project
"
${
project_path
}
"
--job-id
"
${
test_metadata_job_id
}
"
--artifact-path
"
${
FLAKY_RSPEC_SUITE_REPORT_PATH
}
"
||
echo
"{}"
>
"
${
FLAKY_RSPEC_SUITE_REPORT_PATH
}
"
fi
fi
}
}
...
@@ -42,10 +42,10 @@ function retrieve_tests_mapping() {
...
@@ -42,10 +42,10 @@ function retrieve_tests_mapping() {
local
project_path
=
"gitlab-org/gitlab"
local
project_path
=
"gitlab-org/gitlab"
local
test_metadata_with_mapping_job_id
local
test_metadata_with_mapping_job_id
test_metadata_with_mapping_job_id
=
$(
scripts/api/get_job_id
--project
"
${
project_path
}
"
-q
"status=success"
-q
"ref=master"
-q
"username=gitlab-bot"
-Q
"scope=success"
--job-name
"update-tests-metadata"
--artifact-path
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
.gz"
)
test_metadata_with_mapping_job_id
=
$(
scripts/api/get_job_id
.rb
--project
"
${
project_path
}
"
-q
"status=success"
-q
"ref=master"
-q
"username=gitlab-bot"
-Q
"scope=success"
--job-name
"update-tests-metadata"
--artifact-path
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
.gz"
)
if
[[
!
-f
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
"
]]
;
then
if
[[
!
-f
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
"
]]
;
then
(
scripts/api/download_job_artifact
--project
"
${
project_path
}
"
--job-id
"
${
test_metadata_with_mapping_job_id
}
"
--artifact-path
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
.gz"
&&
gzip
-d
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
.gz"
)
||
echo
"{}"
>
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
"
(
scripts/api/download_job_artifact
.rb
--project
"
${
project_path
}
"
--job-id
"
${
test_metadata_with_mapping_job_id
}
"
--artifact-path
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
.gz"
&&
gzip
-d
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
.gz"
)
||
echo
"{}"
>
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
"
fi
fi
scripts/unpack-test-mapping
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
"
"
${
RSPEC_TESTS_MAPPING_PATH
}
"
scripts/unpack-test-mapping
"
${
RSPEC_PACKED_TESTS_MAPPING_PATH
}
"
"
${
RSPEC_TESTS_MAPPING_PATH
}
"
...
...
scripts/utils.sh
View file @
bd88dfaf
...
@@ -89,12 +89,12 @@ function echosuccess() {
...
@@ -89,12 +89,12 @@ function echosuccess() {
function
fail_pipeline_early
()
{
function
fail_pipeline_early
()
{
local
dont_interrupt_me_job_id
local
dont_interrupt_me_job_id
dont_interrupt_me_job_id
=
$(
scripts/api/get_job_id
--job-query
"scope=success"
--job-name
"dont-interrupt-me"
)
dont_interrupt_me_job_id
=
$(
scripts/api/get_job_id
.rb
--job-query
"scope=success"
--job-name
"dont-interrupt-me"
)
if
[[
-n
"
${
dont_interrupt_me_job_id
}
"
]]
;
then
if
[[
-n
"
${
dont_interrupt_me_job_id
}
"
]]
;
then
echoinfo
"This pipeline cannot be interrupted due to
\`
dont-interrupt-me
\`
job
${
dont_interrupt_me_job_id
}
"
echoinfo
"This pipeline cannot be interrupted due to
\`
dont-interrupt-me
\`
job
${
dont_interrupt_me_job_id
}
"
else
else
echoinfo
"Failing pipeline early for fast feedback due to test failures in rspec fail-fast."
echoinfo
"Failing pipeline early for fast feedback due to test failures in rspec fail-fast."
scripts/api/cancel_pipeline
scripts/api/cancel_pipeline
.rb
fi
fi
}
}
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