Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
on:
push:
branches:
- master
pull_request:

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- ruby: 2.7
- ruby: 3
- ruby: 3.1
- ruby: 3.2
- ruby: 3.3
- ruby: 3.4
runs-on: ubuntu-latest
name: RSpec suite with Ruby ${{ matrix.ruby }}
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
FORCE_COLOR: 1
EARTHLY_RUBY_VERSION: ${{ matrix.ruby }}
steps:
- uses: earthly/actions-setup@v1
with:
version: "0.6.30"
- uses: actions/checkout@v3
- name: Put back the git branch into git (Earthly uses it for tagging)
run: |
branch=""
if [ -n "$GITHUB_HEAD_REF" ]; then
branch="$GITHUB_HEAD_REF"
else
branch="${GITHUB_REF##*/}"
fi
git checkout -b "$branch" || true
- name: Docker Login
run: docker login --username "$DOCKERHUB_USERNAME" --password "$DOCKERHUB_TOKEN"
- name: Earthly version
run: earthly --version
- name: Run Rubocop
run: earthly --ci --allow-privileged +rubocop --EARTHLY_RUBY_VERSION=$EARTHLY_RUBY_VERSION
- name: Run Rspec
run: earthly --ci --allow-privileged +rspec --EARTHLY_RUBY_VERSION=$EARTHLY_RUBY_VERSION
19 changes: 19 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require:
- rubocop-rspec

AllCops:
NewCops: enable
TargetRubyVersion: 2.7

Metrics/BlockLength:
AllowedMethods: ['describe', 'context']

Naming/RescuedExceptionsVariableName:
Enabled: Yes
PreferredName: error

RSpec/NestedGroups:
Max: 4

Style/Documentation:
Enabled: No
97 changes: 97 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
VERSION 0.6

# This allows one to change the running Ruby version with:
#
# `earthly --allow-privileged +rspec --EARTHLY_RUBY_VERSION=3`
ARG EARTHLY_RUBY_VERSION=2.7

FROM ruby:$EARTHLY_RUBY_VERSION
WORKDIR /gem

deps:
RUN apt update \
&& apt install --yes \
--no-install-recommends \
build-essential \
git

dev:
FROM +deps

COPY Gemfile* /gem/

IF [ $(dpkg --compare-versions "$EARTHLY_RUBY_VERSION" "gt" "2.6" && echo "true" || echo "false") = "true" ]
RUN echo "Using $(bundle --version) ..."
ELSE
ARG BUNDLER_VERSION=$(grep -A 1 \"BUNDLED WITH\" Gemfile.lock | tail -n1 | awk \"{print $1}\")
RUN echo "Installing Bundler $BUNDLER_VERSION ..." && gem install bundler --version $BUNDLER_VERSION
END

COPY *.gemspec /gem/
RUN bundle install --jobs $(nproc)

COPY .rubocop.yml /gem/
COPY Rakefile /gem/
COPY lib/ /gem/lib/
COPY spec/ /gem/spec/

ENTRYPOINT ["bundle", "exec"]
CMD ["rake"]

SAVE IMAGE juseveno/sms_factor:latest

#
# This target runs Rubocop.
#
# Use the following command in order to run the tests suite:
# earthly --allow-privileged +rubocop
rubocop:
FROM earthly/dind:alpine

COPY docker-compose-earthly.yml ./

WITH DOCKER --load juseveno/sms_factor:latest=+dev
RUN docker-compose -f docker-compose-earthly.yml run --rm gem rubocop
END

#
# This target runs the test suite.
#
# Use the following command in order to run the tests suite:
# earthly --allow-privileged +rspec
rspec:
FROM earthly/dind:alpine

COPY docker-compose-earthly.yml ./

WITH DOCKER --load juseveno/sms_factor:latest=+dev
RUN docker-compose -f docker-compose-earthly.yml run --rm gem
END

#
# This target is used to publish this gem to rubygems.org.
#
# Prerequiries
# You should have login against Rubygems.org so that it has created
# the `~/.gem` folder and stored your API key.
#
# Then use the following command:
# earthly +gem --GEM_CREDENTIALS="$(cat ~/.gem/credentials)" --RUBYGEMS_OTP=123456
gem:
FROM +dev

ARG GEM_CREDENTIALS
ARG RUBYGEMS_OTP

COPY .git/ /gem/
COPY LICENSE /gem/
COPY README.md /gem/

RUN gem build sms_factor.gemspec \
&& mkdir ~/.gem \
&& echo "$GEM_CREDENTIALS" > ~/.gem/credentials \
&& cat ~/.gem/credentials \
&& chmod 600 ~/.gem/credentials \
&& gem push --otp $RUBYGEMS_OTP sms_factor-*.gem

SAVE ARTIFACT sms_factor-*.gem AS LOCAL ./sms_factor.gem
16 changes: 16 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

source 'https://rubygems.org'
gemspec

# When updating the following gems, run `earthly +dev` in the case you're using
# Docker to develop this gem.
gem 'dry-struct'
gem 'dry-types'
gem 'ffaker'
gem 'rake'
gem 'rspec'
gem 'rubocop'
gem 'rubocop-rspec'
gem 'vcr'
gem 'webmock'
132 changes: 132 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
PATH
remote: .
specs:
sms_factor (0.2.2)
dry-struct (~> 1.6)
dry-types (~> 1.7)
nokogiri (~> 1.13, < 1.14)
rest-client (~> 2.0.2, >= 2.0.2)

GEM
remote: https://rubygems.org/
specs:
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.3)
base64 (0.3.0)
bigdecimal (3.2.2)
concurrent-ruby (1.3.5)
crack (1.0.0)
bigdecimal
rexml
diff-lcs (1.6.2)
domain_name (0.6.20240107)
dry-core (1.0.0)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
dry-inflector (1.1.0)
dry-logic (1.5.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-struct (1.6.0)
dry-core (~> 1.0, < 2)
dry-types (>= 1.7, < 2)
ice_nine (~> 0.11)
zeitwerk (~> 2.6)
dry-types (1.7.1)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0)
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
ffaker (2.21.0)
hashdiff (1.2.0)
http-cookie (1.0.8)
domain_name (~> 0.5)
ice_nine (0.11.2)
json (2.12.2)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
logger (1.7.0)
mime-types (3.7.0)
logger
mime-types-data (~> 3.2025, >= 3.2025.0507)
mime-types-data (3.2025.0701)
netrc (0.11.0)
nokogiri (1.13.10-x86_64-linux)
racc (~> 1.4)
parallel (1.27.0)
parser (3.3.8.0)
ast (~> 2.4.1)
racc
prism (1.4.0)
public_suffix (5.1.1)
racc (1.8.1)
rainbow (3.1.1)
rake (13.3.0)
regexp_parser (2.10.0)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.4.1)
rspec (3.13.1)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.5)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.4)
rubocop (1.77.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.45.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.45.1)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-rspec (3.6.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
ruby-progressbar (1.13.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
vcr (6.3.1)
base64
webmock (3.25.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
zeitwerk (2.6.18)

PLATFORMS
ruby

DEPENDENCIES
dry-struct
dry-types
ffaker
rake
rspec
rubocop
rubocop-rspec
sms_factor!
vcr
webmock

BUNDLED WITH
2.3.26
Loading