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
1264e2b6
Commit
1264e2b6
authored
Feb 02, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
f5083586
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
181 additions
and
15 deletions
+181
-15
qa/qa.rb
qa/qa.rb
+4
-0
qa/qa/factory/resource/pipeline.rb
qa/qa/factory/resource/pipeline.rb
+8
-0
qa/qa/factory/resource/runner.rb
qa/qa/factory/resource/runner.rb
+16
-1
qa/qa/page/project/job/show.rb
qa/qa/page/project/job/show.rb
+11
-0
qa/qa/page/project/pipeline/index.rb
qa/qa/page/project/pipeline/index.rb
+6
-0
qa/qa/page/project/pipeline/show.rb
qa/qa/page/project/pipeline/show.rb
+10
-0
qa/qa/page/project/show.rb
qa/qa/page/project/show.rb
+20
-9
qa/qa/runtime/rsa_key.rb
qa/qa/runtime/rsa_key.rb
+1
-1
qa/qa/service/runner.rb
qa/qa/service/runner.rb
+22
-4
qa/qa/specs/features/cicd/pull_with_deploy_key_spec.rb
qa/qa/specs/features/cicd/pull_with_deploy_key_spec.rb
+83
-0
No files found.
qa/qa.rb
View file @
1264e2b6
...
...
@@ -116,6 +116,10 @@ module QA
autoload
:Show
,
'qa/page/project/pipeline/show'
end
module
Job
autoload
:Show
,
'qa/page/project/job/show'
end
module
Settings
autoload
:Common
,
'qa/page/project/settings/common'
autoload
:Advanced
,
'qa/page/project/settings/advanced'
...
...
qa/qa/factory/resource/pipeline.rb
0 → 100644
View file @
1264e2b6
module
QA
module
Factory
module
Resource
class
Pipeline
<
Factory
::
Base
end
end
end
end
qa/qa/factory/resource/runner.rb
View file @
1264e2b6
...
...
@@ -4,7 +4,7 @@ module QA
module
Factory
module
Resource
class
Runner
<
Factory
::
Base
attr_writer
:name
,
:tags
attr_writer
:name
,
:tags
,
:image
,
:executor
,
:docker_image
dependency
Factory
::
Resource
::
Project
,
as: :project
do
|
project
|
project
.
name
=
'project-with-ci-cd'
...
...
@@ -19,6 +19,18 @@ module QA
@tags
||
%w[qa e2e]
end
def
image
@image
||
'gitlab/gitlab-runner:alpine'
end
def
executor
@executor
||
'shell'
end
def
docker_image
@docker_image
||
'ubuntu/16.04'
end
def
fabricate!
project
.
visit!
...
...
@@ -31,6 +43,9 @@ module QA
runner
.
token
=
runners
.
registration_token
runner
.
address
=
runners
.
coordinator_address
runner
.
tags
=
tags
runner
.
image
=
image
runner
.
executor
=
executor
runner
.
docker_image
=
docker_image
runner
.
register!
end
end
...
...
qa/qa/page/project/job/show.rb
0 → 100644
View file @
1264e2b6
module
QA::Page
module
Project::Job
class
Show
<
QA
::
Page
::
Base
def
output
css
=
'.js-build-output'
wait
{
has_css?
(
css
)
}
find
(
css
).
text
end
end
end
end
qa/qa/page/project/pipeline/index.rb
View file @
1264e2b6
...
...
@@ -8,6 +8,12 @@ module QA::Page
def
go_to_latest_pipeline
first
(
'.js-pipeline-url-link'
).
click
end
def
wait_for_latest_pipeline
wait
do
first
(
'.js-pipeline-url-link'
)
end
end
end
end
end
qa/qa/page/project/pipeline/show.rb
View file @
1264e2b6
...
...
@@ -30,6 +30,16 @@ module QA::Page
end
end
end
def
go_to_first_job
css
=
'.js-pipeline-graph-job-link'
wait
do
has_css?
(
css
)
end
first
(
css
).
click
end
end
end
end
qa/qa/page/project/show.rb
View file @
1264e2b6
...
...
@@ -23,16 +23,11 @@ module QA
end
def
choose_repository_clone_http
wait
(
reload:
false
)
do
click_element
:clone_dropdown
page
.
within
(
'.clone-options-dropdown'
)
do
click_link
(
'HTTP'
)
choose_repository_clone
(
'HTTP'
)
end
# Ensure git clone textbox was updated to http URI
page
.
has_css?
(
'.git-clone-holder input#project_clone[value*="http"]'
)
end
def
choose_repository_clone_ssh
choose_repository_clone
(
'SSH'
)
end
def
repository_location
...
...
@@ -57,6 +52,22 @@ module QA
click_link
'New issue'
end
private
def
choose_repository_clone
(
kind
)
wait
(
reload:
false
)
do
click_element
:clone_dropdown
page
.
within
(
'.clone-options-dropdown'
)
do
click_link
(
kind
)
end
# Ensure git clone textbox was updated to http URI
page
.
has_css?
(
%Q{.git-clone-holder input#project_clone[value*="
#{
kind
}
"]}
)
end
end
end
end
end
...
...
qa/qa/runtime/rsa_key.rb
View file @
1264e2b6
...
...
@@ -7,7 +7,7 @@ module QA
extend
Forwardable
attr_reader
:key
def_delegators
:@key
,
:fingerprint
def_delegators
:@key
,
:fingerprint
,
:to_pem
def
initialize
(
bits
=
4096
)
@key
=
OpenSSL
::
PKey
::
RSA
.
new
(
bits
)
...
...
qa/qa/service/runner.rb
View file @
1264e2b6
...
...
@@ -6,13 +6,15 @@ module QA
include
Scenario
::
Actable
include
Service
::
Shellout
attr_accessor
:token
,
:address
,
:tags
,
:image
attr_accessor
:token
,
:address
,
:tags
,
:image
,
:executor
,
:docker_image
def
initialize
(
name
)
@image
=
'gitlab/gitlab-runner:alpine'
@name
=
name
||
"qa-runner-
#{
SecureRandom
.
hex
(
4
)
}
"
@network
=
Runtime
::
Scenario
.
attributes
[
:network
]
||
'test'
@tags
=
%w[qa test]
@image
=
'gitlab/gitlab-runner:alpine'
@executor
=
'shell'
@docker_image
=
'ubuntu/16.04'
end
def
pull
...
...
@@ -26,16 +28,32 @@ module QA
-e CI_SERVER_URL=
#{
@address
}
-e REGISTER_NON_INTERACTIVE=true
-e REGISTRATION_TOKEN=
#{
@token
}
-e RUNNER_EXECUTOR=shell
-e RUNNER_EXECUTOR=
#{
@executor
}
-e DOCKER_IMAGE=
#{
@docker_image
}
-e RUNNER_TAG_LIST=
#{
@tags
.
join
(
','
)
}
-e RUNNER_NAME=
#{
@name
}
#{
@image
}
-c '
gitlab-runner register && gitlab-runner run
'
#{
@image
}
-c '
#{
docker_commands
}
'
CMD
end
def
remove!
shell
"docker rm -f
#{
@name
}
"
end
private
def
docker_commands
commands
=
[
'gitlab-runner register'
,
'gitlab-runner run'
]
if
@executor
==
'docker'
commands
.
unshift
(
'apt-get install -y docker-ce'
)
end
commands
.
join
(
' && '
)
end
end
end
end
qa/qa/specs/features/cicd/pull_with_deploy_key_spec.rb
0 → 100644
View file @
1264e2b6
module
QA
feature
'pull codes with a deploy key'
,
:core
,
:docker
do
let
(
:runner_name
)
{
"qa-runner-
#{
Time
.
now
.
to_i
}
"
}
after
do
Service
::
Runner
.
new
(
runner_name
).
remove!
end
scenario
'user pushes .gitlab-ci.yml to the repository'
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
project
=
Factory
::
Resource
::
Project
.
fabricate!
do
|
resource
|
resource
.
name
=
'cicd-pull-with-deploy-key'
end
Factory
::
Resource
::
Runner
.
fabricate!
do
|
runner
|
runner
.
project
=
project
runner
.
name
=
runner_name
runner
.
tags
=
%w[qa docker]
runner
.
executor
=
'shell'
runner
.
image
=
'gitlab/gitlab-runner:ubuntu'
end
key
=
Runtime
::
RSAKey
.
new
Factory
::
Resource
::
DeployKey
.
fabricate!
do
|
resource
|
resource
.
project
=
project
resource
.
title
=
'deploy key title'
resource
.
key
=
key
.
public_key
end
Factory
::
Resource
::
SecretVariable
.
fabricate!
do
|
resource
|
resource
.
project
=
project
resource
.
key
=
'DEPLOY_KEY'
resource
.
value
=
key
.
to_pem
end
project
.
visit!
repository_url
=
Page
::
Project
::
Show
.
act
do
choose_repository_clone_ssh
repository_location
end
gitlab_ci
=
<<~
YAML
cat-config:
script:
- eval $(ssh-agent -s)
- echo "$DEPLOY_KEY" | tr -d '
\\
r' | ssh-add - > /dev/null
- git clone
#{
repository_url
}
- cat
#{
project
.
name
}
/.gitlab-ci.yml
tags:
- qa
- docker
YAML
Factory
::
Repository
::
Push
.
fabricate!
do
|
push
|
push
.
project
=
project
push
.
file_name
=
'.gitlab-ci.yml'
push
.
commit_message
=
'Add .gitlab-ci.yml'
push
.
file_content
=
gitlab_ci
end
Page
::
Project
::
Show
.
act
{
wait_for_push
}
Page
::
Menu
::
Side
.
act
{
click_ci_cd_pipelines
}
Page
::
Project
::
Pipeline
::
Index
.
act
do
wait_for_latest_pipeline
go_to_latest_pipeline
end
Page
::
Project
::
Pipeline
::
Show
.
act
do
go_to_first_job
end
Page
::
Project
::
Job
::
Show
.
perform
do
|
job
|
expect
(
job
.
output
).
to
include
(
gitlab_ci
.
tr
(
"
\n
"
,
' '
))
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