Skip to content

Commit 19ca440

Browse files
committed
Add first pass of snippet extractor
0 parents  commit 19ca440

27 files changed

+1711
-0
lines changed

Diff for: .dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test/
2+
scripts/
3+
node_modules/

Diff for: .github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @exercism/maintainers-admin

Diff for: .github/workflows/docker.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Push Docker images to DockerHub and ECR
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
7+
jobs:
8+
multiple-registries:
9+
runs-on: ubuntu-latest
10+
11+
env:
12+
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # 2.3.4
17+
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@154c24e1f33dbb5865a021c99f1318cfebf27b32 # 1.1.1
20+
21+
- name: Cache Docker layers
22+
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a # 2.1.3
23+
with:
24+
path: /tmp/.buildx-cache
25+
key: ${{ runner.os }}-buildx-${{ github.sha }}
26+
restore-keys: |
27+
${{ runner.os }}-buildx-
28+
29+
- name: Login to DockerHub
30+
uses: docker/login-action@f3364599c6aa293cdc2b8391b1b56d0c30e45c8a # 1.8.0
31+
with:
32+
username: ${{ secrets.DOCKERHUB_USERNAME }}
33+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
34+
35+
- name: Login to ECR
36+
uses: docker/login-action@f3364599c6aa293cdc2b8391b1b56d0c30e45c8a # 1.8.0
37+
with:
38+
registry: ${{ env.ECR_REGISTRY }}
39+
username: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
40+
password: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}
41+
42+
- name: Build and push Docker image
43+
uses: docker/build-push-action@0db984c1826869dcd0740ff26ff75ff543238fd9 # 2.2.2
44+
with:
45+
context: .
46+
file: ./Dockerfile
47+
push: true
48+
tags: |
49+
${{ github.event.repository.full_name }}:latest
50+
${{ github.event.repository.full_name }}:${{ github.sha }}
51+
${{ env.ECR_REGISTRY }}/${{ github.event.repository.name }}:production
52+
${{ env.ECR_REGISTRY }}/${{ github.event.repository.name }}:${{ github.sha }}
53+
cache-from: type=local,src=/tmp/.buildx-cache
54+
cache-to: type=local,dest=/tmp/.buildx-cache

Diff for: .github/workflows/rubocop.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Set up Ruby
17+
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
18+
with:
19+
ruby-version: 2.5.8
20+
21+
- name: Install gems
22+
run: |
23+
gem install rubocop
24+
gem install rubocop-minitest
25+
gem install rubocop-performance
26+
27+
- name: Run Rubocop
28+
run: rubocop --except Metrics

Diff for: .github/workflows/tests.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
steps:
14+
# Checkout using GitHub's checkout action
15+
- uses: actions/checkout@v2
16+
17+
# Setup Ruby - this needs to match the version in the Gemfile
18+
- name: Set up Ruby
19+
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
20+
with:
21+
ruby-version: 2.5.8
22+
23+
# Caching using GitHub's caching action
24+
- name: Cache Bundler
25+
uses: actions/cache@v2
26+
with:
27+
path: vendor/bundle
28+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-gems-
31+
32+
# Install bundler and yarn dependencies
33+
- name: Install dependencies
34+
run: |
35+
bundle config path vendor/bundle # This is needed for the caching above
36+
bundle install --jobs 4 --retry 3
37+
38+
# Setup code climate
39+
- name: Setup Code Climate test-reporter
40+
run: |
41+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
42+
chmod +x ./cc-test-reporter
43+
./cc-test-reporter before-build
44+
45+
# Run the tests
46+
- name: Run Ruby tests
47+
env:
48+
CAPTURE_CODE_COVERAGE: true
49+
run: |
50+
bundle exec rake test
51+
./cc-test-reporter format-coverage -t simplecov -o codeclimate.backend.json coverage/backend/.resultset.json
52+
53+
# Publish the coverage to CodeClimate
54+
- name: Publish code coverage
55+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
56+
env:
57+
GIT_BRANCH: ${GITHUB_REF/refs\/heads\//}
58+
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
59+
run: |
60+
./cc-test-reporter upload-coverage -i codeclimate.*.json

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/fixtures/
2+
/tmp/
3+
4+
node_modules

Diff for: .rubocop.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
require:
2+
- rubocop-minitest
3+
- rubocop-performance
4+
5+
AllCops:
6+
NewCops: disable
7+
Exclude:
8+
- "bin/**/*"
9+
- "Gemfile"
10+
- "Gemfile.lock"
11+
12+
Bundler/OrderedGems:
13+
Enabled: false
14+
15+
Layout/DotPosition:
16+
EnforcedStyle: trailing
17+
18+
Layout/EndOfLine:
19+
EnforcedStyle: lf
20+
21+
Layout/MultilineMethodCallIndentation:
22+
EnforcedStyle: indented
23+
24+
Layout/EmptyLinesAroundAccessModifier:
25+
EnforcedStyle: only_before
26+
27+
Layout/LineLength:
28+
Exclude:
29+
- "scripts/generate_fixture.rb"
30+
31+
Lint/SuppressedException:
32+
Exclude:
33+
- "test/**/*"
34+
35+
Metrics/BlockLength:
36+
Exclude:
37+
- "test/**/*"
38+
39+
Metrics/MethodLength:
40+
# We probably want to bring this down but let's start here for now
41+
Max: 20
42+
Exclude:
43+
- "test/**/*"
44+
45+
Naming/PredicateName:
46+
Enabled: false
47+
48+
Style/StringLiterals:
49+
Enabled: false
50+
51+
Style/FrozenStringLiteralComment:
52+
Enabled: false
53+
54+
Style/Documentation:
55+
Enabled: false
56+
57+
Style/DocumentationMethod:
58+
Enabled: false
59+
60+
Style/NumericPredicate:
61+
Enabled: false
62+
63+
Style/RedundantSelf:
64+
Enabled: false
65+
66+
Style/ZeroLengthPredicate:
67+
Enabled: false
68+
69+
# I don't mind this being enabled if
70+
# someone fixes all the fails.
71+
Style/ClassAndModuleChildren:
72+
Enabled: false
73+
74+
Naming/VariableNumber:
75+
EnforcedStyle: snake_case
76+
77+
Style/LambdaCall:
78+
EnforcedStyle: braces

Diff for: .ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.6.6

Diff for: Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ruby:2.6.6-alpine3.12
2+
3+
RUN apk update && apk upgrade && \
4+
apk add --no-cache bash git openssh && \
5+
apk add build-base gcc wget git
6+
7+
RUN gem install bundler -v 2.1.4
8+
9+
WORKDIR /opt/snippet-extractor
10+
11+
COPY . .
12+
13+
RUN bundle install
14+
15+
ENTRYPOINT ["sh", "/opt/snippet-extractor/bin/run.sh"]

Diff for: Gemfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
source 'https://rubygems.org'
2+
3+
git_source(:github) do |repo_name|
4+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
5+
"https://github.com/#{repo_name}.git"
6+
end
7+
8+
gem 'json'
9+
gem 'mandate'
10+
gem 'rake'
11+
12+
group :test do
13+
gem 'minitest', '~> 5.10', '!= 5.10.2'
14+
gem 'minitest-stub-const'
15+
gem 'mocha'
16+
gem 'pry'
17+
gem 'simplecov', '~> 0.17.0'
18+
end

Diff for: Gemfile.lock

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
coderay (1.1.3)
5+
docile (1.3.2)
6+
json (2.3.1)
7+
mandate (0.3.0)
8+
method_source (1.0.0)
9+
minitest (5.14.2)
10+
minitest-stub-const (0.6)
11+
mocha (1.11.2)
12+
pry (0.13.1)
13+
coderay (~> 1.1)
14+
method_source (~> 1.0)
15+
rake (13.0.1)
16+
simplecov (0.17.1)
17+
docile (~> 1.1)
18+
json (>= 1.8, < 3)
19+
simplecov-html (~> 0.10.0)
20+
simplecov-html (0.10.2)
21+
22+
PLATFORMS
23+
ruby
24+
25+
DEPENDENCIES
26+
json
27+
mandate
28+
minitest (~> 5.10, != 5.10.2)
29+
minitest-stub-const
30+
mocha
31+
pry
32+
rake
33+
simplecov (~> 0.17.0)
34+
35+
BUNDLED WITH
36+
2.1.4

0 commit comments

Comments
 (0)