Skip to content

Commit

Permalink
Sets up initial gem to patch shoulda-matchers
Browse files Browse the repository at this point in the history
Since we're taking advantage of storing UUIDs in MySQL as `binary`, the shoulda-matchers has an issue when the UUID ends in an `f`.  This has lead to some flakey tests.  [We made an effort to fix this upstream](thoughtbot/shoulda-matchers#1159), which doesn't appear to be gaining traction.  This extracts the fix into a gem so we don't have to support a hard fork for this.

* Adds rubocop and fix linter issues
* Adds circleci config and ingore gem build artifacts
* Adds CHANGELOG.md with latest change
* Ensure database.yml is correctly setup for CI
* Ensure CI builds with mysql to ensure tests run
* Adds license to gemspec and updates readme with license info
* Prepare README for public consumption
* Update gem publishing to use Rubygems
* Removes dox-style in favor of raw rubocop configuration to make open-source compatable
  • Loading branch information
codenamev committed Feb 25, 2020
1 parent 772ce75 commit e631820
Show file tree
Hide file tree
Showing 58 changed files with 783 additions and 1 deletion.
140 changes: 140 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
version: 2.1

orbs:
gem: doximity/gem-publisher@0

executors:
ruby-latest:
resource_class: small
docker:
- image: circleci/ruby:2.6
environment:
BUNDLE_VERSION: "~> 1.17"
- image: circleci/mysql:5.6

# yaml anchor filters
master_only: &master_only
filters:
branches:
only: master
tags:
ignore: /.*/
pr_only: &pr_only
filters:
branches:
ignore: master
tags:
ignore: /.*/
version_tags_only: &version_tags_only
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/

jobs:
build:
executor: ruby-latest
steps:
- checkout
- run:
name: Install Bundler specific version
command: |
gem install bundler --version "${BUNDLE_VERSION}" --force
- restore_cache:
keys:
- v1-bundle-{{ checksum "Gemfile.lock" }}-
- run:
name: Install Ruby Dependencies
command: bundle check --path=vendor/bundle || bundle install --local --frozen --path=vendor/bundle --jobs=4 --retry=3
- save_cache:
key: v1-bundle-{{ checksum "Gemfile.lock" }}-
paths:
- vendor/bundle
- run:
name: Load mysql database from workspace
command: |
apt-get update -qq && apt-get install -y --no-install-recommends mysql-client
until `nc -z 127.0.0.1 3306`; do
echo 'Waiting for MySQL container...'
sleep 1
done
echo 'MySQL container is up'
- run:
name: Run Tests
command: bundle exec rake ci:specs
environment:
DATABASE_URL: mysql2://127.0.0.1:3306
- store_test_results:
name: Store test results
path: tmp/test-results
- run:
name: Run Rubocop
command: bundle exec rake ci:rubocop
- run:
name: Build documentation
command: bundle exec rake ci:doc
- store_artifacts:
name: Saves documentation
path: doc
- persist_to_workspace:
root: .
paths:
- vendor/bundle

workflows:
version: 2

trunk:
jobs:
- build:
<<: *master_only
- gem/build:
<<: *master_only
executor: ruby-latest
name: gem-build
requires:
- build

pull-requests:
jobs:
- build:
<<: *pr_only
- gem/build:
<<: *pr_only
executor: ruby-latest
name: gem-build
requires:
- build
- pre-release-approval:
<<: *pr_only
type: approval
requires:
- gem-build
- gem/publish:
<<: *pr_only
name: gem-publish
to_rubygems: true
pre_release: true
requires:
- pre-release-approval
context: artifact_publishing

final-release:
jobs:
- build:
<<: *version_tags_only
- gem/build:
<<: *version_tags_only
executor: ruby-latest
name: gem-build
requires:
- build
- gem/publish:
<<: *version_tags_only
name: gem-publish
to_rubygems: true
pre_release: false
requires:
- gem-build
context: artifact_publishing
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*.gem
/.bundle/
/.ruby-version
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/**/database.yml
/spec/reports/
/tmp/

# rspec failure tracking
.rspec_status

/vendor/bundle/
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--format documentation
--color
--require spec_helper
75 changes: 75 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
require:
- rubocop-rails
- rubocop-rspec

AllCops:
Exclude:
- "./vendor/**/*"
TargetRubyVersion: 2.6

Layout/DotPosition:
EnforcedStyle: trailing
Enabled: true
Layout/LineLength:
Max: 120

Lint/AmbiguousBlockAssociation:
Exclude:
- ./**/*_spec.rb
Lint/UselessAccessModifier:
ContextCreatingMethods:
- concerning

Metrics/AbcSize:
Max: 20
Metrics/BlockLength:
Exclude:
- "./**/*_spec*.rb"
- "./*.gemspec"
- "./spec/*_helper*.rb"
- "./tasks/ci.rake"
- "./lib/tasks/**/*.rake"
- "Gemfile"
Metrics/CyclomaticComplexity:
Max: 7
Metrics/ModuleLength:
Exclude:
- "./**/*_spec*.rb"
Metrics/MethodLength:
Max: 20
Exclude:
- "./**/*_spec*.rb"
Metrics/PerceivedComplexity:
Max: 8

RSpec/BeforeAfterAll:
Enabled: false
RSpec/ExampleLength:
Enabled: false
RSpec/IteratedExpectation:
Enabled: false
RSpec/FilePath:
Enabled: false
RSpec/MultipleExpectations:
Enabled: false

Rails/ApplicationRecord:
Enabled: false

Security/YAMLLoad:
AutoCorrect: false

Style/Documentation:
Enabled: false
Style/FormatStringToken:
EnforcedStyle: template
Style/LambdaCall:
Enabled: false
Style/NumericLiterals:
Enabled: false
Style/StringLiterals:
EnforcedStyle: double_quotes
ConsistentQuotesInMultiline: true
Enabled: true
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Changelog
=========

## 0.1.1 02/06/2020
* Adds CircleCi config
* Release on Nexus using gem-publisher CircleCI Orb
74 changes: 74 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at vstoll@doximity.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [https://contributor-covenant.org/version/1/4][version]

[homepage]: https://contributor-covenant.org
[version]: https://contributor-covenant.org/version/1/4/
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

source "https://rubygems.org"
gemspec

0 comments on commit e631820

Please sign in to comment.