Permalink
Browse files

Merge pull request #83 from sepulworld/zmw/configure_docker_testing_s…

…uite

Zmw/configure docker testing suite
  • Loading branch information...
sepulworld committed Apr 6, 2016
2 parents 71e3183 + a11c813 commit 4435172f2d34fb1e6ef3da9db2d2f4d755299830
@@ -1,9 +1,27 @@
sudo: required

language: ruby

services:
- docker

before_install:
- rake docker_build
- rake docker_run
- docker ps -a

script:
- bundle exec rake test

after_script:
- rake docker_show_logs

rvm:
- 1.9.3
- 2.2.0
- 2.2.4
- 2.3.0

deploy:
provider: rubygems
api_key:
@@ -0,0 +1,19 @@
FROM debian:jessie

EXPOSE 8080

RUN echo "deb http://repo.aptly.info/ squeeze main" > /etc/apt/sources.list.d/aptly.list; \
apt-key adv --keyserver keys.gnupg.net --recv-keys 2A194991; \
apt-get update; \
apt-get install aptly curl xz-utils bzip2 gnupg wget graphviz -y --force-yes; \
wget --quiet http://mirror.as24220.net/pub/ubuntu-archive/pool/main/z/zeitgeist/zeitgeist_0.9.0-1_all.deb -O /tmp/zeitgeist_0.9.0-1_all.deb; \
wget --quiet http://mirror.as24220.net/pub/ubuntu-archive/pool/main/z/zsh/zsh_5.1.1-1ubuntu1_i386.deb -O /tmp/zsh_5.1.1-1ubuntu1_i386.deb

ADD ./test/fixtures/aptly.conf /etc/aptly.conf

RUN aptly repo create testrepo
RUN aptly repo create testrepo20
RUN aptly repo add testrepo /tmp/zeitgeist_0.9.0-1_all.deb
RUN aptly repo add testrepo20 /tmp/zsh_5.1.1-1ubuntu1_i386.deb

CMD /usr/bin/aptly api serve
@@ -79,6 +79,22 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

Ruby Minitest are impleneted using Docker container for functional tests

Rake tasks available:

```bash
rake build # Build aptly_cli-<version>.gem into the pkg directory
rake docker_build # Docker build image
rake docker_list_aptly # List Docker Aptly running containers
rake docker_run # Start Aptly Docker container on port 8082
rake docker_stop # Stop running Aptly Docker containers
rake install # Build and install aptly_cli-<version>.gem into system gems
rake install:local # Build and install aptly_cli-<version>.gem into system gems without network access
rake test # Run tests
```


## Contributing

1. Fork it ( https://github.com/[my-github-username]/aptly_cli/fork )
@@ -10,3 +10,33 @@ Rake::TestTask.new do |t|
end

task default: :test

desc "Docker build image"
task :docker_build do
sh %{docker build -t sepulworld/aptly_api .}
end

desc "List Docker Aptly running containers"
task :docker_list_aptly do
sh %{docker ps --filter ancestor='sepulworld/aptly_api' --format="{{.ID}}"}
end

desc "Stop running Aptly Docker containers"
task :docker_stop do
sh %{docker stop $(docker ps --filter ancestor='sepulworld/aptly_api' --format="{{.ID}}")}
end

desc "Start Aptly Docker container on port 8082"
task :docker_run do
sh %{docker run -d -p 8082:8080 sepulworld/aptly_api /bin/sh -c "aptly api serve"}
end

desc "Show running Aptly process Docker stdout logs"
task :docker_show_logs do
sh %{docker logs $(docker ps --filter ancestor='sepulworld/aptly_api' --format="{{.ID}}")}
end

desc "Restart Aptly docker container"
task :docker_restart => [:docker_stop, :docker_run] do
puts "Restarting docker Aptly container"
end
@@ -89,7 +89,7 @@ command :repo_edit do |c|
c.syntax = 'aptly-cli repo_edit [options]'
c.summary = 'Edit a local repository metadata, requires --name'
c.description = 'Edit a local repository metadata, requires --name'
c.example 'description', 'aptly-cli repo_edit --name megatronsoftware --default_distribution trusty'
c.example 'Change default distribution', 'aptly-cli repo_edit --name megatronsoftware --default_distribution trusty'
c.option '--name NAME', String, 'Local repository name, required'
c.option '--comment COMMENT', String, 'Edit repository comment'
c.option '--default_distribution DISTRIBUTION', String, 'Edit DefaultDistribution for repo'
@@ -182,7 +182,7 @@ command :publish_drop do |c|
c.syntax = 'aptly-cli publish_drop [options]'
c.summary = 'Delete published repository, clean up files in published directory.'
c.description = 'Delete published repository'
c.example 'Delete publish repository called ', 'aptly-cli repo_list'
c.example 'Delete publish repository prefix precisetest', 'aptly-cli publish_drop --distribution precisetest'
c.option '--prefix PREFIX', String, 'prefix, optional'
c.option '--distribution DISTRIBUTION', String, 'distribution'
c.option '--force', 'force published repository removal even if component cleanup fails'
@@ -207,19 +207,19 @@ command :publish_repo do |c|
c.syntax = 'aptly-cli publish_repo [options]'
c.summary = 'Publish local repository or snapshot under specified prefix. Storage might be passed in prefix as well, e.g. s3:packages/. To supply empty prefix, just remove last part (POST /api/publish/:prefix/<:repos>or<:snapshots>'
c.description = 'Publish local repository or snapshot under specified prefix'
c.example 'description', 'aptly-cli publish_repo --sourcekind local --name precise/megatronsoftware trusty/rocksoftware22 --architectures i386 amd64'
c.example 'description', 'aptly-cli publish_repo --sourcekind local --name megatronsoftware --architectures i386 amd64 --forceoverwrite true'
c.example 'description', 'aptly-cli publish_repo --sourcekind snapshot --name precise/rocksoftware300 --label test_snap'
c.example 'publish multiple repos as source', 'aptly-cli publish_repo --sourcekind local --name precise/megatronsoftware,trusty/rocksoftware22 --architectures i386 amd64'
c.example 'publish one repo, two archs, forceoverwrite', 'aptly-cli publish_repo --sourcekind local --name megatronsoftware --architectures i386 amd64 --forceoverwrite true'
c.example 'publish 2 snapshots into one publish point', 'aptly-cli publish_repo --sourcekind snapshot --name precise/rocksoftware300,main/rocksoftware200 --label test_snap'
c.example 'description', 'aptly-cli publish_repo --sourcekind snapshot --name precise/rocksoftware300 --origin testorigin'
c.example 'publish repo with signing keyring', 'aptly-cli publish_repo --sourcekind snapshot --name precise/rocksoftware300 --origin testorigin --gpg_keyring /etc/apt/trustdb.gpg'
c.option '--name NAME', String, 'Local repository name with optional component, required'
c.option '--name NAME', Array, 'Local repository name with optional component, required'
c.option '--sourcekind SOURCEKIND', String, 'Local for local repositories and snapshot for snapshots, required'
c.option '--prefix PREFIX', String, 'prefix'
c.option '--distribution DISTRIBUTION', String, 'Distribution name, if missing aptly would try to guess from sources'
c.option '--label LABEL', String, 'value of Label: field in published repository stanza'
c.option '--origin ORIGIN', String, 'value of Origin: field in published repository stanza'
c.option '--forceoverwrite', 'when publishing, overwrite files in pool/ directory without notice'
c.option '--architectures ARCHITECTURES', String, 'override list of published architectures'
c.option '--architectures ARCHITECTURES', Array, 'override list of published architectures'
c.option '--gpg_skip', 'Don’t sign published repository'
c.option '--gpg_batch', 'should be set if passing passphrase'
c.option '--gpg_key GPGKEY', String, 'gpg key name (local to aptly server/user)'
@@ -256,10 +256,11 @@ command :publish_update do |c|
c.option '--gpg_passphrase_file GPGPASSFILE', String, 'gpg passphrase file (local to aptly server/user)'
c.action do |args, options|
aptly_command = AptlyCli::AptlyPublish.new
puts aptly_command.publish_update(options.snapshots, { :prefix => options.prefix, :distribution => options.distribution, :forceoverwrite => options.forceoverwrite,
puts aptly_command.publish_update({ :prefix => options.prefix, :distribution => options.distribution, :forceoverwrite => options.forceoverwrite,
:skip => options.gpg_skip, :batch => options.gpg_batch, :gpgKey => options.gpg_key,
:keyring => options.gpg_keyring, :secretKeyring => options.gpg_secret_keyring,
:passphrase => options.gpg_passphrase, :passphraseFile => options.gpg_passphrase_file })
:passphrase => options.gpg_passphrase, :passphraseFile => options.gpg_passphrase_file,
:snapshots => options.snapshots})
end
end

@@ -1,3 +1,3 @@
module AptlyCli
VERSION = '0.2.6'.freeze
VERSION = '0.2.7'.freeze
end
@@ -45,7 +45,15 @@ def publish_list
self.class.get(uri)
end

def parse_names(names, label_type)
def _parse_snapshots(names)
snapshots_to_publish = []
names.each_pair do |k, v|
snapshots_to_publish << { Component: v.to_s, Name: k.to_s }
end
return snapshots_to_publish
end

def _parse_names(names, label_type)
repos_to_publish = []
names = [names] if names.is_a? String
names.each do |k|
@@ -82,7 +90,7 @@ def build_body(available_options_for_func, publish_options, body)
def publish_repo(names, publish_options={})
uri = '/publish'
label_type = 'Name'
repos = parse_names(names, label_type)
repos = _parse_names(names, label_type)
gpg_options = parse_gpg_options(@@available_gpg_options,
publish_options)
@body = {}
@@ -99,16 +107,13 @@ def publish_repo(names, publish_options={})
body: @body_json)
end

def publish_update(snapshots=[], publish_options={})
def publish_update(publish_options={})
uri = '/publish'
label_type = 'Snapshots'
gpg_options = parse_gpg_options(@@available_gpg_options, publish_options)
@body = {}
unless snapshots.nil?
snapshots = parse_names(snapshots, label_type)
@body[:Snapshots] = snapshots
unless publish_options[:snapshots].nil?
@body[:Snapshots] = _parse_snapshots(publish_options[:snapshots])
end

unless gpg_options.empty?
@body[:Signing] = gpg_options
end
@@ -90,7 +90,6 @@ def repo_show(name)

def repo_upload(repo_options = { name: nil, dir: nil, file: nil,
noremove: false, forcereplace: false })

name = repo_options[:name]
dir = repo_options[:dir]
file = repo_options[:file]
@@ -97,7 +97,7 @@ def snapshot_show(name)
def snapshot_update(name, new_name, description=nil)
uri = "/snapshots/#{name}"

unless new_name.nil?
if new_name.nil?
snap_name = name
else
snap_name = new_name
@@ -0,0 +1,16 @@
{
"rootDir": "/aptly",
"downloadConcurrency": 4,
"downloadSpeedLimit": 0,
"architectures": [],
"dependencyFollowSuggests": false,
"dependencyFollowRecommends": false,
"dependencyFollowAllVariants": false,
"dependencyFollowSource": false,
"gpgDisableSign": false,
"gpgDisableVerify": false,
"downloadSourcePackages": false,
"ppaDistributorID": "ubuntu",
"ppaCodename": "",
"S3PublishEndpoints": {}
}

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 4435172

Please sign in to comment.