Commit 338bb2ac authored by Lin Jen-Shin's avatar Lin Jen-Shin

Remove unused codes and address feedback

parent bc2739a5
......@@ -4,7 +4,7 @@ module QA
module Factory
module Resource
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|
project.name = 'project-with-ci-cd'
......@@ -23,14 +23,6 @@ module QA
@image || 'gitlab/gitlab-runner:alpine'
end
def executor
@executor || 'shell'
end
def docker_image
@docker_image || 'ubuntu/16.04'
end
def fabricate!
project.visit!
......@@ -44,8 +36,6 @@ module QA
runner.address = runners.coordinator_address
runner.tags = tags
runner.image = image
runner.executor = executor
runner.docker_image = docker_image
runner.register!
end
end
......
......@@ -6,15 +6,13 @@ module QA
include Scenario::Actable
include Service::Shellout
attr_accessor :token, :address, :tags, :image, :executor, :docker_image
attr_accessor :token, :address, :tags, :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
......@@ -28,28 +26,16 @@ module QA
-e CI_SERVER_URL=#{@address}
-e REGISTER_NON_INTERACTIVE=true
-e REGISTRATION_TOKEN=#{@token}
-e RUNNER_EXECUTOR=#{@executor}
-e DOCKER_IMAGE=#{@docker_image}
-e RUNNER_EXECUTOR=shell
-e RUNNER_TAG_LIST=#{@tags.join(',')}
-e RUNNER_NAME=#{@name}
#{@image} -c '#{docker_commands}'
#{@image} -c 'gitlab-runner register && gitlab-runner run'
CMD
end
def remove!
shell "docker rm -f #{@name}"
end
private
def docker_commands
commands = [
'gitlab-runner register',
'gitlab-runner run'
]
commands.join(' && ')
end
end
end
end
require 'digest/sha1'
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}" }
after do
Service::Runner.new(runner_name).remove!
end
scenario 'user setup a deploy key and use it to pull from CI job' do
scenario 'user sets up a deploy key to clone code using pipelines' 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'
resource.name = 'deploy-key-clone-project'
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
......@@ -47,20 +46,19 @@ module QA
repository_uri = Git::Repository.parse_uri(repository_url)
gitlab_ci =
<<~YAML
cat-config:
script:
- mkdir -p ~/.ssh
- ssh-keyscan -p #{repository_uri.port || 22} #{repository_uri.host} >> ~/.ssh/known_hosts
- eval $(ssh-agent -s)
- echo "$DEPLOY_KEY" | ssh-add -
- git clone #{repository_url}
- sha1sum #{project.name}/.gitlab-ci.yml
tags:
- qa
- docker
YAML
gitlab_ci = <<~YAML
cat-config:
script:
- mkdir -p ~/.ssh
- ssh-keyscan -p #{repository_uri.port || 22} #{repository_uri.host} >> ~/.ssh/known_hosts
- eval $(ssh-agent -s)
- echo "$DEPLOY_KEY" | ssh-add -
- git clone #{repository_url}
- sha1sum #{project.name}/.gitlab-ci.yml
tags:
- qa
- docker
YAML
sha1sum = Digest::SHA1.hexdigest(gitlab_ci)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment