cyclid 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 489faa5033ce922ff61b7ab00b4cd161e7f66ae8
4
- data.tar.gz: 2b0c1803c1f1dd3d82c3b906402b8ddbfbdb3c50
3
+ metadata.gz: a6d5c64f60ead996640a63f571a67236cbcc6185
4
+ data.tar.gz: 478f7805d7e8153aa1d98a55da62f52d8543f504
5
5
  SHA512:
6
- metadata.gz: a0158078cf6a1b6da24afd01b2250c8171b5477f87c0cd52fd4b552c76a894dc50ced3c682988040b207fa3439404550ae130596ad3f84144df85e304c632429
7
- data.tar.gz: cc3c14a58a141da1e819636f0d7eb1451be01d50549b902b5470f00b126241d06b5ba553bd2c55ab24eaf2c5909043781b75189291b391e9ce4bc9b7caebb960
6
+ metadata.gz: d9aaeaa77e2f3d9c2c8f0cac5220e4c6a52b95411d8d7123a28b08255d4aa290276da0682c8e12cc6f93bd2c3682be398bb7ef8f5ac7654d5986a18a36bb4bb2
7
+ data.tar.gz: 31b39a88162dfb9998c65410dae99984bd68b0213484648b5bf2ec699648e5d8f2b17f7cf22dcd0fedb1098fef8444658771d70928732f3ac7b66332f4187fe8
@@ -23,12 +23,13 @@ module Cyclid
23
23
  class EvalException < RuntimeError
24
24
  end
25
25
 
26
- # Evalute an expression for "only_if" & "not_if"
26
+ # Evalute an expression for "only_if", "not_if" & "fail_if"
27
27
  class Evaluator
28
28
  class << self
29
29
  def only_if(statement, vars)
30
30
  evaluate(statement, vars)
31
31
  end
32
+ alias fail_if only_if
32
33
 
33
34
  def not_if(statement, vars)
34
35
  not evaluate(statement, vars) # rubocop:disable Style/Not
@@ -144,7 +144,7 @@ module Cyclid
144
144
  end
145
145
  stage_view.on_success = success_stage
146
146
 
147
- # Now set the on_failure failure
147
+ # Now set the on_failure handler
148
148
  stage_failure = { stage: job_stage[:on_failure] }
149
149
  job_sequence << stage_failure \
150
150
  unless job_stage[:on_failure].nil? or \
@@ -154,6 +154,7 @@ module Cyclid
154
154
  # Merge in any modifiers
155
155
  stage_view.only_if = job_stage[:only_if]
156
156
  stage_view.not_if = job_stage[:not_if]
157
+ stage_view.fail_if = job_stage[:fail_if]
157
158
 
158
159
  # Store the modified StageView
159
160
  stages[stage_view.name.to_sym] = stage_view
@@ -156,6 +156,15 @@ module Cyclid
156
156
  # rubocop:enable Style/MultilineTernaryOperator
157
157
  end
158
158
 
159
+ # Fail the stage if fail_if applies
160
+ if stage.fail_if && Evaluator.fail_if(stage.fail_if, @ctx)
161
+ @notifier.write "Stage #{stage.name} v#{stage.version} failed: #{stage.fail_if}\n"
162
+
163
+ success = false
164
+
165
+ Cyclid.logger.info "stage failed due to #{stage.fail_if}"
166
+ end
167
+
159
168
  # Decide which stage to run next depending on the outcome of this
160
169
  # one
161
170
  if success
@@ -25,7 +25,7 @@ module Cyclid
25
25
  # the database object.
26
26
  class StageView
27
27
  attr_reader :name, :version, :steps
28
- attr_accessor :on_success, :on_failure, :only_if, :not_if
28
+ attr_accessor :on_success, :on_failure, :only_if, :not_if, :fail_if
29
29
 
30
30
  def initialize(arg)
31
31
  if arg.is_a? Cyclid::API::Stage
@@ -29,6 +29,10 @@ module Cyclid
29
29
  @pr ||= @payload['pull_request']
30
30
  end
31
31
 
32
+ def pr_number
33
+ @pr_number ||= pull_request['number']
34
+ end
35
+
32
36
  def pr_head
33
37
  @pr_head ||= pull_request['head']
34
38
  end
@@ -112,7 +116,7 @@ module Cyclid
112
116
  sha = nil
113
117
  type = nil
114
118
  tree['tree'].each do |file|
115
- match = file['path'].match(/\A\.cyclid\.(json|yml)\z/)
119
+ match = file['path'].match(/\A\.cyclid\.(json|yml|yaml)\z/)
116
120
  next unless match
117
121
 
118
122
  sha = file['sha']
@@ -127,7 +131,7 @@ module Cyclid
127
131
  case type
128
132
  when 'json'
129
133
  Oj.load(Base64.decode64(blob.content))
130
- when 'yml'
134
+ when 'yml', 'yaml'
131
135
  YAML.load(Base64.decode64(blob.content))
132
136
  end
133
137
  end
@@ -117,7 +117,10 @@ module Cyclid
117
117
  ctx = { github_event: 'pull_request',
118
118
  github_user: pull_request['user']['login'],
119
119
  github_ref: pr_ref,
120
- github_comment: pull_request['title'] }
120
+ github_comment: pull_request['title'],
121
+ github_owner: pr_repository.owner,
122
+ github_repository: pr_repository.name,
123
+ github_number: pr_number }
121
124
 
122
125
  callback = GithubCallback.new(auth_token, pr_repository, pr_sha, linkback_url)
123
126
  job_from_definition(job_definition, callback, ctx)
@@ -154,7 +157,7 @@ module Cyclid
154
157
  end
155
158
 
156
159
  # If we didn't update an existing source definition, insert the new one
157
- normalized << new unless updated
160
+ normalized << new_source unless updated
158
161
 
159
162
  normalized.compact
160
163
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Cyclid
3
3
  module Api
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyclid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Van Der Vliet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-12 00:00:00.000000000 Z
11
+ date: 2017-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj