test_ids 1.2.2 → 1.2.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
  SHA256:
3
- metadata.gz: 99c0a18269234a91b27a3e0329047c5e5a4cbe50ef28679f1f1e81192a845341
4
- data.tar.gz: 469135ba4071b217135f24f431f60dc9e3bd9730942c957543d9cbd83eed5543
3
+ metadata.gz: 3cc056bd639bd5288a0ed73842d5790de1beaf2d8ef53aefe004376fd2647ca2
4
+ data.tar.gz: 75ee0869b2c5d8a9e0e0ec75d9125bd8ad5286a1490af80e95ddcd986874b12e
5
5
  SHA512:
6
- metadata.gz: 2d5a6d61c38b447d3895ca50357b8cc63241067e11c4582ecb166a0a5c7cf6439c54b8025abff91412c041b968518741eadfd176904e92c1e4db45326d9af9d4
7
- data.tar.gz: cbf61dfc565216d1aa44ca6bc8f882647888782da5bf4f41a97d34af3015d61629643e4fc37e99ef00b4e52baf1b1d814dcd3ec6a472296060c23aa7702a49cc
6
+ metadata.gz: ca98189aaf0d39ba9b4f7acac86354e5f6afa2c537dc3e6f70ebcce6413e607aeca2ed722f548c761432306729163c1b893ca4a10bbf2b711b217cd2418bfc58
7
+ data.tar.gz: 86b3b1023d650d963adf0cc4998dda002bec9bd925b4ac20e414f4215a765101ca7c8e5a8dfd84024eec4808e17fb61ca425a150218357955c622dc5d22d0bfc
@@ -83,7 +83,7 @@ class TestIdsApplication < Origen::Application
83
83
  puts "All tests passing, proceeding with release process!"
84
84
  end
85
85
  end
86
-
86
+
87
87
  # To enabled source-less pattern generation create a class (for example PatternDispatcher)
88
88
  # to generate the pattern. This should return false if the requested pattern has been
89
89
  # dispatched, otherwise Origen will proceed with looking up a pattern source as normal.
data/config/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module TestIds
2
2
  MAJOR = 1
3
3
  MINOR = 2
4
- BUGFIX = 2
4
+ BUGFIX = 3
5
5
  DEV = nil
6
6
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
7
7
  end
data/lib/test_ids/git.rb CHANGED
@@ -50,26 +50,28 @@ module TestIds
50
50
  end
51
51
 
52
52
  def initialize(options)
53
- unless File.exist?("#{options[:local]}/.git")
54
- FileUtils.rm_rf(options[:local]) if File.exist?(options[:local])
55
- FileUtils.mkdir_p(options[:local])
56
- Dir.chdir options[:local] do
57
- `git clone #{options[:remote]} .`
58
- unless File.exist?('lock.json')
59
- # Should really try to use the Git driver for this
60
- exec 'touch lock.json'
61
- exec 'git add lock.json'
62
- exec 'git commit -m "Initial commit"'
63
- exec 'git push'
53
+ if !(TestIds.lsf_manual_init_shutdown) && Origen.running_locally?
54
+ unless File.exist?("#{options[:local]}/.git")
55
+ FileUtils.rm_rf(options[:local]) if File.exist?(options[:local])
56
+ FileUtils.mkdir_p(options[:local])
57
+ Dir.chdir options[:local] do
58
+ `git clone #{options[:remote]} .`
59
+ unless File.exist?('lock.json')
60
+ # Should really try to use the Git driver for this
61
+ exec 'touch lock.json'
62
+ exec 'git add lock.json'
63
+ exec 'git commit -m "Initial commit"'
64
+ exec 'git push'
65
+ end
64
66
  end
65
67
  end
68
+ @local = options[:local]
69
+ @repo = ::Git.open(options[:local])
70
+ # Get rid of any local edits coming in here, this is only called once at the start
71
+ # of the program generation run.
72
+ # No need to pull latest as that will be done when we obtain a lock.
73
+ @repo.reset_hard
66
74
  end
67
- @local = options[:local]
68
- @repo = ::Git.open(options[:local])
69
- # Get rid of any local edits coming in here, this is only called once at the start
70
- # of the program generation run.
71
- # No need to pull latest as that will be done when we obtain a lock.
72
- @repo.reset_hard
73
75
  end
74
76
 
75
77
  # Roll the repo back to the given commit ID
@@ -108,11 +110,13 @@ module TestIds
108
110
  end
109
111
 
110
112
  def publish
111
- Origen.profile 'Publishing the test IDs store' do
112
- release_lock
113
- repo.add # Checkin everything
114
- repo.commit('Publishing latest store')
115
- repo.push('origin', 'master', force: true)
113
+ if !(TestIds.lsf_manual_init_shutdown) && Origen.running_locally?
114
+ Origen.profile 'Publishing the test IDs store' do
115
+ release_lock
116
+ repo.add # Checkin everything
117
+ repo.commit('Publishing latest store')
118
+ repo.push('origin', 'master', force: true)
119
+ end
116
120
  end
117
121
  end
118
122
 
@@ -124,23 +128,25 @@ module TestIds
124
128
  end
125
129
 
126
130
  def get_lock
127
- return if @lock_open
128
- Origen.profile 'Obtaining test IDs lock' do
129
- until available_to_lock?
130
- puts
131
- puts "Waiting for lock, currently locked by #{lock_user} (the lock will expire in less than #{lock_minutes_remaining} #{'minute'.pluralize(lock_minutes_remaining)} if not released before that)"
132
- puts
133
- sleep 5
131
+ if !(TestIds.lsf_manual_init_shutdown) && Origen.running_locally?
132
+ return if @lock_open
133
+ Origen.profile 'Obtaining test IDs lock' do
134
+ until available_to_lock?(@repo)
135
+ puts
136
+ puts "Waiting for lock, currently locked by #{lock_user} (the lock will expire in less than #{lock_minutes_remaining} #{'minute'.pluralize(lock_minutes_remaining)} if not released before that)"
137
+ puts
138
+ sleep 5
139
+ end
140
+ data = {
141
+ 'user' => User.current.name,
142
+ 'expires' => (Time.now + minutes(5)).to_f
143
+ }
144
+ write('lock.json', JSON.pretty_generate(data))
145
+ repo.commit('Obtaining lock')
146
+ repo.push('origin')
134
147
  end
135
- data = {
136
- 'user' => User.current.name,
137
- 'expires' => (Time.now + minutes(5)).to_f
138
- }
139
- write('lock.json', JSON.pretty_generate(data))
140
- repo.commit('Obtaining lock')
141
- repo.push('origin')
148
+ @lock_open = true
142
149
  end
143
- @lock_open = true
144
150
  end
145
151
 
146
152
  def release_lock
@@ -151,11 +157,11 @@ module TestIds
151
157
  write('lock.json', JSON.pretty_generate(data))
152
158
  end
153
159
 
154
- def available_to_lock?
160
+ def available_to_lock?(repo_to_use)
155
161
  result = false
156
162
  Origen.profile 'Checking for lock' do
157
- repo.fetch
158
- repo.reset_hard('origin/master')
163
+ repo_to_use.fetch
164
+ repo_to_use.reset_hard('origin/master')
159
165
  if lock_content && lock_user && lock_user != User.current.name
160
166
  result = Time.now.to_f > lock_expires
161
167
  else
data/lib/test_ids.rb CHANGED
@@ -239,10 +239,78 @@ module TestIds
239
239
  @publish = val ? :save : :dont_save
240
240
  end
241
241
 
242
+ def lsf_manual_init_shutdown
243
+ if @lsf_manual_init_shutdown
244
+ true
245
+ end
246
+ false
247
+ end
248
+
242
249
  def next_in_range(range, options)
243
250
  current_configuration.allocator.next_in_range(range, options)
244
251
  end
245
252
 
253
+ def lsf_init(git_repo, lsf_publish)
254
+ @lsf_manual_init_shutdown = true
255
+ local_var_git_database_dir = "#{Origen.app.imports_directory}/test_ids/#{Pathname.new(git_repo).basename}"
256
+ FileUtils.mkdir_p(local_var_git_database_dir)
257
+ unless File.exist?("#{local_var_git_database_dir}/.git")
258
+ FileUtils.rm_rf(local_var_git_database_dir) if File.exist?(local_var_git_database_dir)
259
+ FileUtils.mkdir_p(local_var_git_database_dir)
260
+ Dir.chdir local_var_git_database_dir do
261
+ `git clone #{git_repo} .`
262
+ unless File.exist?('lock.json')
263
+ # Should really try to use the Git driver for this
264
+ exec 'touch lock.json'
265
+ exec 'git add lock.json'
266
+ exec 'git commit -m "Initial commit"'
267
+ exec 'git push'
268
+ end
269
+ end
270
+ end
271
+ @local = local_var_git_database_dir
272
+ @repo = ::Git.open(local_var_git_database_dir)
273
+ # Get rid of any local edits coming in here, this is only called once at the start
274
+ # of the program generation run.
275
+ # No need to pull latest as that will be done when we obtain a lock.
276
+ @repo.reset_hard
277
+ @git = Git.new(local: local_var_git_database_dir, remote: @repo)
278
+ if lsf_publish
279
+ return if @lock_open
280
+ Origen.profile 'Obtaining test IDs lock' do
281
+ until @git.available_to_lock?(@repo)
282
+ puts
283
+ puts "Waiting for lock, currently locked by #{@git.lock_user} (the lock will expire in less than #{@git.lock_minutes_remaining} #{'minute'.pluralize(@git.lock_minutes_remaining)} if not released before that)"
284
+ puts
285
+ sleep 5
286
+ end
287
+ data = {
288
+ 'user' => User.current.name,
289
+ 'expires' => (Time.now + @git.minutes(5)).to_f
290
+ }
291
+ @git.write('lock.json', JSON.pretty_generate(data))
292
+ repo.commit('Obtaining lock')
293
+ repo.push('origin')
294
+ end
295
+ @lock_open = true
296
+ end
297
+ end
298
+
299
+ def lsf_shutdown(lsf_publish)
300
+ if lsf_publish
301
+ Origen.profile 'Publishing the test IDs store' do
302
+ data = {
303
+ 'user' => nil,
304
+ 'expires' => nil
305
+ }
306
+ @git.write('lock.json', JSON.pretty_generate(data))
307
+ repo.add # Checkin everything
308
+ repo.commit('Publishing latest store')
309
+ repo.push('origin', 'master', force: true)
310
+ end
311
+ end
312
+ end
313
+
246
314
  ## When set to true, all numbers generated will be checked to see if they comply
247
315
  ## with the current configuration, and if not they will be re-assigned based on the
248
316
  ## current configuration
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_ids
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-10 00:00:00.000000000 Z
11
+ date: 2022-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: origen
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: 1.8.11
130
130
  requirements: []
131
- rubygems_version: 3.1.4
131
+ rubygems_version: 3.2.31
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Origen plugin to assign and track test program bins and test numbers