exercism_config 0.16.0 → 0.21.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75202fecc54b1825dc26f9e60d665857889b7811447c6901578934dc470b111b
4
- data.tar.gz: 27f499b1562ad2ce6edde2cd8708f7cff05467f821f933f5e462dde483cdb4d1
3
+ metadata.gz: 0c24cc2300139fb5053af4489866ee9994265766f12f5b91fe676ed055c4d3a7
4
+ data.tar.gz: b657a28b1adccf1b74b1a57005eb324889466a1f92a7ac581094f576e904df99
5
5
  SHA512:
6
- metadata.gz: 79df4d09897c5ed3c9ef96af5b0435d39e1418fa0d82b23b8047b4003c66d828d8651989353433a21e9d791e106e6fbf693770a0c6b2328d49bc324d29e72b98
7
- data.tar.gz: 5385e1048f4eb054225447c5f7f84b7f9b433d231511698912c4681a15615d67b51a35b8977bf1af5baabe15038b5e7d0c2d3ea26fef412c017305659fb5526b
6
+ metadata.gz: c6bd5340aa8d762d42891713b7c0768edee802e884ca19489f41cb72613eb0362c53887a7963425f0e83661028ffe0fdb62dc7040bf559a9c45854abd6665505
7
+ data.tar.gz: 27ae8d52eebdf0196e3a2c3414fbfe3726ad532728c8b81970ab96e7333224333508cf5653b2566d334d6a69949cfbc6d0599b80dd18a06c63374d7907150c08
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exercism_config (0.11.0)
4
+ exercism_config (0.18.0)
5
5
  aws-sdk-dynamodb (~> 1.0)
6
6
  mandate
7
7
  zeitwerk
@@ -10,7 +10,7 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  aws-eventstream (1.1.0)
13
- aws-partitions (1.345.0)
13
+ aws-partitions (1.346.0)
14
14
  aws-sdk-core (3.104.3)
15
15
  aws-eventstream (~> 1, >= 1.0.2)
16
16
  aws-partitions (~> 1, >= 1.239.0)
data/README.md CHANGED
@@ -19,8 +19,3 @@ require 'exercism_config'
19
19
  ExercismConfig.config.webservers_alb_dns_name
20
20
  ```
21
21
 
22
- To print out all the config from the command-line, you can run:
23
-
24
- ```bash
25
- AWS_PROFILE=exercism_terraform ./bin/run
26
- ```
data/bin/setup CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bash
1
+ setup_#!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
  set -vx
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "exercism_config"
5
+ require 'yaml'
6
+
7
+ env = ExercismConfig::DetermineEnvironment.()
8
+ if env == :production
9
+ puts "Aborted! This script should not be run in production."
10
+ exit
11
+ end
12
+
13
+ def create_table(client)
14
+ client.create_table(
15
+ table_name: :config,
16
+ attribute_definitions: [
17
+ {
18
+ attribute_name: "id",
19
+ attribute_type: "S",
20
+ },
21
+ ],
22
+ key_schema: [
23
+ {
24
+ attribute_name: "id",
25
+ key_type: "HASH",
26
+ }
27
+ ],
28
+ provisioned_throughput: {
29
+ read_capacity_units: 1,
30
+ write_capacity_units: 1,
31
+ }
32
+ )
33
+ end
34
+
35
+ def delete_table(client)
36
+ client.delete_table(
37
+ table_name: :config,
38
+ )
39
+ end
40
+
41
+ def set_config_value(client, id, value)
42
+ client.put_item(
43
+ table_name: :config,
44
+ item: {
45
+ id: id,
46
+ value: value
47
+ }
48
+ )
49
+ end
50
+
51
+ client = ExercismConfig::SetupDynamoDBClient.()
52
+
53
+ begin
54
+ create_table(client)
55
+ rescue Aws::DynamoDB::Errors::ResourceInUseException => e
56
+ if ARGV.include?("--force")
57
+ puts "Table exists. Recreating..."
58
+ delete_table(client)
59
+ create_table(client)
60
+ puts "Table recreated."
61
+ else
62
+ puts "Table exists. Not recreating."
63
+ end
64
+ end
65
+
66
+ settings_file_arg = ARGV.select{|arg|arg.start_with?("--settings-file=")}.first
67
+ settings_file =
68
+ if settings_file_arg
69
+ settings_file_arg.split("=").last
70
+ elsif ENV["EXERCISM_DOCKER"]
71
+ File.expand_path("../../settings/docker.yml", __FILE__)
72
+ elsif ENV["EXERCISM_CI"]
73
+ File.expand_path("../../settings/ci.yml", __FILE__)
74
+ else
75
+ File.expand_path("../../settings/development.yml", __FILE__)
76
+ end
77
+
78
+ puts "Using settings file: #{settings_file}"
79
+ settings = YAML.load(File.read(settings_file))
80
+
81
+ settings.each do |key, value|
82
+ set_config_value(client, key, value)
83
+ end
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
19
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
20
  end
21
- spec.bindir = "exe"
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.bindir = "bin"
22
+ spec.executables = ["setup_exercism_config"]
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "aws-sdk-dynamodb", "~> 1.0"
@@ -0,0 +1,16 @@
1
+ module ExercismConfig
2
+ class DetermineEnvironment
3
+ include Mandate
4
+
5
+ def call
6
+ env = ENV["EXERCISM_ENV"] || ENV["RAILS_ENV"] || ENV["APP_ENV"]
7
+ raise Exercism::ConfigError, "No environment set - set one of EXERCISM_ENV, RAILS_ENV or APP_ENV" unless env
8
+
9
+ unless %w[development test production].include?(env)
10
+ raise Exercism::ConfigError, "environments must be one of development test production. Got #{env}"
11
+ end
12
+
13
+ env.to_sym
14
+ end
15
+ end
16
+ end
@@ -19,13 +19,11 @@ module ExercismConfig
19
19
 
20
20
  memoize
21
21
  def config_endpoint
22
- case Exercism.environment
23
- when :development, :test
24
- host = ENV["EXERCISM_DOCKER"] ? "dynamodb:8000" : "localhost:3039"
25
- "http://#{host}"
26
- else
27
- nil
28
- end
22
+ return nil unless %i[development test].include?(Exercism.environment)
23
+ return "http://127.0.0.1:#{ENV["DYNAMODB_PORT"]}" if ENV["EXERCISM_CI"]
24
+
25
+ host = ENV["EXERCISM_DOCKER"] ? "dynamodb:8000" : "localhost:3039"
26
+ "http://#{host}"
29
27
  end
30
28
  end
31
29
  end
@@ -1,3 +1,3 @@
1
1
  module ExercismConfig
2
- VERSION = "0.16.0"
2
+ VERSION = "0.21.0"
3
3
  end
@@ -0,0 +1,7 @@
1
+ aws_iterations_bucket: exercism-staging-iterations
2
+ dynamodb_tooling_jobs_table: tooling_jobs
3
+ tooling_orchestrator_url: http://127.0.0.1:3021
4
+ anycable_redis_url: redis://127.0.0.1:6379/1
5
+ anycable_rpc_host: 127.0.0.1:50051
6
+ rds_master_endpoint: 127.0.0.1
7
+ rds_port: <%= ENV["MYSQL_PORT"] %>
@@ -0,0 +1,7 @@
1
+ aws_iterations_bucket: exercism-staging-iterations
2
+ dynamodb_tooling_jobs_table: tooling_jobs
3
+ tooling_orchestrator_url: http://127.0.0.1:3021
4
+ anycable_redis_url: 'redis://127.0.0.1:6379/1'
5
+ anycable_rpc_host: '127.0.0.1:50051'
6
+ rds_master_endpoint: localhost
7
+ mysql_socket: /tmp/mysql.sock
@@ -0,0 +1,7 @@
1
+ aws_iterations_bucket: exercism-staging-iterations
2
+ dynamodb_tooling_jobs_table: tooling_jobs
3
+ tooling_orchestrator_url: http://tooling-orchestrator:3021
4
+ anycable_redis_url: redis://redis:6379/1
5
+ anycable_rpc_host: 0.0.0.0:50051
6
+ rds_master_endpoint: mysql
7
+ rds_port: 3306
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.16.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Walker
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-28 00:00:00.000000000 Z
11
+ date: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb
@@ -111,7 +111,8 @@ dependencies:
111
111
  description:
112
112
  email:
113
113
  - jez.walker@gmail.com
114
- executables: []
114
+ executables:
115
+ - setup_exercism_config
115
116
  extensions: []
116
117
  extra_rdoc_files: []
117
118
  files:
@@ -122,15 +123,19 @@ files:
122
123
  - README.md
123
124
  - Rakefile
124
125
  - bin/console
125
- - bin/run
126
126
  - bin/setup
127
+ - bin/setup_exercism_config
127
128
  - exercism_config.gemspec
128
129
  - lib/exercism/config.rb
129
130
  - lib/exercism_config.rb
131
+ - lib/exercism_config/determine_environment.rb
130
132
  - lib/exercism_config/generate_aws_settings.rb
131
133
  - lib/exercism_config/retrieve.rb
132
134
  - lib/exercism_config/setup_dynamodb_client.rb
133
135
  - lib/exercism_config/version.rb
136
+ - settings/ci.yml
137
+ - settings/development.yml
138
+ - settings/docker.yml
134
139
  homepage: https://exercism.io
135
140
  licenses: []
136
141
  metadata:
data/bin/run DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "exercism_config"
5
-
6
- p ExercismConfig.config.to_h