exercism-config 0.75.0 → 0.79.0

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: a20f0049e610db0735f9d7384583f08e043b7d90ab3821bee7897e0403c37c4d
4
- data.tar.gz: 0a7f8922dd4caad2bd6a4759220c520764ed1363b996d554c2d25421243a0377
3
+ metadata.gz: 75f1646a6035b52f15adf8009bd1813142aacb183dd292586103ac92a3eb8bcf
4
+ data.tar.gz: e3f6555dfcce9300b2f228288e78b7024530729a84cc801e988329f76a7bc47e
5
5
  SHA512:
6
- metadata.gz: 56ebc394087d29d4c38d49683a41d2898ef3334b3a49156f3713262ad5615379e94ffb659b6a12dbedca42f3cd9b5f4c426ccd894149e37a06c80cdb962c4d6d
7
- data.tar.gz: fb765b9f842512a3d1eb1f396736f9858ae337817acb718b45867a4775c955470590385505232185fc878c95f4302e3a1c6f96c71076531b56e63b8e2c4762e8
6
+ metadata.gz: abd507cb222e44902547f311245120a37a8ac82418dbeb405b4ffe5ca314d3d8e209c15f167e4cb358137b4406c200cbb9b83760d977bce881a22fe8ba13b0f2
7
+ data.tar.gz: f1321cdebd33b7ade32c9e7245fb48b18a2f5162aa87492a9fe9a66e24749c5155ae37ea4f2bb9d5bd94aff1578e88dd0b466ad525bb6a7ea609d1542dfe5daf
data/README.md CHANGED
@@ -23,6 +23,7 @@ Exercism.config.mysql_port
23
23
  Exercism.config.spi_url
24
24
  Exercism.config.tooling_orchestrator_url
25
25
  Exercism.config.language_server_url
26
+ Exercism.config.opensearch_host
26
27
 
27
28
  # Secrets
28
29
  Exercism.secrets.github_access_token
@@ -37,6 +38,7 @@ Exercism.dynamodb_client
37
38
  Exercism.s3_client
38
39
  Exercism.ecr_client
39
40
  Exercism.octokit_client
41
+ Exercism.opensearch_client
40
42
  ```
41
43
 
42
44
  ## Explanation
@@ -40,5 +40,6 @@ Gem::Specification.new do |spec|
40
40
  # own Gemfile when using this.
41
41
  spec.add_development_dependency 'aws-sdk-ecr'
42
42
  spec.add_development_dependency 'aws-sdk-s3'
43
+ spec.add_development_dependency 'elasticsearch', '6.8.3'
43
44
  spec.add_development_dependency 'redis'
44
45
  end
@@ -5,9 +5,11 @@ module Exercism
5
5
 
6
6
  extend Mandate::Memoize
7
7
 
8
- def self.create!(type, submission_uuid, language, exercise, extra = {})
8
+ def self.create!(type, submission_uuid, language, exercise,
9
+ run_in_background: false,
10
+ **data)
9
11
  job_id = SecureRandom.uuid.tr('-', '')
10
- data = extra.merge(
12
+ data.merge!(
11
13
  id: job_id,
12
14
  submission_uuid: submission_uuid,
13
15
  type: type,
@@ -16,13 +18,14 @@ module Exercism
16
18
  created_at: Time.now.utc.to_i
17
19
  )
18
20
 
21
+ queue_key = run_in_background ? key_for_queued_in_background : key_for_queued
19
22
  redis = Exercism.redis_tooling_client
20
23
  redis.multi do
21
24
  redis.set(
22
25
  "job:#{job_id}",
23
26
  data.to_json
24
27
  )
25
- redis.rpush(key_for_queued, job_id)
28
+ redis.rpush(queue_key, job_id)
26
29
  redis.set("submission:#{submission_uuid}:#{type}", job_id)
27
30
  end
28
31
  new(job_id, data)
@@ -55,7 +58,7 @@ module Exercism
55
58
  data.key?(meth) || super
56
59
  end
57
60
 
58
- def method_missing(meth)
61
+ def method_missing(meth, *args)
59
62
  super unless respond_to_missing?(meth)
60
63
 
61
64
  data[meth]
@@ -69,7 +72,7 @@ module Exercism
69
72
  end
70
73
  end
71
74
 
72
- def executed!(status, output, exception)
75
+ def executed!(status, output)
73
76
  redis = Exercism.redis_tooling_client
74
77
  redis.multi do
75
78
  redis.lrem(key_for_queued, 1, id)
@@ -80,8 +83,7 @@ module Exercism
80
83
  "job:#{id}",
81
84
  data.merge(
82
85
  execution_status: status,
83
- execution_output: output,
84
- execution_exception: exception
86
+ execution_output: output
85
87
  ).to_json
86
88
  )
87
89
  end
@@ -91,7 +93,8 @@ module Exercism
91
93
  redis = Exercism.redis_tooling_client
92
94
  redis.multi do
93
95
  redis.lrem(key_for_executed, 1, id)
94
- redis.rpush(key_for_processed, id)
96
+ redis.del("job:#{id}")
97
+ redis.del("submission:#{data[:submission_uuid]}:#{data[:type]}")
95
98
  end
96
99
  end
97
100
 
@@ -107,17 +110,44 @@ module Exercism
107
110
  id == other.id
108
111
  end
109
112
 
110
- def stderr
111
- read_s3_file('stderr')
113
+ def store_stdout!(content)
114
+ write_s3_file!(:stdout, content)
115
+ end
116
+
117
+ def store_stderr!(content)
118
+ write_s3_file!(:stderr, content)
119
+ end
120
+
121
+ def store_metadata!(content)
122
+ write_s3_file!('metadata.json', content.to_json)
112
123
  end
113
124
 
114
125
  def stdout
115
- read_s3_file('stdout')
126
+ read_s3_file(:stdout)
127
+ end
128
+
129
+ def stderr
130
+ read_s3_file(:stderr)
131
+ end
132
+
133
+ def metadata
134
+ JSON.parse(read_s3_file('metadata.json'))
135
+ rescue JSON::ParserError
136
+ {}
116
137
  end
117
138
 
118
139
  private
119
140
  attr_reader :data
120
141
 
142
+ def write_s3_file!(name, content)
143
+ Exercism.s3_client.put_object(
144
+ bucket: s3_bucket_name,
145
+ key: "#{s3_folder}/#{name}",
146
+ body: content,
147
+ acl: 'private'
148
+ )
149
+ end
150
+
121
151
  def read_s3_file(name)
122
152
  Exercism.s3_client.get_object(
123
153
  bucket: s3_bucket_name,
@@ -137,7 +167,7 @@ module Exercism
137
167
  Exercism.config.aws_tooling_jobs_bucket
138
168
  end
139
169
 
140
- %w[queued locked executed processed cancelled].each do |key|
170
+ %w[queued queued_in_background locked executed cancelled].each do |key|
141
171
  ToolingJob.singleton_class.class_eval do
142
172
  define_method "key_for_#{key}" do
143
173
  Exercism.env.production? ? key : "#{Exercism.env}:#{key}"
@@ -69,4 +69,21 @@ module Exercism
69
69
  c.auto_paginate = true
70
70
  end
71
71
  end
72
+
73
+ def self.opensearch_client
74
+ require 'elasticsearch'
75
+
76
+ # For now, we're using the ElasticSearch client, but this needs to be
77
+ # changed to the OpenSearch client once it becomes available
78
+ Elasticsearch::Client.new(
79
+ url: ENV.fetch("OPENSEARCH_HOST", config.opensearch_host),
80
+ user: ENV.fetch("OPENSEARCH_USER", Exercism.env.production? ? nil : "admin"),
81
+ password: ENV.fetch("OPENSEARCH_PASSWORD", Exercism.env.production? ? nil : "admin"),
82
+ transport_options: {
83
+ ssl: {
84
+ verify: Exercism.env.production?
85
+ }
86
+ }
87
+ )
88
+ end
72
89
  end
@@ -1,3 +1,3 @@
1
1
  module ExercismConfig
2
- VERSION = '0.75.0'.freeze
2
+ VERSION = '0.79.0'.freeze
3
3
  end
data/settings/ci.yml CHANGED
@@ -37,6 +37,9 @@ efs_repositories_mount_point: "/tmp/exercism/efs/repos"
37
37
  github_organization: fake-exercism
38
38
  github_bot_username: exercism-bot
39
39
 
40
+ # OpenSearch
41
+ opensearch_host: https://127.0.0.1:9200
42
+
40
43
  # Extra things not used in development, but here
41
44
  # so that this file can provide a reference
42
45
  website_assets_host:
data/settings/docker.yml CHANGED
@@ -37,6 +37,9 @@ efs_repositories_mount_point: "/tmp/exercism/efs/repos"
37
37
  github_organization: fake-exercism
38
38
  github_bot_username: exercism-bot
39
39
 
40
+ # OpenSearch
41
+ opensearch_host: https://opensearch:9200
42
+
40
43
  # Extra things not used in development, but here
41
44
  # so that this file can provide a reference
42
45
  website_assets_host:
data/settings/local.yml CHANGED
@@ -37,6 +37,9 @@ efs_repositories_mount_point: "/tmp/exercism/efs/repos"
37
37
  github_organization: fake-exercism
38
38
  github_bot_username: exercism-bot
39
39
 
40
+ # OpenSearch
41
+ opensearch_host: https://localhost:9200
42
+
40
43
  # Extra things not used in development, but here
41
44
  # so that this file can provide a reference
42
45
  website_assets_host:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exercism-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.75.0
4
+ version: 0.79.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Walker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-04 00:00:00.000000000 Z
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: elasticsearch
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 6.8.3
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 6.8.3
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: redis
155
169
  requirement: !ruby/object:Gem::Requirement