Skip to content

Commit

Permalink
Fix conflicts after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunk13 committed Feb 14, 2024
2 parents 40c9b06 + e00080c commit 1fc306f
Show file tree
Hide file tree
Showing 49 changed files with 458 additions and 83 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
bin/
test/
tests/
node_modules/
.appends
.git
Expand All @@ -7,3 +9,5 @@ node_modules/
.gitattributes
.dockerignore
Dockerfile
!bin/run.sh
!bin/run.rb
20 changes: 13 additions & 7 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@ on:

jobs:
rubocop:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Set up Ruby
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939
uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7
with:
ruby-version: 3.0.2
ruby-version: .ruby-version
bundler-cache: true

- name: Install gems
run: |
gem install rubocop
gem install rubocop-minitest
gem install rubocop-performance
# Extract the exact versions of the rubocop gems from Gemfile.lock
rubocop_version=$(sed -n -E 's/^ rubocop \((.+)\)/\1/p' Gemfile.lock)
rubocop_minitest_version=$(sed -n -E 's/^ rubocop-minitest \((.+)\)/\1/p' Gemfile.lock)
rubocop_performance_version=$(sed -n -E 's/^ rubocop-performance \((.+)\)/\1/p' Gemfile.lock)
gem install rubocop -v $rubocop_version
gem install rubocop-minitest -v $rubocop_minitest_version
gem install rubocop-performance -v $rubocop_performance_version
- name: Run Rubocop
run: rubocop --except Metrics
78 changes: 44 additions & 34 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,56 @@
name: Tests

on:
push:
branches: [main]
pull_request:
branches: [main]
branches:
- main
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
unit_tests:
name: Unit tests
runs-on: ubuntu-22.04

steps:
# Checkout using GitHub's checkout action
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

# Setup Ruby - this needs to match the version in the Gemfile
- name: Set up Ruby
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939
- name: Setup Ruby
uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7
with:
ruby-version: 3.0.2
ruby-version: .ruby-version
bundler-cache: true

# Setup code climate
- name: Setup Code Climate test-reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
# Run the tests
- name: Run Ruby tests
env:
CAPTURE_CODE_COVERAGE: true
run: |
bundle exec rake test
./cc-test-reporter format-coverage -t simplecov -o codeclimate.backend.json coverage/backend/.resultset.json
# Publish the coverage to CodeClimate
- name: Publish code coverage
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
env:
GIT_BRANCH: ${GITHUB_REF/refs\/heads\//}
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
run: |
./cc-test-reporter upload-coverage -i codeclimate.*.json
- name: Install gems
run: bundle install

- name: Run tests
run: bundle exec rake test

smoke_tests:
name: Smoke tests
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
with:
install: true

- name: Build Docker image and store in cache
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: .
push: false
load: true
tags: exercism/ruby-test-runner
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run Tests in Docker
run: bin/run-tests-in-docker.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
tests/**/results.json
21 changes: 20 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ AllCops:
- "bin/**/*"
- "Gemfile"
- "Gemfile.lock"
- "test/fixtures/**/*"
- "test/fixtures**/*"
- "test/fixtures/syntax_error_in_code/input/two_fer.rb"
- "test/fixtures/syntax_error_in_tests/input/two_fer_test.rb"
- "tests/**/*"
- "vendor/**/*"

Bundler/OrderedGems:
Expand All @@ -30,6 +33,18 @@ Layout/MultilineMethodCallIndentation:
Layout/EmptyLinesAroundAccessModifier:
EnforcedStyle: only_before

Layout/TrailingEmptyLines:
Exclude:
- "test/**/*"

Layout/CommentIndentation:
Exclude:
- "test/**/*"

Layout/LeadingCommentSpace:
Exclude:
- "test/**/*"

Lint/SuppressedException:
Exclude:
- "test/**/*"
Expand Down Expand Up @@ -81,3 +96,7 @@ Naming/VariableNumber:

Style/LambdaCall:
EnforcedStyle: braces

Style/RedundantReturn:
Exclude:
- "test/**/*"
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-3.0.2
ruby-3.2.2
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ This policy was initially adopted from the Front-end London Slack community and
A version history can be seen on [GitHub](https://github.com/exercism/website-copy/edit/main/pages/code_of_conduct.md).

_This policy is a "living" document, and subject to refinement and expansion in the future.
This policy applies to the Exercism website, the Exercism GitHub organization, any other Exercism-related communication channels (e.g. Slack, Twitter, email) and any other Exercism entity or event._
This policy applies to the Exercism website, the Exercism GitHub organization, any other Exercism-related communication channels (e.g. Discord, Forum, Twitter, email) and any other Exercism entity or event._
21 changes: 12 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
FROM ruby:3.0.2-alpine
FROM ruby:3.2.2-alpine3.18 AS build

RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh && \
apk add build-base gcc wget git
apk add --no-cache git openssh build-base gcc wget git

RUN wget -P /usr/local/bin https://github.com/exercism/tooling-webserver/releases/latest/download/tooling_webserver && \
chmod +x /usr/local/bin/tooling_webserver
COPY Gemfile Gemfile.lock .

WORKDIR /opt/test-runner

COPY Gemfile Gemfile.lock ./
RUN gem install bundler:2.2.29 && \
RUN gem install bundler:2.4.18 && \
bundle config set without 'development test' && \
bundle install

FROM ruby:3.2.2-alpine3.18

RUN apk add --no-cache bash

WORKDIR /opt/test-runner

COPY --from=build /usr/local/bundle /usr/local/bundle

COPY . .

ENTRYPOINT [ "sh", "/opt/test-runner/bin/run.sh" ]
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end

ruby '3.0.2'
ruby '3.2.2'

gem "mandate", "~> 1.0.0"
gem 'rake'
Expand Down
41 changes: 24 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,52 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
base64 (0.1.1)
coderay (1.1.3)
docile (1.3.2)
json (2.6.1)
language_server-protocol (3.17.0.3)
mandate (1.0.0)
method_source (1.0.0)
minitest (5.11.3)
mocha (1.11.2)
parallel (1.19.2)
parser (3.0.2.0)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
rainbow (3.0.0)
racc (1.7.1)
rainbow (3.1.1)
rake (12.3.3)
regexp_parser (1.8.2)
rexml (3.2.4)
rubocop (0.90.0)
regexp_parser (2.8.1)
rexml (3.2.6)
rubocop (1.56.0)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 2.7.1.1)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.3.0, < 1.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.3.0)
parser (>= 2.7.1.4)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-minitest (0.10.1)
rubocop (>= 0.87)
rubocop-performance (1.8.0)
rubocop (>= 0.87.0)
ruby-progressbar (1.10.1)
ruby-progressbar (1.13.0)
simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
unicode-display_width (1.7.0)
unicode-display_width (2.4.2)

PLATFORMS
ruby
Expand All @@ -60,7 +67,7 @@ DEPENDENCIES
simplecov (~> 0.17.0)

RUBY VERSION
ruby 3.0.2p107
ruby 3.2.2p53

BUNDLED WITH
2.2.29
2.4.18
2 changes: 1 addition & 1 deletion bin/rubocop-quick
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

git diff --name-status --staged | grep '^[MA]' | grep -o '\s\+.*rb' | xargs bundle exec rubocop --except Metrics --auto-correct --format quiet --force-exclusion Gemfile && \
git diff --name-status --staged | grep '^[MA]' | grep -o '\s\+.*rb' | xargs bundle exec rubocop --except Metrics --autocorrect --format quiet --force-exclusion Gemfile && \
git diff --name-status --staged | grep '^[MA]' | grep -o '\s\+.*rb' | xargs git add
46 changes: 46 additions & 0 deletions bin/run-in-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env sh

# Synopsis:
# Run the test runner on a solution using the test runner Docker image.
# The test runner Docker image is built automatically.

# Arguments:
# $1: exercise slug
# $2: path to solution folder
# $3: path to output directory

# Output:
# Writes the test results to a results.json file in the passed-in output directory.
# The test results are formatted according to the specifications at https://github.com/exercism/docs/blob/main/building/tooling/test-runners/interface.md

# Example:
# ./bin/run-in-docker.sh two-fer path/to/solution/folder/ path/to/output/directory/

# Stop executing when a command returns a non-zero return code
set -e

# If any required arguments is missing, print the usage and exit
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "usage: ./bin/run-in-docker.sh exercise-slug path/to/solution/folder/ path/to/output/directory/"
exit 1
fi

slug="$1"
solution_dir=$(realpath "${2%/}")
output_dir=$(realpath "${3%/}")

# Create the output directory if it doesn't exist
mkdir -p "${output_dir}"

# Build the Docker image
docker build --rm -t exercism/ruby-test-runner .

# Run the Docker image using the settings mimicking the production environment
docker run \
--rm \
--network none \
--read-only \
--mount type=bind,src="${solution_dir}",dst=/solution \
--mount type=bind,src="${output_dir}",dst=/output \
--mount type=tmpfs,dst=/tmp \
exercism/ruby-test-runner "${slug}" /solution /output
31 changes: 31 additions & 0 deletions bin/run-tests-in-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env sh

# Synopsis:
# Test the test runner Docker image by running it against a predefined set of
# solutions with an expected output.
# The test runner Docker image is built automatically.

# Output:
# Outputs the diff of the expected test results against the actual test results
# generated by the test runner Docker image.

# Example:
# ./bin/run-tests-in-docker.sh

# Stop executing when a command returns a non-zero return code
set -e

# Build the Docker image
docker build --rm -t exercism/ruby-test-runner .

# Run the Docker image using the settings mimicking the production environment
docker run \
--rm \
--network none \
--read-only \
--mount type=bind,src="${PWD}/tests",dst=/opt/test-runner/tests \
--mount type=tmpfs,dst=/tmp \
--volume "${PWD}/bin/run-tests.sh:/opt/test-runner/bin/run-tests.sh" \
--workdir /opt/test-runner \
--entrypoint /opt/test-runner/bin/run-tests.sh \
exercism/ruby-test-runner
Loading

0 comments on commit 1fc306f

Please sign in to comment.