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
338bb2ac
Commit
338bb2ac
authored
Feb 12, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused codes and address feedback
parent
bc2739a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
47 deletions
+21
-47
qa/qa/factory/resource/runner.rb
qa/qa/factory/resource/runner.rb
+1
-11
qa/qa/service/runner.rb
qa/qa/service/runner.rb
+4
-18
qa/qa/specs/features/project/deploy_key_clone_spec.rb
qa/qa/specs/features/project/deploy_key_clone_spec.rb
+16
-18
No files found.
qa/qa/factory/resource/runner.rb
View file @
338bb2ac
...
@@ -4,7 +4,7 @@ module QA
...
@@ -4,7 +4,7 @@ module QA
module
Factory
module
Factory
module
Resource
module
Resource
class
Runner
<
Factory
::
Base
class
Runner
<
Factory
::
Base
attr_writer
:name
,
:tags
,
:image
,
:executor
,
:docker_image
attr_writer
:name
,
:tags
,
:image
dependency
Factory
::
Resource
::
Project
,
as: :project
do
|
project
|
dependency
Factory
::
Resource
::
Project
,
as: :project
do
|
project
|
project
.
name
=
'project-with-ci-cd'
project
.
name
=
'project-with-ci-cd'
...
@@ -23,14 +23,6 @@ module QA
...
@@ -23,14 +23,6 @@ module QA
@image
||
'gitlab/gitlab-runner:alpine'
@image
||
'gitlab/gitlab-runner:alpine'
end
end
def
executor
@executor
||
'shell'
end
def
docker_image
@docker_image
||
'ubuntu/16.04'
end
def
fabricate!
def
fabricate!
project
.
visit!
project
.
visit!
...
@@ -44,8 +36,6 @@ module QA
...
@@ -44,8 +36,6 @@ module QA
runner
.
address
=
runners
.
coordinator_address
runner
.
address
=
runners
.
coordinator_address
runner
.
tags
=
tags
runner
.
tags
=
tags
runner
.
image
=
image
runner
.
image
=
image
runner
.
executor
=
executor
runner
.
docker_image
=
docker_image
runner
.
register!
runner
.
register!
end
end
end
end
...
...
qa/qa/service/runner.rb
View file @
338bb2ac
...
@@ -6,15 +6,13 @@ module QA
...
@@ -6,15 +6,13 @@ module QA
include
Scenario
::
Actable
include
Scenario
::
Actable
include
Service
::
Shellout
include
Service
::
Shellout
attr_accessor
:token
,
:address
,
:tags
,
:image
,
:executor
,
:docker_image
attr_accessor
:token
,
:address
,
:tags
,
:image
def
initialize
(
name
)
def
initialize
(
name
)
@image
=
'gitlab/gitlab-runner:alpine'
@name
=
name
||
"qa-runner-
#{
SecureRandom
.
hex
(
4
)
}
"
@name
=
name
||
"qa-runner-
#{
SecureRandom
.
hex
(
4
)
}
"
@network
=
Runtime
::
Scenario
.
attributes
[
:network
]
||
'test'
@network
=
Runtime
::
Scenario
.
attributes
[
:network
]
||
'test'
@tags
=
%w[qa test]
@tags
=
%w[qa test]
@image
=
'gitlab/gitlab-runner:alpine'
@executor
=
'shell'
@docker_image
=
'ubuntu/16.04'
end
end
def
pull
def
pull
...
@@ -28,28 +26,16 @@ module QA
...
@@ -28,28 +26,16 @@ module QA
-e CI_SERVER_URL=
#{
@address
}
-e CI_SERVER_URL=
#{
@address
}
-e REGISTER_NON_INTERACTIVE=true
-e REGISTER_NON_INTERACTIVE=true
-e REGISTRATION_TOKEN=
#{
@token
}
-e REGISTRATION_TOKEN=
#{
@token
}
-e RUNNER_EXECUTOR=
#{
@executor
}
-e RUNNER_EXECUTOR=shell
-e DOCKER_IMAGE=
#{
@docker_image
}
-e RUNNER_TAG_LIST=
#{
@tags
.
join
(
','
)
}
-e RUNNER_TAG_LIST=
#{
@tags
.
join
(
','
)
}
-e RUNNER_NAME=
#{
@name
}
-e RUNNER_NAME=
#{
@name
}
#{
@image
}
-c '
#{
docker_commands
}
'
#{
@image
}
-c '
gitlab-runner register && gitlab-runner run
'
CMD
CMD
end
end
def
remove!
def
remove!
shell
"docker rm -f
#{
@name
}
"
shell
"docker rm -f
#{
@name
}
"
end
end
private
def
docker_commands
commands
=
[
'gitlab-runner register'
,
'gitlab-runner run'
]
commands
.
join
(
' && '
)
end
end
end
end
end
end
end
qa/qa/specs/features/
cicd/pull_with_deploy_key
_spec.rb
→
qa/qa/specs/features/
project/deploy_key_clone
_spec.rb
View file @
338bb2ac
require
'digest/sha1'
require
'digest/sha1'
module
QA
module
QA
feature
'
pull codes with
a deploy key'
,
:core
,
:docker
do
feature
'
cloning code using
a deploy key'
,
:core
,
:docker
do
let
(
:runner_name
)
{
"qa-runner-
#{
Time
.
now
.
to_i
}
"
}
let
(
:runner_name
)
{
"qa-runner-
#{
Time
.
now
.
to_i
}
"
}
after
do
after
do
Service
::
Runner
.
new
(
runner_name
).
remove!
Service
::
Runner
.
new
(
runner_name
).
remove!
end
end
scenario
'user set
up a deploy key and use it to pull from CI job
'
do
scenario
'user set
s up a deploy key to clone code using pipelines
'
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
project
=
Factory
::
Resource
::
Project
.
fabricate!
do
|
resource
|
project
=
Factory
::
Resource
::
Project
.
fabricate!
do
|
resource
|
resource
.
name
=
'
cicd-pull-with-deploy-key
'
resource
.
name
=
'
deploy-key-clone-project
'
end
end
Factory
::
Resource
::
Runner
.
fabricate!
do
|
runner
|
Factory
::
Resource
::
Runner
.
fabricate!
do
|
runner
|
runner
.
project
=
project
runner
.
project
=
project
runner
.
name
=
runner_name
runner
.
name
=
runner_name
runner
.
tags
=
%w[qa docker]
runner
.
tags
=
%w[qa docker]
runner
.
executor
=
'shell'
runner
.
image
=
'gitlab/gitlab-runner:ubuntu'
runner
.
image
=
'gitlab/gitlab-runner:ubuntu'
end
end
...
@@ -47,20 +46,19 @@ module QA
...
@@ -47,20 +46,19 @@ module QA
repository_uri
=
Git
::
Repository
.
parse_uri
(
repository_url
)
repository_uri
=
Git
::
Repository
.
parse_uri
(
repository_url
)
gitlab_ci
=
gitlab_ci
=
<<~
YAML
<<~
YAML
cat-config:
cat-config:
script:
script:
- mkdir -p ~/.ssh
- mkdir -p ~/.ssh
- ssh-keyscan -p
#{
repository_uri
.
port
||
22
}
#{
repository_uri
.
host
}
>> ~/.ssh/known_hosts
- ssh-keyscan -p
#{
repository_uri
.
port
||
22
}
#{
repository_uri
.
host
}
>> ~/.ssh/known_hosts
- eval $(ssh-agent -s)
- eval $(ssh-agent -s)
- echo "$DEPLOY_KEY" | ssh-add -
- echo "$DEPLOY_KEY" | ssh-add -
- git clone
#{
repository_url
}
- git clone
#{
repository_url
}
- sha1sum
#{
project
.
name
}
/.gitlab-ci.yml
- sha1sum
#{
project
.
name
}
/.gitlab-ci.yml
tags:
tags:
- qa
- qa
- docker
- docker
YAML
YAML
sha1sum
=
Digest
::
SHA1
.
hexdigest
(
gitlab_ci
)
sha1sum
=
Digest
::
SHA1
.
hexdigest
(
gitlab_ci
)
...
...
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