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
12d7c00f
Commit
12d7c00f
authored
Aug 16, 2021
by
Albert Salim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract list of changed files to artifact
parent
0fd00976
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
16 deletions
+29
-16
.gitlab/ci/setup.gitlab-ci.yml
.gitlab/ci/setup.gitlab-ci.yml
+6
-2
tooling/bin/find_changes
tooling/bin/find_changes
+21
-0
tooling/bin/find_tests
tooling/bin/find_tests
+2
-14
No files found.
.gitlab/ci/setup.gitlab-ci.yml
View file @
12d7c00f
...
@@ -70,11 +70,13 @@ verify-tests-yml:
...
@@ -70,11 +70,13 @@ verify-tests-yml:
-
install_gitlab_gem
-
install_gitlab_gem
-
install_tff_gem
-
install_tff_gem
-
retrieve_tests_mapping
-
retrieve_tests_mapping
-
'
if
[
-n
"$CI_MERGE_REQUEST_IID"
];
then
tooling/bin/find_tests
${MATCHED_TESTS_FILE};
fi'
-
'
if
[
-n
"$CI_MERGE_REQUEST_IID"
];
then
tooling/bin/find_changes
${CHANGES_FILE};
fi'
-
'
if
[
-n
"$CI_MERGE_REQUEST_IID"
];
then
echo
"test
files
affected:
$(cat
$MATCHED_TESTS_FILE)";
fi'
-
'
if
[
-n
"$CI_MERGE_REQUEST_IID"
];
then
tooling/bin/find_tests
${CHANGES_FILE}
${MATCHED_TESTS_FILE};
fi'
-
'
if
[
-n
"$CI_MERGE_REQUEST_IID"
];
then
echo
"related
rspec
tests:
$(cat
$MATCHED_TESTS_FILE)";
fi'
artifacts
:
artifacts
:
expire_in
:
7d
expire_in
:
7d
paths
:
paths
:
-
${CHANGES_FILE}
-
${MATCHED_TESTS_FILE}
-
${MATCHED_TESTS_FILE}
detect-tests
:
detect-tests
:
...
@@ -83,6 +85,7 @@ detect-tests:
...
@@ -83,6 +85,7 @@ detect-tests:
-
.rails:rules:detect-tests
-
.rails:rules:detect-tests
variables
:
variables
:
RSPEC_TESTS_MAPPING_ENABLED
:
"
true"
RSPEC_TESTS_MAPPING_ENABLED
:
"
true"
CHANGES_FILE
:
tmp/changed_files.txt
MATCHED_TESTS_FILE
:
tmp/matching_tests.txt
MATCHED_TESTS_FILE
:
tmp/matching_tests.txt
detect-tests as-if-foss
:
detect-tests as-if-foss
:
...
@@ -91,6 +94,7 @@ detect-tests as-if-foss:
...
@@ -91,6 +94,7 @@ detect-tests as-if-foss:
-
.rails:rules:detect-tests
-
.rails:rules:detect-tests
-
.as-if-foss
-
.as-if-foss
variables
:
variables
:
CHANGES_FILE
:
tmp/changed_foss_files.txt
MATCHED_TESTS_FILE
:
tmp/matching_foss_tests.txt
MATCHED_TESTS_FILE
:
tmp/matching_foss_tests.txt
before_script
:
before_script
:
-
'
[
"$FOSS_ONLY"
=
"1"
]
&&
rm
-rf
ee/
qa/spec/ee/
qa/qa/specs/features/ee/
qa/qa/ee/
qa/qa/ee.rb'
-
'
[
"$FOSS_ONLY"
=
"1"
]
&&
rm
-rf
ee/
qa/spec/ee/
qa/qa/specs/features/ee/
qa/qa/ee/
qa/qa/ee.rb'
tooling/bin/find_changes
0 → 100755
View file @
12d7c00f
#!/usr/bin/env ruby
# frozen_string_literal: true
require
'gitlab'
gitlab_token
=
ENV
.
fetch
(
'DANGER_GITLAB_API_TOKEN'
,
''
)
gitlab_endpoint
=
ENV
.
fetch
(
'CI_API_V4_URL'
)
mr_project_path
=
ENV
.
fetch
(
'CI_MERGE_REQUEST_PROJECT_PATH'
)
mr_iid
=
ENV
.
fetch
(
'CI_MERGE_REQUEST_IID'
)
output_file
=
ARGV
.
shift
Gitlab
.
configure
do
|
config
|
config
.
endpoint
=
gitlab_endpoint
config
.
private_token
=
gitlab_token
end
mr_changes
=
Gitlab
.
merge_request_changes
(
mr_project_path
,
mr_iid
)
file_changes
=
mr_changes
.
changes
.
map
{
|
change
|
change
[
'new_path'
]
}
File
.
write
(
output_file
,
file_changes
.
join
(
' '
))
tooling/bin/find_tests
View file @
12d7c00f
#!/usr/bin/env ruby
#!/usr/bin/env ruby
# frozen_string_literal: true
# frozen_string_literal: true
require
'gitlab'
require
'test_file_finder'
require
'test_file_finder'
gitlab_token
=
ENV
.
fetch
(
'DANGER_GITLAB_API_TOKEN'
,
''
)
changes
=
ARGV
.
shift
gitlab_endpoint
=
ENV
.
fetch
(
'CI_API_V4_URL'
)
Gitlab
.
configure
do
|
config
|
config
.
endpoint
=
gitlab_endpoint
config
.
private_token
=
gitlab_token
end
output_file
=
ARGV
.
shift
output_file
=
ARGV
.
shift
mr_project_path
=
ENV
.
fetch
(
'CI_MERGE_REQUEST_PROJECT_PATH'
)
changed_files
=
File
.
read
(
changes
).
split
(
' '
)
mr_iid
=
ENV
.
fetch
(
'CI_MERGE_REQUEST_IID'
)
mr_changes
=
Gitlab
.
merge_request_changes
(
mr_project_path
,
mr_iid
)
changed_files
=
mr_changes
.
changes
.
map
{
|
change
|
change
[
'new_path'
]
}
tff
=
TestFileFinder
::
FileFinder
.
new
(
paths:
changed_files
).
tap
do
|
file_finder
|
tff
=
TestFileFinder
::
FileFinder
.
new
(
paths:
changed_files
).
tap
do
|
file_finder
|
file_finder
.
use
TestFileFinder
::
MappingStrategies
::
PatternMatching
.
load
(
'tests.yml'
)
file_finder
.
use
TestFileFinder
::
MappingStrategies
::
PatternMatching
.
load
(
'tests.yml'
)
...
...
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