[SCM] ci-tooling packaging branch, master, updated. 6735615bea1a12a5a1be92393e1088d4e6d08c3f

Rohan Garg rohangarg-guest at moszumanska.debian.org
Mon Sep 14 15:34:20 UTC 2015


Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=6735615

The following commit has been merged in the master branch:
commit 6735615bea1a12a5a1be92393e1088d4e6d08c3f
Author: Rohan Garg <rohan at garg.io>
Date:   Mon Sep 14 17:33:51 2015 +0200

    Split out DCI and KCI modules into their own files
    
    New tests for DCI
---
 data/{kci.yaml => dci.yaml} |  4 +--
 lib/{kci.rb => ci.rb}       | 20 ------------
 lib/dci.rb                  | 11 +++++++
 lib/kci.rb                  | 77 +--------------------------------------------
 test/test_dci.rb            | 42 +++++++++++++++++++++++++
 5 files changed, 55 insertions(+), 99 deletions(-)

diff --git a/data/kci.yaml b/data/dci.yaml
similarity index 69%
copy from data/kci.yaml
copy to data/dci.yaml
index 8a8940d..aff2b11 100644
--- a/data/kci.yaml
+++ b/data/dci.yaml
@@ -1,9 +1,7 @@
 series:
-  wily: "15.10"
-  vivid: "15.04"
+  testing: "8"
 architectures:
   - amd64
-  - i386
 extra_architectures:
   - armhf
 types:
diff --git a/lib/kci.rb b/lib/ci.rb
similarity index 85%
copy from lib/kci.rb
copy to lib/ci.rb
index b0e0c1a..4057b89 100644
--- a/lib/kci.rb
+++ b/lib/ci.rb
@@ -63,23 +63,3 @@ module CI
     hash.sort_by { |_, version| Gem::Version.new(version) }
   end
 end
-
-module KCI
-  extend CI
-  private
-  def self.data
-    return @data if defined?(@data)
-    file = File.join(File.dirname(__dir__), 'data', 'kci.yaml')
-    @data = YAML.load(File.read(file))
-  end
-end
-
-module DCI
-  extend CI
-  private
-  def self.data
-    return @data if defined?(@data)
-    file = File.join(File.dirname(__dir__), 'data', 'dci.yaml')
-    @data = YAML.load(File.read(file))
-  end
-end
diff --git a/lib/dci.rb b/lib/dci.rb
index 00db4b1..b5f0a9d 100644
--- a/lib/dci.rb
+++ b/lib/dci.rb
@@ -1,3 +1,4 @@
+require_relative 'ci'
 require_relative 'logger'
 
 $logger = DCILogger.instance
@@ -18,3 +19,13 @@ def dci_run_cmd(cmd)
         retry
     end
 end
+
+module DCI
+  extend CI
+  private
+  def self.data
+    return @data if defined?(@data)
+    file = File.join(File.dirname(__dir__), 'data', 'dci.yaml')
+    @data = YAML.load(File.read(file))
+  end
+end
diff --git a/lib/kci.rb b/lib/kci.rb
index b0e0c1a..2981300 100644
--- a/lib/kci.rb
+++ b/lib/kci.rb
@@ -1,69 +1,4 @@
-require 'yaml'
-require 'ostruct'
-
-# Kubuntu CI specific stuff.
-module CI
-  # @param sort [Symbol] sorting applied to hash
-  #   - *:none* No sorting, arbitrary order as in config itself (fastest)
-  #   - *:ascending* Oldest version comes first (i.e. [15.04, 15.10])
-  #   - *:descending* Oldest version comes last (i.e. [15.10, 15.04])
-  # @return [Hash] distribution series
-  def series(sort: :none)
-    return sort_version_hash(data['series']).to_h if sort == :ascending
-    return sort_version_hash(data['series']).reverse.to_h if sort == :descending
-    data['series']
-  end
-
-  # @return [String] name of the latest (i.e. newest) series
-  def latest_series
-    @latest_series ||= series(sort: :descending).keys.first
-  end
-
-  # Core architectures. These are always enabled architectures that also get
-  # ISOs generated and so forth.
-  # This for example are general purpose architectures such as i386/amd64.
-  # @see .extra_architectures
-  # @return [Array<String>] architectures to integrate
-  def architectures
-    data['architectures']
-  end
-
-  # Extra architectures. They differ from core architectures in that they are
-  # not automatically enabled and might not be used or useful in all contexts.
-  # This for example are special architectures such as ARM.
-  # @see .all_architectures
-  # @return [Array<String>] architectures to only integrated when explicitly
-  #   enabled within the context of a build.
-  def extra_architectures
-    data['extra_architectures']
-  end
-
-  # Convenience function to combine all known architectures. Generally when
-  # creating scopes (e.g. when creating jenkins jobs) one wants to use the
-  # specific readers as to either use the core architectures or extras or a
-  # suitable mix of both. When read-iterating on something that includes the
-  # architecture value all_architectures is the way to go to cover all possible
-  # architectures.
-  # @see .architectures
-  # @see .extra_architectures
-  # @return [Array<String>] all architectures
-  def all_architectures
-    architectures + extra_architectures
-  end
-
-  # @return [Array<String>] types to integrate (stable/unstable)
-  def types
-    data['types']
-  end
-
-  private
-
-  # @return [Array] array can be converted back with to_h
-  def sort_version_hash(hash)
-    hash.sort_by { |_, version| Gem::Version.new(version) }
-  end
-end
-
+require_relative 'ci'
 module KCI
   extend CI
   private
@@ -73,13 +8,3 @@ module KCI
     @data = YAML.load(File.read(file))
   end
 end
-
-module DCI
-  extend CI
-  private
-  def self.data
-    return @data if defined?(@data)
-    file = File.join(File.dirname(__dir__), 'data', 'dci.yaml')
-    @data = YAML.load(File.read(file))
-  end
-end
diff --git a/test/test_dci.rb b/test/test_dci.rb
new file mode 100644
index 0000000..4fb1133
--- /dev/null
+++ b/test/test_dci.rb
@@ -0,0 +1,42 @@
+require_relative 'lib/testcase'
+# Require kci through the kci/lib symlink to make sure path resolution works
+# even with the changed relativity towards data/.
+# i.e. ../data/kci.yaml is ../../data/kci.yaml within that symlink context
+require_relative '../kci/lib/dci'
+
+# Test kci
+class DCITest < TestCase
+  def assert_equal_collection(expected, actual)
+    assert_equal(expected.sort, actual.sort)
+  end
+
+  def test_types
+    assert_equal_collection(%w(stable unstable), DCI.types)
+  end
+
+  def test_architectures
+    assert_equal_collection(%w(amd64), DCI.architectures)
+  end
+
+  def test_extra_architectures
+    assert_equal_collection(%w(armhf), DCI.extra_architectures)
+  end
+
+  def test_all_architectures
+    assert_equal_collection(%w(amd64 armhf), DCI.all_architectures)
+  end
+
+  def test_series
+    assert_equal_collection(%w(testing), DCI.series.keys)
+    assert_equal_collection(%w(8), DCI.series.values)
+    assert_equal('8', DCI.series['testing'])
+
+    # With sorting
+    assert_equal('testing', DCI.series(sort: :ascending).keys.first)
+    assert_equal('testing', DCI.series(sort: :descending).keys.first)
+  end
+
+  def test_latest_series
+    assert_equal('testing', DCI.latest_series)
+  end
+end

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list