[SCM] ci-tooling packaging branch, master, updated. f7a3c4b94410a8cf426bbce56228957dad4be881
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Sun Jan 11 18:04:29 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=f7a3c4b
The following commit has been merged in the master branch:
commit f7a3c4b94410a8cf426bbce56228957dad4be881
Author: Harald Sitter <sitter at kde.org>
Date: Sun Jan 11 19:04:26 2015 +0100
introduce projectfactory and test the project array stuff a bit
I am not sure the factory ought to stay, it feels all a bit fishy
---
lib/projects.rb | 90 +++++++++++++---------
...a-sources-kate-2.json => ppa-sources-kate.json} | 3 +-
test/data/projects/debian/control | 54 +++++++++++++
test/data/projects/projects.json | 6 ++
test/test-projects.rb | 22 +++++-
5 files changed, 136 insertions(+), 39 deletions(-)
diff --git a/lib/projects.rb b/lib/projects.rb
index b8d7dbc..3e15c3c 100644
--- a/lib/projects.rb
+++ b/lib/projects.rb
@@ -96,50 +96,66 @@ class Project
end
end
+# @private
+class ProjectFactory
+ def list_all_repos(component)
+ return %x[ssh git.debian.org ls /git/pkg-kde/#{component}].chop!.gsub!('.git', '').split(' ')
+ end
+
+ def factorize(key, value, type)
+ ret = []
+ case key
+ when "all_repos"
+ value.each do |component|
+ repos = list_all_repos(component)
+ repos.each do |name|
+ ret << Project.new(name, component, type: type)
+ end
+ end
+ when "selective_repos"
+ value.each do |component, names|
+ names.each do |name|
+ ret << Project.new(name, component, type: type)
+ end
+ end
+ when "custom_ci"
+ repos = []
+ config['custom_ci'].each do |custom_ci|
+ if custom_ci['type'] == 'github'
+ require 'octokit'
+ if custom_ci['repos'] == ['all']
+ Octokit.organization_repositories(custom_ci['org']).each do |octo_repo|
+ repos << octo_repo[:name]
+ end
+ end
+ elsif custom_ci['repos'] == ['all'] && custom_ci['type'] != 'github'
+ repos = %x[ssh #{custom_ci['git_host']} ls /].chop!.gsub!('.git', '').split(' ')
+ else
+ repos = custom_ci['repos']
+ end
+
+ puts repos
+ repos.each do |repo|
+ self << Project.new(repo, custom_ci['org'], custom_ci['git_host'], type: type)
+ end
+ end
+ else
+ raise "ProjectFactory encountered an unknown configuration key: #{key}"
+ end
+ return ret
+ end
+end
+
class Projects < Array
def initialize(type: "unstable",
allow_custom_ci: false,
projects_file: File.expand_path(File.dirname(File.dirname(__FILE__))) + '/data/projects.json')
super()
config = JSON::parse(File.read(projects_file))
+ config.delete("custom_ci") unless allow_custom_ci
- # Get all repos inside a component.
- config['all_repos'].each do |component|
- repos = %x[ssh git.debian.org ls /git/pkg-kde/#{component}].chop!.gsub!('.git', '').split(' ')
- repos.each do |name|
- self << Project.new(name, component, type: type)
- end
- end
-
- # Get selective component/repo combinations.
- config['selective_repos'].each do |component, repos|
- repos.each do |name|
- self << Project.new(name, component, type: type)
- end
- end
-
- # Custom CI jobs
- if allow_custom_ci
- repos = []
- config['custom_ci'].each do |custom_ci|
- if custom_ci['type'] == 'github'
- require 'octokit'
- if custom_ci['repos'] == ['all']
- Octokit.organization_repositories(custom_ci['org']).each do |octo_repo|
- repos << octo_repo[:name]
- end
- end
- elsif custom_ci['repos'] == ['all'] && custom_ci['type'] != 'github'
- repos = %x[ssh #{custom_ci['git_host']} ls /].chop!.gsub!('.git', '').split(' ')
- else
- repos = custom_ci['repos']
- end
-
- puts repos
- repos.each do |repo|
- self << Project.new(repo, custom_ci['org'], custom_ci['git_host'], type: type)
- end
- end
+ config.each do |key, value|
+ self.concat(ProjectFactory.new.factorize(key, value, type))
end
# Build a hash for quick lookup of which source provides which binary.
diff --git a/test/data/lp/ppa-sources-kate-2.json b/test/data/lp/ppa-sources-kate.json
similarity index 92%
copy from test/data/lp/ppa-sources-kate-2.json
copy to test/data/lp/ppa-sources-kate.json
index 77dbc2e..7a82ffb 100644
--- a/test/data/lp/ppa-sources-kate-2.json
+++ b/test/data/lp/ppa-sources-kate.json
@@ -1,6 +1,7 @@
{
"total_size": 2,
- "start": 2,
+ "start": 75,
+ "prev_collection_link": "https://api.launchpad.net/devel/%7Ekubuntu-ci/+archive/ubuntu/unstable?source_name=kate\u0026ws.op=getPublishedSources\u0026ws.size=75\u0026direction=backwards\u0026memo=75",
"entries": [
{"package_creator_link": "https://api.launchpad.net/devel/~kubuntu-ci", "package_signer_link": "https://api.launchpad.net/devel/~neon-builder", "source_package_name": "kate", "removal_comment": null, "sponsor_link": null, "display_name": "kate 4:4.50.0+git20141115.0010+15.04-0ubuntu0 in vivid", "creator_link": null, "source_package_version": "4:4.50.0+git20141115.0010+15.04-0ubuntu0", "date_superseded": "2014-11-16T00:33:06.201878+00:00", "http_etag": "fc4237808d94e7effa7450844630978fdae55f8b-48111addc5186d4e70102b5292d8d9cbce42e3fe", "packageupload_link": "https://api.launchpad.net/devel/ubuntu/vivid/+upload/8227146", "self_link": "https://api.launchpad.net/devel/~kubuntu-ci/+archive/ubuntu/unstable/+sourcepub/4571865", "distro_series_link": "https://api.launchpad.net/devel/ubuntu/vivid", "component_name": "main", "status": "Superseded", "date_removed": "2014-11-17T02:10:16.560759+00:00", "pocket": "Release", "date_published": "2014-11-15T00:21:37.927456+00:00", "removed_by_link": null, "section_name": "kde", "date_made_pending": "2014-11-16T00:42:20.004356+00:00", "resource_type_link": "https://api.launchpad.net/devel/#source_package_publishing_history", "archive_link": "https://api.launchpad.net/devel/~kubuntu-ci/+archive/ubuntu/unstable", "package_maintainer_link": "https://api.launchpad.net/devel/~ubuntu-devel-discuss-lists", "date_created": "2014-11-15T00:11:20.132000+00:00", "scheduled_deletion_date": "2014-11-17T00:42:20.004356+00:00"}, {"package_creator_link": "https://api.launchpad.net/devel/~kubuntu-ci", "package_signer_link": "https://api.launchpad.net/devel/~neon-builder", "source_package_name": "kate", "removal_comment": null, "sponsor_link": null, "display_name": "kate 4:4.50.0+git20141115.0006+14.10-0ubuntu0 in utopic", "creator_link": null, "source_package_version": "4:4.50.0+git20141115.0006+14.10-0ubuntu0", "date_superseded": "2014-11-16T00:33:06.201878+00:00", "http_etag": "063b7fc0e70a10286ecfa7a55ce135edea5c480e-a0dc754cbb052b42f9091cbc3ea60ad2eb2ddc70", "packageupload_link": "https://api.launchpad.net/devel/ubuntu/utopic/+upload/8227121", "self_link": "https://api.launchpad.net/devel/~kubuntu-ci/+archive/ubuntu/unstable/+sourcepub/4571852", "distro_series_link": "https://api.launchpad.net/devel/ubuntu/utopic", "component_name": "main", "status": "Superseded", "date_removed": "2014-11-17T02:10:16.560759+00:00", "pocket": "Release", "date_published": "2014-11-15T00:21:37.927456+00:00", "removed_by_link": null, "section_name": "kde", "date_made_pending": "2014-11-16T00:42:20.004356+00:00", "resource_type_link": "https://api.launchpad.net/devel/#source_package_publishing_history", "archive_link": "https://api.launchpad.net/devel/~kubuntu-ci/+archive/ubuntu/unstable", "package_maintainer_link": "https://api.launchpad.net/devel/~ubuntu-devel-discuss-lists", "date_created": "2014-11-15T00:08:11.909701+00:00", "scheduled_deletion_date": "2014-11-17T00:42:20.004356+00:00"}
]
diff --git a/test/data/projects/debian/control b/test/data/projects/debian/control
new file mode 100644
index 0000000..ac03c2a
--- /dev/null
+++ b/test/data/projects/debian/control
@@ -0,0 +1,54 @@
+Source: kinfocenter
+Priority: extra
+Section: kde
+Maintainer: Debian/Kubuntu Qt/KDE Maintainers <debian-qt-kde at lists.debian.org>
+Build-Depends: cmake,
+ debhelper (>= 9.0.0),
+ extra-cmake-modules (>= 1.3.0~),
+ kdoctools-dev (>= 5.2.0),
+ kio-dev (>= 5.2.0),
+ kwayland-dev (>= 5.0.95),
+ libkf5completion-dev (>= 5.2.0),
+ libkf5config-dev (>= 5.2.0),
+ libkf5coreaddons-dev (>= 5.2.0),
+ libkf5dbusaddons-dev (>= 5.2.0),
+ libkf5i18n-dev (>= 5.2.0),
+ libkf5iconthemes-dev (>= 5.2.0),
+ libkf5kcmutils-dev (>= 5.2.0),
+ libkf5kdelibs4support-dev (>= 5.2.0),
+ libkf5service-dev (>= 5.2.0),
+ libkf5solid-dev (>= 5.2.0),
+ libkf5widgetsaddons-dev (>= 5.2.0),
+ libkf5xmlgui-dev (>= 5.2.0),
+ libpci-dev,
+ libraw1394-dev,
+ pkg-config,
+ pkg-kde-tools (>= 0.15.15ubuntu1~)
+Standards-Version: 3.9.5
+Homepage: https://projects.kde.org/projects/playground/libs/libkscreen
+
+Package: kinfocenter
+Architecture: any
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Breaks: kinfocenter5 (<< 4:5.2.0-0ubuntu1~ubuntu14.10~ppa3),
+ kinfocenter5-data (<< 4:5.2.0-0ubuntu1~ubuntu14.10~ppa3)
+Replaces: kinfocenter5 (<< 4:5.2.0-0ubuntu1~ubuntu14.10~ppa3),
+ kinfocenter5-data (<< 4:5.2.0-0ubuntu1~ubuntu14.10~ppa3)
+Description: overview of your system library
+ The kinfocenter provides you with a centralized and convenient
+ overview of your system and desktop environment.
+ .
+ This package contains the shared library
+
+Package: kinfocenter-dbg
+Section: debug
+Architecture: any
+Recommends: qtbase5-dbg
+Depends: kinfocenter (= ${binary:Version}), ${misc:Depends}
+Breaks: kinfocenter5-dbg (<< 4:5.2.0-0ubuntu1~ubuntu14.10~ppa3)
+Replaces: kinfocenter5-dbg (<< 4:5.2.0-0ubuntu1~ubuntu14.10~ppa3)
+Description: overview of your system - debug files
+ The kinfocenter provides you with a centralized and convenient
+ overview of your system and desktop environment.
+ .
+ This package contains the debugging symbols.
diff --git a/test/data/projects/projects.json b/test/data/projects/projects.json
new file mode 100644
index 0000000..fe9519f
--- /dev/null
+++ b/test/data/projects/projects.json
@@ -0,0 +1,6 @@
+{
+ "all_repos" : [ "plasma"],
+ "selective_repos" : {
+ "kde-applications" : [ "gwenview" ]
+ }
+}
diff --git a/test/test-projects.rb b/test/test-projects.rb
index 8084fd0..edfd6f2 100644
--- a/test/test-projects.rb
+++ b/test/test-projects.rb
@@ -4,6 +4,17 @@ require "tmpdir"
require_relative "../lib/projects"
+# Mixin a prepend to overload the list_all_repos function with something testable.
+module FakeProjectFactory
+ def list_all_repos(component)
+ return %w(kinfocenter)
+ end
+end
+
+class ProjectFactory
+ prepend FakeProjectFactory
+end
+
class ProjectTest < Test::Unit::TestCase
def setup
@testdir = File.expand_path(File.dirname(__FILE__))
@@ -71,6 +82,15 @@ class ProjectTest < Test::Unit::TestCase
end
def test_array_init_unstable
- Projects.new(type: "unstable", projects_file: "#{@datadir}/projects.json")
+ # FIXME: this still goes through git.debian
+ reference_projects = %w(kinfocenter gwenview)
+ projects = Projects.new(type: "unstable", projects_file: "#{@datadir}/projects.json")
+ assert_not_nil(projects)
+ assert_equal(projects.size, reference_projects.size)
+ tmpref = reference_projects.clone
+ projects.each do |project|
+ tmpref.delete_if { |name| name == project.name }
+ end
+ assert_equal(tmpref.size, 0)
end
end
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list