exercism-config 0.34.0 → 0.41.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 +4 -4
- data/.github/workflows/tests.yml +1 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +8 -0
- data/README.md +3 -4
- data/Rakefile +4 -0
- data/bin/console +1 -1
- data/bin/rubocop-quick +2 -2
- data/bin/setup_exercism_config +5 -6
- data/bin/setup_exercism_local_aws +14 -9
- data/lib/exercism-config.rb +7 -2
- data/lib/exercism/config.rb +15 -1
- data/lib/exercism_config/determine_environment.rb +1 -5
- data/lib/exercism_config/environment.rb +49 -0
- data/lib/exercism_config/generate_aws_settings.rb +3 -12
- data/lib/exercism_config/retrieve.rb +4 -11
- data/lib/exercism_config/setup_dynamodb_client.rb +2 -6
- data/lib/exercism_config/setup_s3_client.rb +1 -3
- data/lib/exercism_config/version.rb +1 -1
- data/settings/{test-ci.yml → ci.yml} +1 -0
- data/settings/docker.yml +1 -0
- data/settings/{development.yml → local.yml} +1 -0
- metadata +5 -7
- data/.github/config/rubocop_linter_action.yml +0 -12
- data/settings/test-docker.yml +0 -9
- data/settings/test-local.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01f964544c9ddec6effc25a1b417ed9d2f3d0c5dcb98ebae0b6cd9c4b62e3963
|
4
|
+
data.tar.gz: 61a0591b8b221bed122b2dc12cfceff707aaf7005f56335bab86e1e31633210b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd48bdaf9a8b8a86a3934e886442b6c23fd5285a2f0a578d0b6209ac1ac5b88ad58d2e34401459c84dbb7f0d57a99b5ef411199016f43833744811656ae6f188
|
7
|
+
data.tar.gz: d0ac7eee145662d64d964f6b6dfd19d85aa780d5d387d9fb5c53adbe1c0963556389d4dfedb985c1617e81754d8ea5dc9e9befffecfe069826767d79d510e48f
|
data/.github/workflows/tests.yml
CHANGED
@@ -73,6 +73,7 @@ jobs:
|
|
73
73
|
###
|
74
74
|
# Publish the coverage to CodeClimate
|
75
75
|
- name: Publish code coverage
|
76
|
+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
|
76
77
|
env:
|
77
78
|
GIT_BRANCH: ${GITHUB_REF/refs\/heads\//}
|
78
79
|
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -56,6 +56,10 @@ Style/Documentation:
|
|
56
56
|
Style/DocumentationMethod:
|
57
57
|
Enabled: false
|
58
58
|
|
59
|
+
Style/GuardClause:
|
60
|
+
Exclude:
|
61
|
+
- lib/exercism_config/environment.rb
|
62
|
+
|
59
63
|
Style/IfUnlessModifier:
|
60
64
|
Exclude:
|
61
65
|
- "lib/exercism_config/setup_dynamodb_client.rb"
|
@@ -74,6 +78,10 @@ Style/ZeroLengthPredicate:
|
|
74
78
|
Style/ClassAndModuleChildren:
|
75
79
|
Enabled: false
|
76
80
|
|
81
|
+
Naming/FileName:
|
82
|
+
Exclude:
|
83
|
+
- "lib/exercism-config.rb"
|
84
|
+
|
77
85
|
Naming/VariableNumber:
|
78
86
|
EnforcedStyle: snake_case
|
79
87
|
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|

|
4
4
|
[](https://codeclimate.com/github/exercism/config/maintainability)
|
5
5
|
[](https://codeclimate.com/github/exercism/config/test_coverage)
|
6
|
-
[](https://badge.fury.io/rb/exercism-config)
|
7
7
|
|
8
8
|
When terraform creates Exercism's infrastructure, it writes endpoints and DNS entries to DynamoDB.
|
9
9
|
This gem allows you to trivially retrieve that data.
|
@@ -17,10 +17,9 @@ Simply include this gem in your Gemfile, require it, and then refer to the objec
|
|
17
17
|
|
18
18
|
```ruby
|
19
19
|
# Gemfile
|
20
|
-
gem '
|
20
|
+
gem 'exercism-config'
|
21
21
|
|
22
22
|
# Your code
|
23
|
-
require '
|
23
|
+
require 'exercism-config'
|
24
24
|
ExercismConfig.config.webservers_alb_dns_name
|
25
25
|
```
|
26
|
-
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/bin/rubocop-quick
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
git diff --name-status --staged | grep '^[MA]' | grep -o '
|
4
|
-
git diff --name-status --staged | grep '^[MA]' | grep -o '
|
3
|
+
git diff --name-status --staged | grep '^[MA]' | grep -o '\s\+.*rb' | xargs bundle exec rubocop --except Metrics --auto-correct --format quiet --force-exclusion lib/exercism-config.rb && \
|
4
|
+
git diff --name-status --staged | grep '^[MA]' | grep -o '\s\+.*rb' | xargs git add
|
data/bin/setup_exercism_config
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'bundler/setup'
|
4
|
-
require '
|
4
|
+
require 'exercism-config'
|
5
5
|
require 'erb'
|
6
6
|
require 'yaml'
|
7
7
|
|
8
|
-
|
9
|
-
if env == :production
|
8
|
+
if Exercism.env.production?
|
10
9
|
puts 'Aborted! This script should not be run in production.'
|
11
10
|
exit
|
12
11
|
end
|
@@ -17,7 +16,7 @@ def create_table(client)
|
|
17
16
|
attribute_definitions: [
|
18
17
|
{
|
19
18
|
attribute_name: 'id',
|
20
|
-
attribute_type: 'S'
|
19
|
+
attribute_type: 'S'
|
21
20
|
}
|
22
21
|
],
|
23
22
|
key_schema: [
|
@@ -71,9 +70,9 @@ settings_file =
|
|
71
70
|
elsif ENV['EXERCISM_DOCKER']
|
72
71
|
File.expand_path('../settings/docker.yml', __dir__)
|
73
72
|
elsif ENV['EXERCISM_CI']
|
74
|
-
File.expand_path('../settings/
|
73
|
+
File.expand_path('../settings/ci.yml', __dir__)
|
75
74
|
else
|
76
|
-
File.expand_path('../settings/
|
75
|
+
File.expand_path('../settings/local.yml', __dir__)
|
77
76
|
end
|
78
77
|
|
79
78
|
puts "Using settings file: #{settings_file}"
|
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "bundler/setup"
|
3
|
-
require "
|
3
|
+
require "exercism-config"
|
4
4
|
|
5
5
|
# Only allow this to run in development
|
6
|
-
return
|
6
|
+
return if Exercism.env.production?
|
7
7
|
|
8
8
|
puts "Create AWS/DynamoDB tables..."
|
9
9
|
|
@@ -15,13 +15,18 @@ Exercism.config.dynamodb_client = ExercismConfig::SetupDynamoDBClient.()
|
|
15
15
|
|
16
16
|
# We don't need this running for CI atm as none of our
|
17
17
|
# tests actually hit s3. Although we might choose to change this
|
18
|
-
unless ENV["EXERCISM_CI"]
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
unless ENV["EXERCISM_CI"] || ENV["EXERCISM_SKIP_S3"]
|
19
|
+
[
|
20
|
+
Exercism.config.aws_iterations_bucket,
|
21
|
+
Exercism.config.aws_tooling_jobs_bucket,
|
22
|
+
].each do |bucket|
|
23
|
+
begin
|
24
|
+
ExercismConfig::SetupS3Client.().create_bucket(bucket: bucket)
|
25
|
+
rescue Seahorse::Client::NetworkingError => e
|
26
|
+
puts "local S3 not up yet..."
|
27
|
+
sleep 2 # slighty retry delaty
|
28
|
+
retry
|
29
|
+
end
|
25
30
|
end
|
26
31
|
end
|
27
32
|
|
data/lib/exercism-config.rb
CHANGED
@@ -3,6 +3,7 @@ require 'mandate'
|
|
3
3
|
require 'ostruct'
|
4
4
|
require 'json'
|
5
5
|
|
6
|
+
require_relative 'exercism_config/environment'
|
6
7
|
require_relative 'exercism_config/determine_environment'
|
7
8
|
require_relative 'exercism_config/generate_aws_settings'
|
8
9
|
require_relative 'exercism_config/setup_dynamodb_client'
|
@@ -14,11 +15,15 @@ require_relative 'exercism_config/version'
|
|
14
15
|
require_relative 'exercism/config'
|
15
16
|
|
16
17
|
module Exercism
|
17
|
-
class ConfigError < RuntimeError
|
18
|
+
class ConfigError < RuntimeError; end
|
19
|
+
|
20
|
+
def self.env
|
21
|
+
@env ||= ExercismConfig::DetermineEnvironment.()
|
18
22
|
end
|
19
23
|
|
20
24
|
def self.environment
|
21
|
-
|
25
|
+
puts "Exercism.environment is deprecated. Use Exercism.env"
|
26
|
+
env
|
22
27
|
end
|
23
28
|
|
24
29
|
def self.config
|
data/lib/exercism/config.rb
CHANGED
@@ -1,12 +1,26 @@
|
|
1
1
|
module Exercism
|
2
2
|
class Config < OpenStruct
|
3
|
+
PROPS_WITH_TEST_SUFFIX = %i[
|
4
|
+
dynamodb_tooling_jobs_table
|
5
|
+
].freeze
|
6
|
+
|
3
7
|
def initialize(data, aws_settings)
|
4
8
|
super(data)
|
5
9
|
self.aws_settings = aws_settings
|
6
10
|
end
|
7
11
|
|
12
|
+
PROPS_WITH_TEST_SUFFIX.each do |prop|
|
13
|
+
define_method prop do
|
14
|
+
Exercism.env.test? ? "#{super()}-test" : super()
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
def to_json(*_args)
|
9
|
-
to_h
|
19
|
+
hash = to_h
|
20
|
+
PROPS_WITH_TEST_SUFFIX.each do |prop|
|
21
|
+
hash[prop] = send(prop)
|
22
|
+
end
|
23
|
+
hash.to_json
|
10
24
|
end
|
11
25
|
end
|
12
26
|
end
|
@@ -6,11 +6,7 @@ module ExercismConfig
|
|
6
6
|
env = ENV['EXERCISM_ENV'] || ENV['RAILS_ENV'] || ENV['APP_ENV']
|
7
7
|
raise Exercism::ConfigError, 'No environment set - set one of EXERCISM_ENV, RAILS_ENV or APP_ENV' unless env
|
8
8
|
|
9
|
-
|
10
|
-
raise Exercism::ConfigError, "environment must be one of development, test or production. Got #{env}."
|
11
|
-
end
|
12
|
-
|
13
|
-
env.to_sym
|
9
|
+
Environment.new(env)
|
14
10
|
end
|
15
11
|
end
|
16
12
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module ExercismConfig
|
2
|
+
class Environment
|
3
|
+
ALLOWED_ENVS = %(development test production).freeze
|
4
|
+
private_constant :ALLOWED_ENVS
|
5
|
+
|
6
|
+
def initialize(raw_env)
|
7
|
+
@env = raw_env.to_s
|
8
|
+
|
9
|
+
unless ALLOWED_ENVS.include?(env)
|
10
|
+
raise Exercism::ConfigError, "environment must be one of development, test or production. Got #{env}."
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def ==(other)
|
15
|
+
env == other.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
def eql?(other)
|
19
|
+
env == other.to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def hash
|
23
|
+
env.hash
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
env
|
28
|
+
end
|
29
|
+
|
30
|
+
def inspect
|
31
|
+
env
|
32
|
+
end
|
33
|
+
|
34
|
+
def development?
|
35
|
+
env == "development"
|
36
|
+
end
|
37
|
+
|
38
|
+
def test?
|
39
|
+
env == "test"
|
40
|
+
end
|
41
|
+
|
42
|
+
def production?
|
43
|
+
env == "production"
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
attr_reader :env
|
48
|
+
end
|
49
|
+
end
|
@@ -13,26 +13,17 @@ module ExercismConfig
|
|
13
13
|
|
14
14
|
memoize
|
15
15
|
def aws_access_key_id
|
16
|
-
|
17
|
-
when :development, :test
|
18
|
-
'FAKE'
|
19
|
-
end
|
16
|
+
Exercism.env.production? ? nil : 'FAKE'
|
20
17
|
end
|
21
18
|
|
22
19
|
memoize
|
23
20
|
def aws_secret_access_key
|
24
|
-
|
25
|
-
when :development, :test
|
26
|
-
'FAKE'
|
27
|
-
end
|
21
|
+
Exercism.env.production? ? nil : 'FAKE'
|
28
22
|
end
|
29
23
|
|
30
24
|
memoize
|
31
25
|
def profile
|
32
|
-
|
33
|
-
when :production
|
34
|
-
'exercism_staging'
|
35
|
-
end
|
26
|
+
Exercism.env.production? ? nil : 'exercism_staging'
|
36
27
|
end
|
37
28
|
end
|
38
29
|
end
|
@@ -3,7 +3,7 @@ module ExercismConfig
|
|
3
3
|
include Mandate
|
4
4
|
|
5
5
|
def call
|
6
|
-
return generate_mock if Exercism.
|
6
|
+
return generate_mock if Exercism.env.test?
|
7
7
|
|
8
8
|
retrieve_from_dynamodb
|
9
9
|
end
|
@@ -14,11 +14,11 @@ module ExercismConfig
|
|
14
14
|
require 'yaml'
|
15
15
|
|
16
16
|
filename = if ENV["EXERCISM_CI"]
|
17
|
-
'
|
17
|
+
'ci'
|
18
18
|
elsif ENV["EXERCISM_DOCKER"]
|
19
|
-
'
|
19
|
+
'docker'
|
20
20
|
else
|
21
|
-
'
|
21
|
+
'local'
|
22
22
|
end
|
23
23
|
|
24
24
|
settings_file = File.expand_path("../../../settings/#{filename}.yml", __FILE__)
|
@@ -36,13 +36,6 @@ module ExercismConfig
|
|
36
36
|
h[item['id']] = item['value']
|
37
37
|
end
|
38
38
|
|
39
|
-
# Tweak things for dynamodb when we're running in test mode
|
40
|
-
if Exercism.environment == :test
|
41
|
-
%w[dynamodb_tooling_jobs_table].each do |key|
|
42
|
-
data[key] = "#{data[key]}-test"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
39
|
aws_settings = GenerateAwsSettings.()
|
47
40
|
Exercism::Config.new(data, aws_settings)
|
48
41
|
rescue Exercism::ConfigError
|
@@ -15,14 +15,10 @@ module ExercismConfig
|
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
|
-
attr_reader :environment
|
19
|
-
|
20
18
|
memoize
|
21
19
|
def config_endpoint
|
22
|
-
return nil
|
23
|
-
if Exercism.
|
24
|
-
return "http://127.0.0.1:#{ENV['DYNAMODB_PORT']}"
|
25
|
-
end
|
20
|
+
return nil if Exercism.env.production?
|
21
|
+
return "http://127.0.0.1:#{ENV['DYNAMODB_PORT']}" if Exercism.env.test? && ENV['EXERCISM_CI']
|
26
22
|
|
27
23
|
host = ENV['EXERCISM_DOCKER'] ? 'dynamodb:8000' : 'localhost:3040'
|
28
24
|
"http://#{host}"
|
@@ -18,11 +18,9 @@ module ExercismConfig
|
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
21
|
-
attr_reader :environment
|
22
|
-
|
23
21
|
memoize
|
24
22
|
def config_endpoint
|
25
|
-
return nil
|
23
|
+
return nil if Exercism.env.production?
|
26
24
|
return "http://127.0.0.1:#{ENV['S3_PORT']}" if ENV['EXERCISM_CI']
|
27
25
|
|
28
26
|
host = ENV['EXERCISM_DOCKER'] ? 's3:9090' : 'localhost:3041'
|
@@ -1,6 +1,7 @@
|
|
1
1
|
anycable_redis_url: redis://127.0.0.1:6379/1
|
2
2
|
anycable_rpc_host: 127.0.0.1:50051
|
3
3
|
aws_iterations_bucket: exercism-staging-iterations
|
4
|
+
aws_tooling_jobs_bucket: exercism-staging-tooling-jobs
|
4
5
|
dynamodb_tooling_jobs_table: tooling_jobs
|
5
6
|
spi_url: http://127.0.0.1:3020
|
6
7
|
tooling_orchestrator_url: http://127.0.0.1:3021
|
data/settings/docker.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
anycable_redis_url: redis://redis:6379/1
|
2
2
|
anycable_rpc_host: 0.0.0.0:50051
|
3
3
|
aws_iterations_bucket: exercism-staging-iterations
|
4
|
+
aws_tooling_jobs_bucket: exercism-staging-tooling-jobs
|
4
5
|
dynamodb_tooling_jobs_table: tooling_jobs
|
5
6
|
mysql_master_endpoint: mysql
|
6
7
|
mysql_port: 3306
|
@@ -1,6 +1,7 @@
|
|
1
1
|
anycable_redis_url: redis://127.0.0.1:6379/1
|
2
2
|
anycable_rpc_host: 127.0.0.1:50051
|
3
3
|
aws_iterations_bucket: exercism-staging-iterations
|
4
|
+
aws_tooling_jobs_bucket: exercism-staging-tooling-jobs
|
4
5
|
dynamodb_tooling_jobs_table: tooling_jobs
|
5
6
|
mysql_master_endpoint: localhost
|
6
7
|
mysql_socket: /tmp/mysql.sock
|
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.
|
4
|
+
version: 0.41.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: 2020-08-
|
11
|
+
date: 2020-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-dynamodb
|
@@ -131,7 +131,6 @@ executables:
|
|
131
131
|
extensions: []
|
132
132
|
extra_rdoc_files: []
|
133
133
|
files:
|
134
|
-
- ".github/config/rubocop_linter_action.yml"
|
135
134
|
- ".github/workflows/rubocop.yml"
|
136
135
|
- ".github/workflows/tests.yml"
|
137
136
|
- ".gitignore"
|
@@ -150,17 +149,16 @@ files:
|
|
150
149
|
- lib/exercism-config.rb
|
151
150
|
- lib/exercism/config.rb
|
152
151
|
- lib/exercism_config/determine_environment.rb
|
152
|
+
- lib/exercism_config/environment.rb
|
153
153
|
- lib/exercism_config/generate_aws_settings.rb
|
154
154
|
- lib/exercism_config/retrieve.rb
|
155
155
|
- lib/exercism_config/setup_dynamodb_client.rb
|
156
156
|
- lib/exercism_config/setup_s3_client.rb
|
157
157
|
- lib/exercism_config/version.rb
|
158
158
|
- package.json
|
159
|
-
- settings/
|
159
|
+
- settings/ci.yml
|
160
160
|
- settings/docker.yml
|
161
|
-
- settings/
|
162
|
-
- settings/test-docker.yml
|
163
|
-
- settings/test-local.yml
|
161
|
+
- settings/local.yml
|
164
162
|
- yarn.lock
|
165
163
|
homepage: https://exercism.io
|
166
164
|
licenses: []
|
data/settings/test-docker.yml
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
anycable_redis_url: redis://some_anycable_redis_url:1234/9
|
2
|
-
anycable_rpc_host: 1.2.3.4:9876543
|
3
|
-
aws_iterations_bucket: some-iterations-bucket
|
4
|
-
dynamodb_tooling_jobs_table: some_tooling_table
|
5
|
-
spi_url: http://some_url:1234
|
6
|
-
tooling_orchestrator_url: http://some_orchestrator_url:1234
|
7
|
-
|
8
|
-
mysql_master_endpoint: mysql
|
9
|
-
mysql_port: 3306
|
data/settings/test-local.yml
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
anycable_redis_url: redis://some_anycable_redis_url:1234/9
|
2
|
-
anycable_rpc_host: 1.2.3.4:9876543
|
3
|
-
aws_iterations_bucket: some-iterations-bucket
|
4
|
-
dynamodb_tooling_jobs_table: some_tooling_table
|
5
|
-
spi_url: http://some_url:1234
|
6
|
-
tooling_orchestrator_url: http://some_orchestrator_url:1234
|
7
|
-
|
8
|
-
mysql_master_endpoint: localhost
|
9
|
-
mysql_socket: /tmp/mysql.sock
|