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
43189510
Commit
43189510
authored
Jul 05, 2021
by
Andrejs Cunskis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add github project import via api
parent
0e588e91
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
17 deletions
+85
-17
qa/qa/resource/project.rb
qa/qa/resource/project.rb
+16
-15
qa/qa/resource/project_imported_from_github.rb
qa/qa/resource/project_imported_from_github.rb
+28
-2
qa/qa/specs/features/api/1_manage/import_github_repo_spec.rb
qa/qa/specs/features/api/1_manage/import_github_repo_spec.rb
+41
-0
No files found.
qa/qa/resource/project.rb
View file @
43189510
...
...
@@ -9,21 +9,22 @@ module QA
include
Members
include
Visibility
attr_accessor
:repository_storage
# requires admin access
attr_writer
:initialize_with_readme
,
:auto_devops_enabled
,
:github_personal_access_token
,
:github_repository_path
attribute
:id
attribute
:name
attribute
:add_name_uuid
attribute
:description
attribute
:standalone
attribute
:runners_token
attribute
:visibility
attribute
:template_name
attribute
:import
attr_accessor
:repository_storage
,
# requires admin access
:initialize_with_readme
,
:auto_devops_enabled
,
:github_personal_access_token
,
:github_repository_path
attributes
:id
,
:name
,
:add_name_uuid
,
:description
,
:standalone
,
:runners_token
,
:visibility
,
:template_name
,
:import
,
:import_status
attribute
:group
do
Group
.
fabricate!
...
...
qa/qa/resource/project_imported_from_github.rb
View file @
43189510
...
...
@@ -5,6 +5,8 @@ require 'securerandom'
module
QA
module
Resource
class
ProjectImportedFromGithub
<
Resource
::
Project
attribute
:github_repo_id
def
fabricate!
self
.
import
=
true
...
...
@@ -16,10 +18,34 @@ module QA
end
Page
::
Project
::
Import
::
Github
.
perform
do
|
import_page
|
import_page
.
add_personal_access_token
(
@
github_personal_access_token
)
import_page
.
import!
(
@github_repository_path
,
@
name
)
import_page
.
add_personal_access_token
(
github_personal_access_token
)
import_page
.
import!
(
github_repository_path
,
name
)
end
end
def
fabricate_via_api!
super
rescue
ResourceURLMissingError
"
#{
Runtime
::
Scenario
.
gitlab_address
}
/
#{
group
.
full_path
}
/
#{
name
}
"
end
def
api_post_path
'/import/github'
end
def
api_post_body
{
repo_id:
github_repo_id
,
new_name:
name
,
target_namespace:
group
.
full_path
,
personal_access_token:
github_personal_access_token
,
ci_cd_only:
false
}
end
def
transform_api_resource
(
api_resource
)
api_resource
end
end
end
end
qa/qa/specs/features/api/1_manage/import_github_repo_spec.rb
0 → 100644
View file @
43189510
# frozen_string_literal: true
module
QA
RSpec
.
describe
'Manage'
,
:github
,
:requires_admin
do
describe
'Project import'
do
let!
(
:api_client
)
{
Runtime
::
API
::
Client
.
as_admin
}
let!
(
:group
)
{
Resource
::
Group
.
fabricate_via_api!
{
|
resource
|
resource
.
api_client
=
api_client
}
}
let!
(
:user
)
do
Resource
::
User
.
fabricate_via_api!
do
|
resource
|
resource
.
api_client
=
api_client
resource
.
hard_delete_on_api_removal
=
true
end
end
let
(
:imported_project
)
do
Resource
::
ProjectImportedFromGithub
.
fabricate_via_api!
do
|
project
|
project
.
name
=
'imported-project'
project
.
group
=
group
project
.
github_personal_access_token
=
Runtime
::
Env
.
github_access_token
project
.
github_repository_path
=
'gitlab-qa-github/test-project'
project
.
api_client
=
api_client
project
.
github_repo_id
=
'310217317'
end
end
before
do
group
.
add_member
(
user
,
Resource
::
Members
::
AccessLevel
::
MAINTAINER
)
end
after
do
user
.
remove_via_api!
end
it
'imports Github repo via api'
do
imported_project
.
reload!
# import the project and reload all fields
expect
{
imported_project
.
reload!
.
import_status
}.
to
eventually_eq
(
'finished'
).
within
(
duration:
90
)
end
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