exercism_config 0.27.0 → 0.32.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/config/rubocop_linter_action.yml +12 -0
- data/.github/workflows/rubocop.yml +17 -0
- data/.github/workflows/tests.yml +81 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +81 -0
- data/.ruby-version +1 -0
- data/Gemfile +2 -2
- data/Rakefile +6 -6
- data/bin/console +3 -3
- data/bin/release +3 -0
- data/bin/rubocop-quick +4 -0
- data/bin/setup_exercism_config +26 -26
- data/bin/setup_exercism_local_aws +97 -0
- data/exercism_config.gemspec +26 -18
- data/lib/exercism/config.rb +1 -1
- data/lib/exercism_config.rb +2 -2
- data/lib/exercism_config/determine_environment.rb +2 -2
- data/lib/exercism_config/generate_aws_settings.rb +4 -8
- data/lib/exercism_config/retrieve.rb +16 -9
- data/lib/exercism_config/setup_dynamodb_client.rb +6 -4
- data/lib/exercism_config/setup_s3_client.rb +4 -5
- data/lib/exercism_config/version.rb +1 -1
- data/package.json +12 -0
- data/settings/development.yml +4 -4
- data/settings/docker.yml +5 -5
- data/settings/{ci.yml → test-ci.yml} +5 -5
- data/settings/test-docker.yml +9 -0
- data/settings/test-local.yml +9 -0
- data/yarn.lock +527 -0
- metadata +79 -12
- data/Gemfile.lock +0 -42
- data/settings/test.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e14b3c0708d9db6b12e6f4caaa5057843b3efc625f6cbad8876035cdf8aae053
|
4
|
+
data.tar.gz: 6de2537d9b2409de7e2160064ebb60dac184863184b24f046e8b440c87bd8981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3283719f6c0d60fbd9ab3c1bf9fb8f4a56f22320daf970fd879e1dfe22687a05dfe1f41ed44fb569a39368447ffd9fa86179b42c89a86a349fe7645016ecf0da
|
7
|
+
data.tar.gz: ead756a7f96597671973354b297bb333cbb127c6b1699c9b6d67ce7a52f5bec25fbe8b4559217b9e86f3d6ea3aaa3c8d44f64653ba25a3922389d2fee7a22c78
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: Rubocop
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
rubocop:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Rubocop Linter Action
|
15
|
+
uses: andrewmcodes/rubocop-linter-action@v3.0.0
|
16
|
+
env:
|
17
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
services:
|
14
|
+
dynamodb:
|
15
|
+
image: "amazon/dynamodb-local"
|
16
|
+
ports:
|
17
|
+
- 8000
|
18
|
+
|
19
|
+
steps:
|
20
|
+
###
|
21
|
+
# Checkout using GitHub's checkout action
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
|
24
|
+
###
|
25
|
+
# Setup Ruby - this needs to match the version in the Gemfile
|
26
|
+
- name: Set up Ruby
|
27
|
+
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
28
|
+
with:
|
29
|
+
ruby-version: 2.6.6
|
30
|
+
|
31
|
+
###
|
32
|
+
# Caching using GitHub's caching action
|
33
|
+
- name: Cache Bundler
|
34
|
+
uses: actions/cache@v2
|
35
|
+
with:
|
36
|
+
path: vendor/bundle
|
37
|
+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
38
|
+
restore-keys: |
|
39
|
+
${{ runner.os }}-gems-
|
40
|
+
|
41
|
+
###
|
42
|
+
# Install bundler and yarn dependencies
|
43
|
+
- name: Install dependencies
|
44
|
+
env:
|
45
|
+
EXERCISM_ENV: test
|
46
|
+
EXERCISM_CI: true
|
47
|
+
DYNAMODB_PORT: ${{ job.services.dynamodb.ports['8000'] }}
|
48
|
+
run: |
|
49
|
+
bundle config path vendor/bundle # This is needed for the caching above
|
50
|
+
bundle install --jobs 4 --retry 3
|
51
|
+
bundle exec setup_exercism_config
|
52
|
+
|
53
|
+
###
|
54
|
+
# Setup code climate
|
55
|
+
# - name: Setup Code Climate test-reporter
|
56
|
+
# run: |
|
57
|
+
# curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
58
|
+
# chmod +x ./cc-test-reporter
|
59
|
+
# ./cc-test-reporter before-build
|
60
|
+
|
61
|
+
###
|
62
|
+
# Run the tests
|
63
|
+
- name: Run Ruby tests
|
64
|
+
env:
|
65
|
+
EXERCISM_ENV: test
|
66
|
+
EXERCISM_CI: true
|
67
|
+
DYNAMODB_PORT: ${{ job.services.dynamodb.ports['8000'] }}
|
68
|
+
CAPTURE_CODE_COVERAGE: true
|
69
|
+
run: |
|
70
|
+
bundle exec rake test
|
71
|
+
#./cc-test-reporter format-coverage -t simplecov -o codeclimate.backend.json coverage/backend/.resultset.json
|
72
|
+
|
73
|
+
###
|
74
|
+
# Publish the coverage to CodeClimate
|
75
|
+
# - name: Publish code coverage
|
76
|
+
# env:
|
77
|
+
# GIT_BRANCH: ${GITHUB_REF/refs\/heads\//}
|
78
|
+
# CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
|
79
|
+
# run: |
|
80
|
+
# ./cc-test-reporter sum-coverage codeclimate.*.json -p 2 -o codeclimate.total.json
|
81
|
+
# ./cc-test-reporter upload-coverage -i codeclimate.total.json
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-minitest
|
3
|
+
- rubocop-performance
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
NewCops: disable
|
7
|
+
Exclude:
|
8
|
+
- "bin/**/*"
|
9
|
+
|
10
|
+
Bundler/OrderedGems:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Layout/DotPosition:
|
14
|
+
EnforcedStyle: trailing
|
15
|
+
|
16
|
+
Layout/EndOfLine:
|
17
|
+
EnforcedStyle: lf
|
18
|
+
|
19
|
+
Layout/MultilineMethodCallIndentation:
|
20
|
+
EnforcedStyle: indented
|
21
|
+
|
22
|
+
Layout/EmptyLinesAroundAccessModifier:
|
23
|
+
EnforcedStyle: only_before
|
24
|
+
|
25
|
+
#Layout/LineLength:
|
26
|
+
#Exclude:
|
27
|
+
|
28
|
+
Lint/SuppressedException:
|
29
|
+
Exclude:
|
30
|
+
- "test/**/*"
|
31
|
+
- "lib/tooling_invoker/runc_wrapper.rb"
|
32
|
+
- "lib/tooling_invoker/external_command.rb"
|
33
|
+
|
34
|
+
Metrics/BlockLength:
|
35
|
+
Exclude:
|
36
|
+
- "test/**/*"
|
37
|
+
|
38
|
+
Metrics/MethodLength:
|
39
|
+
# We probably want to bring this down but let's start here for now
|
40
|
+
Max: 20
|
41
|
+
Exclude:
|
42
|
+
- "test/**/*"
|
43
|
+
|
44
|
+
Naming/PredicateName:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
Style/StringLiterals:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Style/FrozenStringLiteralComment:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Style/Documentation:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
Style/DocumentationMethod:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
Style/IfUnlessModifier:
|
60
|
+
Exclude:
|
61
|
+
- "lib/exercism_config/setup_dynamodb_client.rb"
|
62
|
+
|
63
|
+
Style/NumericPredicate:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
Style/RedundantSelf:
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
Style/ZeroLengthPredicate:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
# I don't mind this being enabled if
|
73
|
+
# someone fixes all the fails.
|
74
|
+
Style/ClassAndModuleChildren:
|
75
|
+
Enabled: false
|
76
|
+
|
77
|
+
Naming/VariableNumber:
|
78
|
+
EnforcedStyle: snake_case
|
79
|
+
|
80
|
+
Style/LambdaCall:
|
81
|
+
EnforcedStyle: braces
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.6.6
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
3
|
|
4
4
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
7
|
-
t.test_files = FileList[
|
5
|
+
t.libs << 'test'
|
6
|
+
t.libs << 'lib'
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
8
|
end
|
9
9
|
|
10
|
-
task :
|
10
|
+
task default: :test
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'exercism_config'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "exercism_config"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/bin/release
ADDED
data/bin/rubocop-quick
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
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,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'exercism_config'
|
5
5
|
require 'erb'
|
6
6
|
require 'yaml'
|
7
7
|
|
8
|
-
env = ExercismConfig::DetermineEnvironment.
|
8
|
+
env = ExercismConfig::DetermineEnvironment.call
|
9
9
|
if env == :production
|
10
|
-
puts
|
11
|
-
exit
|
10
|
+
puts 'Aborted! This script should not be run in production.'
|
11
|
+
exit
|
12
12
|
end
|
13
13
|
|
14
14
|
def create_table(client)
|
@@ -16,26 +16,26 @@ def create_table(client)
|
|
16
16
|
table_name: :config,
|
17
17
|
attribute_definitions: [
|
18
18
|
{
|
19
|
-
attribute_name:
|
20
|
-
attribute_type:
|
21
|
-
}
|
19
|
+
attribute_name: 'id',
|
20
|
+
attribute_type: 'S'
|
21
|
+
}
|
22
22
|
],
|
23
23
|
key_schema: [
|
24
24
|
{
|
25
|
-
attribute_name:
|
26
|
-
key_type:
|
25
|
+
attribute_name: 'id',
|
26
|
+
key_type: 'HASH'
|
27
27
|
}
|
28
28
|
],
|
29
29
|
provisioned_throughput: {
|
30
|
-
read_capacity_units: 1,
|
31
|
-
write_capacity_units: 1
|
30
|
+
read_capacity_units: 1,
|
31
|
+
write_capacity_units: 1
|
32
32
|
}
|
33
33
|
)
|
34
34
|
end
|
35
35
|
|
36
36
|
def delete_table(client)
|
37
37
|
client.delete_table(
|
38
|
-
table_name: :config
|
38
|
+
table_name: :config
|
39
39
|
)
|
40
40
|
end
|
41
41
|
|
@@ -49,31 +49,31 @@ def set_config_value(client, id, value)
|
|
49
49
|
)
|
50
50
|
end
|
51
51
|
|
52
|
-
client = ExercismConfig::SetupDynamoDBClient.
|
52
|
+
client = ExercismConfig::SetupDynamoDBClient.call
|
53
53
|
|
54
54
|
begin
|
55
55
|
create_table(client)
|
56
56
|
rescue Aws::DynamoDB::Errors::ResourceInUseException => e
|
57
|
-
if ARGV.include?(
|
58
|
-
puts
|
57
|
+
if ARGV.include?('--force')
|
58
|
+
puts 'Table exists. Recreating...'
|
59
59
|
delete_table(client)
|
60
60
|
create_table(client)
|
61
|
-
puts
|
61
|
+
puts 'Table recreated.'
|
62
62
|
else
|
63
|
-
puts
|
63
|
+
puts 'Table exists. Not recreating.'
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
settings_file_arg = ARGV.select{|arg|arg.start_with?(
|
68
|
-
settings_file =
|
67
|
+
settings_file_arg = ARGV.select { |arg| arg.start_with?('--settings-file=') }.first
|
68
|
+
settings_file =
|
69
69
|
if settings_file_arg
|
70
|
-
settings_file_arg.split(
|
71
|
-
elsif ENV[
|
72
|
-
File.expand_path(
|
73
|
-
elsif ENV[
|
74
|
-
File.expand_path(
|
70
|
+
settings_file_arg.split('=').last
|
71
|
+
elsif ENV['EXERCISM_DOCKER']
|
72
|
+
File.expand_path('../settings/docker.yml', __dir__)
|
73
|
+
elsif ENV['EXERCISM_CI']
|
74
|
+
File.expand_path('../settings/test-ci.yml', __dir__)
|
75
75
|
else
|
76
|
-
File.expand_path(
|
76
|
+
File.expand_path('../settings/development.yml', __dir__)
|
77
77
|
end
|
78
78
|
|
79
79
|
puts "Using settings file: #{settings_file}"
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "bundler/setup"
|
3
|
+
require "exercism_config"
|
4
|
+
|
5
|
+
# Only allow this to run in development
|
6
|
+
return unless Exercism.environment == :development
|
7
|
+
|
8
|
+
puts "Create AWS/DynamoDB tables..."
|
9
|
+
|
10
|
+
Exercism.config.dynamodb_client = ExercismConfig::SetupDynamoDBClient.()
|
11
|
+
|
12
|
+
##################
|
13
|
+
# Setup local s3 #
|
14
|
+
##################
|
15
|
+
|
16
|
+
# We don't need this running for CI atm as none of our
|
17
|
+
# tests actually hit s3. Although we might choose to change this
|
18
|
+
unless ENV["EXERCISM_CI"]
|
19
|
+
begin
|
20
|
+
ExercismConfig::SetupS3Client.().create_bucket(bucket: Exercism.config.aws_iterations_bucket)
|
21
|
+
rescue Seahorse::Client::NetworkingError => e
|
22
|
+
puts "local S3 not up yet..."
|
23
|
+
sleep 2 # slighty retry delaty
|
24
|
+
retry
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
########################
|
29
|
+
# Setup local dynamodb #
|
30
|
+
########################
|
31
|
+
%w[tooling_jobs tooling_jobs-test].each do |table_name|
|
32
|
+
begin
|
33
|
+
Exercism.config.dynamodb_client.delete_table(
|
34
|
+
table_name: table_name
|
35
|
+
)
|
36
|
+
rescue Aws::DynamoDB::Errors::ResourceNotFoundException
|
37
|
+
end
|
38
|
+
puts "[x] #{table_name}"
|
39
|
+
|
40
|
+
Exercism.config.dynamodb_client.create_table(
|
41
|
+
table_name: table_name,
|
42
|
+
attribute_definitions: [
|
43
|
+
{
|
44
|
+
attribute_name: "id",
|
45
|
+
attribute_type: "S"
|
46
|
+
}
|
47
|
+
],
|
48
|
+
key_schema: [
|
49
|
+
{
|
50
|
+
attribute_name: "id",
|
51
|
+
key_type: "HASH"
|
52
|
+
}
|
53
|
+
],
|
54
|
+
provisioned_throughput: {
|
55
|
+
read_capacity_units: 1,
|
56
|
+
write_capacity_units: 1
|
57
|
+
}
|
58
|
+
)
|
59
|
+
|
60
|
+
Exercism.config.dynamodb_client.update_table(
|
61
|
+
table_name: table_name,
|
62
|
+
attribute_definitions: [
|
63
|
+
{
|
64
|
+
attribute_name: "job_status",
|
65
|
+
attribute_type: "S"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
attribute_name: "created_at",
|
69
|
+
attribute_type: "N"
|
70
|
+
}
|
71
|
+
],
|
72
|
+
global_secondary_index_updates: [
|
73
|
+
{
|
74
|
+
create: {
|
75
|
+
index_name: "job_status", # required
|
76
|
+
key_schema: [ # required
|
77
|
+
{
|
78
|
+
attribute_name: "job_status", # required
|
79
|
+
key_type: "HASH" # required, accepts HASH, RANGE
|
80
|
+
},
|
81
|
+
{
|
82
|
+
attribute_name: "created_at", # required
|
83
|
+
key_type: "RANGE" # required, accepts HASH, RANGE
|
84
|
+
}
|
85
|
+
],
|
86
|
+
projection: { # required
|
87
|
+
projection_type: "KEYS_ONLY"
|
88
|
+
},
|
89
|
+
provisioned_throughput: {
|
90
|
+
read_capacity_units: 1, # required
|
91
|
+
write_capacity_units: 1 # required
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
]
|
96
|
+
)
|
97
|
+
end
|