foca-integrity 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/integrity.gemspec +2 -2
- data/lib/integrity/installer.rb +12 -13
- data/lib/integrity/migrations.rb +146 -39
- data/test/helpers.rb +2 -2
- metadata +2 -2
data/VERSION.yml
CHANGED
data/integrity.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{integrity}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.7"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Nicol\303\241s Sanguinetti", "Simon Rozet"]
|
9
|
-
s.date = %q{2009-01-
|
9
|
+
s.date = %q{2009-01-31}
|
10
10
|
s.default_executable = %q{integrity}
|
11
11
|
s.description = %q{Your Friendly Continuous Integration server. Easy, fun and painless!}
|
12
12
|
s.email = %q{contacto@nicolassanguinetti.info}
|
data/lib/integrity/installer.rb
CHANGED
@@ -23,7 +23,7 @@ module Integrity
|
|
23
23
|
Integrity.new(config)
|
24
24
|
migrate_db(direction)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
desc "version",
|
28
28
|
"Print the current integrity version"
|
29
29
|
def version
|
@@ -34,15 +34,14 @@ module Integrity
|
|
34
34
|
attr_reader :root
|
35
35
|
|
36
36
|
def migrate_db(direction="up")
|
37
|
-
require
|
38
|
-
|
39
|
-
|
37
|
+
require 'migrations'
|
38
|
+
|
40
39
|
set_up_migrations unless migrations_already_set_up?
|
41
40
|
add_initial_migration if tables_from_before_migrations_exist?
|
42
41
|
|
43
42
|
case direction.to_s
|
44
|
-
when "up" then migrate_up!
|
45
|
-
when "down" then migrate_down!
|
43
|
+
when "up" then Integrity::Migrations.migrate_up!
|
44
|
+
when "down" then Integrity::Migrations.migrate_down!
|
46
45
|
else raise ArgumentError, "DIRECTION must be either up or down"
|
47
46
|
end
|
48
47
|
end
|
@@ -97,35 +96,35 @@ module Integrity
|
|
97
96
|
puts
|
98
97
|
puts %Q(Don't forget to tweak #{root / "config.yml"} to your needs.)
|
99
98
|
end
|
100
|
-
|
99
|
+
|
101
100
|
def set_up_migrations
|
102
101
|
database_adapter.execute %q(CREATE TABLE "migration_info" ("migration_name" VARCHAR(255));)
|
103
102
|
end
|
104
|
-
|
103
|
+
|
105
104
|
def add_initial_migration
|
106
105
|
database_adapter.execute %q(INSERT INTO "migration_info" ("migration_name") VALUES ("initial"))
|
107
106
|
end
|
108
|
-
|
107
|
+
|
109
108
|
def tables_from_before_migrations_exist?
|
110
109
|
table_exists?("integrity_projects") &&
|
111
110
|
table_exists?("integrity_builds") &&
|
112
111
|
table_exists?("integrity_notifiers")
|
113
112
|
end
|
114
|
-
|
113
|
+
|
115
114
|
def migrations_already_set_up?
|
116
115
|
table_exists?("migration_info")
|
117
116
|
end
|
118
|
-
|
117
|
+
|
119
118
|
def without_pluralizing_table_names
|
120
119
|
database_adapter.resource_naming_convention = DataMapper::NamingConventions::Resource::Underscored
|
121
120
|
yield
|
122
121
|
database_adapter.resource_naming_convention = DataMapper::NamingConventions::Resource::UnderscoredAndPluralized
|
123
122
|
end
|
124
|
-
|
123
|
+
|
125
124
|
def table_exists?(table_name)
|
126
125
|
database_adapter.storage_exists?(table_name)
|
127
126
|
end
|
128
|
-
|
127
|
+
|
129
128
|
def database_adapter
|
130
129
|
DataMapper.repository(:default).adapter
|
131
130
|
end
|
data/lib/integrity/migrations.rb
CHANGED
@@ -1,50 +1,157 @@
|
|
1
1
|
require "dm-migrations"
|
2
2
|
require "migration_runner"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
up do
|
8
|
-
create_table :integrity_projects do
|
9
|
-
column :id, Serial
|
10
|
-
column :name, String, :nullable => false
|
11
|
-
column :permalink, String
|
12
|
-
column :uri, URI, :nullable => false
|
13
|
-
column :branch, String, :nullable => false, :default => "master"
|
14
|
-
column :command, String, :nullable => false, :default => "rake"
|
15
|
-
column :public, Boolean, :default => true
|
16
|
-
column :building, Boolean, :default => false
|
17
|
-
column :created_at, DateTime
|
18
|
-
column :updated_at, DateTime
|
19
|
-
|
20
|
-
column :build_id, Serial
|
21
|
-
column :notifier_id,Serial
|
22
|
-
end
|
4
|
+
module Integrity
|
5
|
+
class Migrations
|
6
|
+
include DataMapper::Types
|
23
7
|
|
24
|
-
|
25
|
-
|
26
|
-
column :output, Text, :nullable => false, :default => ""
|
27
|
-
column :successful, Boolean, :nullable => false, :default => false
|
28
|
-
column :commit_identifier, String, :nullable => false
|
29
|
-
column :commit_metadata, Yaml, :nullable => false
|
30
|
-
column :created_at, DateTime
|
31
|
-
column :updated_at, DateTime
|
8
|
+
# not strictly necessary, but it makes it clear what is going on.
|
9
|
+
include DataMapper::MigrationRunner
|
32
10
|
|
33
|
-
|
34
|
-
|
11
|
+
migration 1, :initial, :verbose => false do
|
12
|
+
up do
|
13
|
+
create_table :integrity_projects do
|
14
|
+
column :id, Integer, :serial => true
|
15
|
+
column :name, String, :nullable => false
|
16
|
+
column :permalink, String
|
17
|
+
column :uri, URI, :nullable => false
|
18
|
+
column :branch, String, :nullable => false, :default => "master"
|
19
|
+
column :command, String, :nullable => false, :default => "rake"
|
20
|
+
column :public, Boolean, :default => true
|
21
|
+
column :building, Boolean, :default => false
|
22
|
+
column :created_at, DateTime
|
23
|
+
column :updated_at, DateTime
|
24
|
+
|
25
|
+
column :build_id, Integer
|
26
|
+
column :notifier_id, Integer
|
27
|
+
end
|
28
|
+
|
29
|
+
create_table :integrity_builds do
|
30
|
+
column :id, Integer, :serial => true
|
31
|
+
column :output, Text, :nullable => false, :default => ""
|
32
|
+
column :successful, Boolean, :nullable => false, :default => false
|
33
|
+
column :commit_identifier, String, :nullable => false
|
34
|
+
column :commit_metadata, Yaml, :nullable => false
|
35
|
+
column :created_at, DateTime
|
36
|
+
column :updated_at, DateTime
|
37
|
+
|
38
|
+
column :project_id, Integer
|
39
|
+
end
|
40
|
+
|
41
|
+
create_table :integrity_notifiers do
|
42
|
+
column :id, Integer, :serial => true
|
43
|
+
column :name, String, :nullable => false
|
44
|
+
column :config, Yaml, :nullable => false
|
35
45
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
column :config, Yaml, :nullable => false
|
46
|
+
column :project_id, Integer
|
47
|
+
end
|
48
|
+
end
|
40
49
|
|
41
|
-
|
50
|
+
down do
|
51
|
+
drop_table :integrity_notifiers
|
52
|
+
drop_table :integrity_projects
|
53
|
+
drop_table :integrity_builds
|
54
|
+
end
|
42
55
|
end
|
43
|
-
end
|
44
56
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
57
|
+
migration 2, :add_commits, :verbose => false do
|
58
|
+
up do
|
59
|
+
class ::Integrity::Build
|
60
|
+
property :commit_identifier, String
|
61
|
+
property :commit_metadata, Yaml, :lazy => false
|
62
|
+
property :project_id, Integer
|
63
|
+
end
|
64
|
+
|
65
|
+
create_table :integrity_commits do
|
66
|
+
column :id, Integer, :serial => true
|
67
|
+
column :identifier, String, :nullable => false
|
68
|
+
column :message, String, :nullable => false, :length => 255
|
69
|
+
column :author, String, :nullable => false, :length => 255
|
70
|
+
column :committed_at, DateTime, :nullable => false
|
71
|
+
column :created_at, DateTime
|
72
|
+
column :updated_at, DateTime
|
73
|
+
|
74
|
+
column :project_id, Integer
|
75
|
+
end
|
76
|
+
|
77
|
+
modify_table :integrity_builds do
|
78
|
+
add_column :commit_id, Integer
|
79
|
+
add_column :started_at, DateTime
|
80
|
+
add_column :completed_at, DateTime
|
81
|
+
end
|
82
|
+
|
83
|
+
# Die, orphans, die
|
84
|
+
Build.all(:project_id => nil).destroy!
|
85
|
+
|
86
|
+
# sqlite hodgepockery
|
87
|
+
all_builds = Build.all.each {|b| b.freeze }
|
88
|
+
drop_table :integrity_builds
|
89
|
+
create_table :integrity_builds do
|
90
|
+
column :id, Integer, :serial => true
|
91
|
+
column :started_at, DateTime
|
92
|
+
column :completed_at, DateTime
|
93
|
+
column :successful, Boolean
|
94
|
+
column :output, Text, :nullable => false, :default => ""
|
95
|
+
column :created_at, DateTime
|
96
|
+
column :updated_at, DateTime
|
97
|
+
|
98
|
+
column :commit_id, Integer
|
99
|
+
end
|
100
|
+
|
101
|
+
all_builds.each do |build|
|
102
|
+
commit = Commit.first(:identifier => build.commit_identifier)
|
103
|
+
|
104
|
+
if commit.nil?
|
105
|
+
commit = Commit.create(:identifier => build.commit_identifier,
|
106
|
+
:message => build.commit_metadata[:message],
|
107
|
+
:author => build.commit_metadata[:author],
|
108
|
+
:committed_at => build.commit_metadata[:date],
|
109
|
+
:project_id => build.project_id)
|
110
|
+
end
|
111
|
+
|
112
|
+
Build.create(:commit_id => commit.id,
|
113
|
+
:started_at => build.created_at,
|
114
|
+
:completed_at => build.updated_at,
|
115
|
+
:successful => build.successful,
|
116
|
+
:output => build.output)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
down do
|
121
|
+
modify_table :integrity_builds do
|
122
|
+
add_column :commit_identifier, String, :nullable => false
|
123
|
+
add_column :commit_metadata, Yaml, :nullable => false
|
124
|
+
add_column :project_id, Integer
|
125
|
+
end
|
126
|
+
|
127
|
+
# sqlite hodgepockery
|
128
|
+
all_builds = Build.all.map {|b| b.freeze }
|
129
|
+
drop_table :integrity_builds
|
130
|
+
create_table :integrity_builds do
|
131
|
+
column :id, Integer, :serial => true
|
132
|
+
column :output, Text, :nullable => false, :default => ""
|
133
|
+
column :successful, Boolean, :nullable => false, :default => false
|
134
|
+
column :commit_identifier, String, :nullable => false
|
135
|
+
column :commit_metadata, Yaml, :nullable => false
|
136
|
+
column :created_at, DateTime
|
137
|
+
column :updated_at, DateTime
|
138
|
+
column :project_id, Integer
|
139
|
+
end
|
140
|
+
|
141
|
+
all_builds.each do |build|
|
142
|
+
Build.create(:project_id => build.commit.project_id,
|
143
|
+
:output => build.output,
|
144
|
+
:successful => build.successful,
|
145
|
+
:commit_identifier => build.commit.identifier,
|
146
|
+
:commit_metadata => {
|
147
|
+
:message => build.commit.message,
|
148
|
+
:author => build.commit.author.full,
|
149
|
+
:date => commit.committed_at
|
150
|
+
}.to_yaml)
|
151
|
+
end
|
152
|
+
|
153
|
+
drop_table :commits
|
154
|
+
end
|
155
|
+
end
|
49
156
|
end
|
50
157
|
end
|
data/test/helpers.rb
CHANGED
@@ -14,10 +14,10 @@ rescue LoadError
|
|
14
14
|
puts "You're missing some gems required to run the tests."
|
15
15
|
puts "Please run `rake test:install_dependencies`"
|
16
16
|
puts "You'll probably need to run that command as root or with sudo."
|
17
|
-
puts
|
17
|
+
puts
|
18
18
|
puts "Thanks :)"
|
19
19
|
puts
|
20
|
-
|
20
|
+
|
21
21
|
exit 1
|
22
22
|
end
|
23
23
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foca-integrity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Nicol\xC3\xA1s Sanguinetti"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-01-
|
13
|
+
date: 2009-01-31 00:00:00 -08:00
|
14
14
|
default_executable: integrity
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|