From 5b35a75569c5aa37e9f26f46dda73ed0656f4cde Mon Sep 17 00:00:00 2001 From: Vladislav Trotsenko Date: Sun, 22 Jan 2023 14:39:18 +0100 Subject: [PATCH 1/3] Technical/Increase project code quality (#90) * Added new bunch of project linters * Added lefthook config, removed overcommit * Updated rubocop config * Updated circleci config * Fixed linters issues --- .circleci/config.yml | 54 ++++++++++++++----- .circleci/linter_configs/.bundler-audit.yml | 4 ++ .circleci/linter_configs/.cspell.yml | 31 +++++++++++ .circleci/linter_configs/.fasterer.yml | 4 ++ .circleci/linter_configs/.lefthook.yml | 34 ++++++++++++ .circleci/linter_configs/.markdownlint.yml | 9 ++++ .../linter_configs/.rubocop.yml | 24 +++++---- .circleci/linter_configs/.yamllint.yml | 7 +++ .codeclimate.yml | 2 + .github/BRANCH_NAMING_CONVENTION.md | 6 +-- .github/FUNDING.yml | 2 + .overcommit.yml | 39 -------------- .reek.yml | 2 + CHANGELOG.md | 52 +++++++++--------- CONTRIBUTING.md | 2 +- Gemfile | 1 - Gemfile.lock | 7 --- README.md | 12 +++-- 18 files changed, 185 insertions(+), 107 deletions(-) create mode 100644 .circleci/linter_configs/.bundler-audit.yml create mode 100644 .circleci/linter_configs/.cspell.yml create mode 100644 .circleci/linter_configs/.fasterer.yml create mode 100644 .circleci/linter_configs/.lefthook.yml create mode 100644 .circleci/linter_configs/.markdownlint.yml rename .rubocop.yml => .circleci/linter_configs/.rubocop.yml (86%) create mode 100644 .circleci/linter_configs/.yamllint.yml delete mode 100644 .overcommit.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 768ef07..ee73ada 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,31 +1,48 @@ +--- + +version: 2.1 + defaults: &defaults working_directory: ~/truemail-server docker: - - image: cimg/ruby:3.2.0 + - image: cimg/ruby:3.2.0-node references: install_bundler: &install_bundler run: name: Installing bundler - command: gem i bundler -v $(tail -1 Gemfile.lock | tr -d ' ') + command: | + gem i bundler -v $(tail -1 Gemfile.lock | tr -d ' ') + bundle config set --local path '~/vendor/bundle' restore_bundle_cache: &restore_bundle_cache restore_cache: keys: - - truemail-server-{{ checksum "Gemfile" }} + - truemail-server-{{ checksum "Gemfile.lock" }} + paths: + - ~/vendor/bundle bundle_install: &bundle_install run: name: Installing gems - command: | - bundle config set --local path 'vendor/bundle' - bundle install + command: bundle install save_bundle_cache: &save_bundle_cache save_cache: - key: truemail-server-{{ checksum "Gemfile" }} + key: truemail-server-{{ checksum "Gemfile.lock" }} paths: - - vendor/bundle + - ~/vendor/bundle + + install_linters: &install_linters + run: + name: Installing bunch of linters + command: | + curl -1sLf 'https://dl.cloudsmith.io/public/evilmartians/lefthook/setup.deb.sh' | sudo -E bash + sudo apt-get update -y + sudo apt-get install -y lefthook shellcheck yamllint + npm install --prefix='~/.local' --global --save-dev git+https://github.com/streetsidesoftware/cspell-cli markdownlint-cli + cp .circleci/linter_configs/.fasterer.yml .fasterer.yml + cp .circleci/linter_configs/.lefthook.yml lefthook.yml install_codeclimate_reporter: &install_codeclimate_reporter run: @@ -34,7 +51,6 @@ references: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter chmod +x ./cc-test-reporter -version: 2 jobs: linters: <<: *defaults @@ -46,12 +62,23 @@ jobs: - <<: *restore_bundle_cache - <<: *bundle_install - <<: *save_bundle_cache + - <<: *install_linters - run: - name: Running Overcommit - command: | - bundle exec overcommit -s - SKIP=AuthorEmail,AuthorName bundle exec overcommit -r + name: Running code style linters + command: lefthook run code-style-linters + + - run: + name: Running code performance linters + command: lefthook run code-performance-linters + + - run: + name: Running code vulnerability linters + command: lefthook run code-vulnerability-linters + + - run: + name: Running code documentation linters + command: lefthook run code-documentation-linters tests: <<: *defaults @@ -87,7 +114,6 @@ jobs: ./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input - workflows: - version: 2 build: jobs: - linters diff --git a/.circleci/linter_configs/.bundler-audit.yml b/.circleci/linter_configs/.bundler-audit.yml new file mode 100644 index 0000000..46f2b05 --- /dev/null +++ b/.circleci/linter_configs/.bundler-audit.yml @@ -0,0 +1,4 @@ +--- + +ignore: + - EXA-MPLE-XXXX diff --git a/.circleci/linter_configs/.cspell.yml b/.circleci/linter_configs/.cspell.yml new file mode 100644 index 0000000..cd454b1 --- /dev/null +++ b/.circleci/linter_configs/.cspell.yml @@ -0,0 +1,31 @@ +--- + +enableGlobDot: true + +patterns: + - name: GithubUser + pattern: /\[@.+\]/gmx + - name: MarkdownCode + pattern: /`{1,3}.+`{1,3}/gmx + - name: MarkdownCodeBlock + pattern: /^\s*```[\s\S]*?^\s*```/gmx + +languageSettings: + - languageId: markdown + ignoreRegExpList: + - Email + - GithubUser + - MarkdownCode + - MarkdownCodeBlock + +words: + - Commiting + - Gitter + - Healthcheck + - Trotsenko + - Truemail + - Vladislav + - bestwebua + - codebases + - dockerized + - nameserver's diff --git a/.circleci/linter_configs/.fasterer.yml b/.circleci/linter_configs/.fasterer.yml new file mode 100644 index 0000000..8c1976b --- /dev/null +++ b/.circleci/linter_configs/.fasterer.yml @@ -0,0 +1,4 @@ +--- + +exclude_paths: + - '.circleci/**/*.rb' diff --git a/.circleci/linter_configs/.lefthook.yml b/.circleci/linter_configs/.lefthook.yml new file mode 100644 index 0000000..ff36770 --- /dev/null +++ b/.circleci/linter_configs/.lefthook.yml @@ -0,0 +1,34 @@ +--- + +no_tty: true +skip_output: + - meta + +code-style-linters: + commands: + reek: + run: bundle exec reek + rubocop: + run: bundle exec rubocop -c '.circleci/linter_configs/.rubocop.yml' + shellcheck: + glob: '*.{sh}' + run: shellcheck --norc {all_files} + yamllint: + run: yamllint -c '.circleci/linter_configs/.yamllint.yml' . + +code-performance-linters: + commands: + fasterer: + run: bundle exec fasterer + +code-vulnerability-linters: + commands: + bundle-audit: + run: bundle exec bundle-audit check -c '.circleci/linter_configs/.bundler-audit.yml' --update + +code-documentation-linters: + commands: + cspell: + run: cspell-cli lint -c '.circleci/linter_configs/.cspell.yml' '**/*.{txt,md}' + markdownlint: + run: markdownlint -c '.circleci/linter_configs/.markdownlint.yml' '**/*.md' diff --git a/.circleci/linter_configs/.markdownlint.yml b/.circleci/linter_configs/.markdownlint.yml new file mode 100644 index 0000000..065b285 --- /dev/null +++ b/.circleci/linter_configs/.markdownlint.yml @@ -0,0 +1,9 @@ +--- + +default: true + +MD013: + line_length: 500 + +MD024: + siblings_only: true diff --git a/.rubocop.yml b/.circleci/linter_configs/.rubocop.yml similarity index 86% rename from .rubocop.yml rename to .circleci/linter_configs/.rubocop.yml index f0f511e..46f0d22 100644 --- a/.rubocop.yml +++ b/.circleci/linter_configs/.rubocop.yml @@ -1,12 +1,14 @@ +--- + require: - rubocop-rspec - rubocop-performance AllCops: - DisplayCopNames: true - DisplayStyleGuide: true - TargetRubyVersion: 3.1 + DisplayCopNames: true + DisplayStyleGuide: true + TargetRubyVersion: 3.2 NewCops: enable # Style ----------------------------------------------------------------------- @@ -65,14 +67,14 @@ Layout/ClassStructure: - belongs_to - has_and_belongs_to_many ExpectedOrder: - - module_inclusion - - constants - - associations - - public_class_methods - - initializer - - public_methods - - protected_methods - - private_methods + - module_inclusion + - constants + - associations + - public_class_methods + - initializer + - public_methods + - protected_methods + - private_methods # Lint ------------------------------------------------------------------------ diff --git a/.circleci/linter_configs/.yamllint.yml b/.circleci/linter_configs/.yamllint.yml new file mode 100644 index 0000000..10a4ecf --- /dev/null +++ b/.circleci/linter_configs/.yamllint.yml @@ -0,0 +1,7 @@ +--- + +extends: default + +rules: + line-length: + max: 200 diff --git a/.codeclimate.yml b/.codeclimate.yml index f03540e..894ab37 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,3 +1,5 @@ +--- + checks: argument-count: enabled: false diff --git a/.github/BRANCH_NAMING_CONVENTION.md b/.github/BRANCH_NAMING_CONVENTION.md index 1eacce6..f16f264 100644 --- a/.github/BRANCH_NAMING_CONVENTION.md +++ b/.github/BRANCH_NAMING_CONVENTION.md @@ -16,7 +16,7 @@ bugfix/fix-some-bug-name ### Squash commits -Please squash all branch commits into the one before openning your PR from your fork. It's simple to do with the git: +Please squash all branch commits into the one before opening your PR from your fork. It's simple to do with the git: ```bash git rebase -i [hash your first commit of your branch]~1 @@ -25,9 +25,9 @@ git rebase -i 6467fe36232401fa740af067cfd8ac9ec932fed2~1 # example ### Add commit description -Please complete your commit description folowing next pattern: +Please complete your commit description following next pattern: -``` +```code Technical/Add info files # should be the same name as your branch name * Added license, changelog, contributing, code of conduct docs diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index ae2d9cf..0844874 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,3 @@ +--- + github: [bestwebua] diff --git a/.overcommit.yml b/.overcommit.yml deleted file mode 100644 index 004214e..0000000 --- a/.overcommit.yml +++ /dev/null @@ -1,39 +0,0 @@ -PreCommit: - AuthorEmail: - enabled: true - required: false - - AuthorName: - enabled: false - - BundleAudit: - enabled: true - - Fasterer: - enabled: true - include: '**/*.rb' - - TrailingWhitespace: - enabled: true - - Reek: - enabled: true - flags: ['--force-exclusion'] - - RuboCop: - enabled: true - flags: ['--format=emacs', '--force-exclusion', '--display-cop-names'] - include: - - '**/*.gemspec' - - '**/*.rake' - - '**/*.rb' - - '**/*.ru' - - '**/Gemfile' - - '**/Rakefile' - -PostCheckout: - ALL: - quiet: true - - IndexTags: - enabled: true diff --git a/.reek.yml b/.reek.yml index b634eed..1489fc2 100644 --- a/.reek.yml +++ b/.reek.yml @@ -1,3 +1,5 @@ +--- + detectors: IrresponsibleModule: enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index a010ab3..89358f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (rack 2.2.6.2, truemail 3.0.5) +- Updated application dependencies (`rack` 2.2.6.2, `truemail` 3.0.5) - Updated Ruby version to 3.2.0 - Updated development dependencies - Updated application version @@ -24,7 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 3.0.1) +- Updated application dependencies (`truemail` 3.0.1) - Updated development dependencies - Updated application codebase, tests - Updated application docs, version @@ -33,7 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (rack 2.2.4, truemail 2.7.5) +- Updated application dependencies (`rack` 2.2.4, `truemail` 2.7.5) - Updated development dependencies - Updated application version @@ -45,7 +45,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (rack 2.2.3.1, truemail 2.7.3) +- Updated application dependencies (`rack` 2.2.3.1, `truemail` 2.7.3) - Updated Ruby version to 3.1.2 - Updated development dependencies - Updated application version @@ -61,7 +61,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Updated `System::CommandLineParams` - Updated `System::Configuration::COMMAND_LINE_ATTRS` -- Updated application dependencies (truemail 2.7.1) +- Updated application dependencies (`truemail` 2.7.1) - Updated Ruby version to 3.1.1 - Updated development dependencies - Updated application version @@ -70,7 +70,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.6) +- Updated application dependencies (`truemail` 2.6) - Updated Ruby version to 3.1.0 - Updated development dependencies - Updated application version @@ -84,7 +84,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Updated - Updated development dependencies -- Updated rubocop/codeclimate config +- Updated `rubocop`/`codeclimate` config - Updated application version - Updated documentation @@ -92,7 +92,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.5.4) +- Updated application dependencies (`truemail` 2.5.4) - Updated development dependencies - Updated application version @@ -100,7 +100,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.5.3) +- Updated application dependencies (`truemail` 2.5.3) - Updated development dependencies - Updated application version @@ -108,7 +108,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.5.2) +- Updated application dependencies (`truemail` 2.5.2) - Updated development dependencies - Updated application version @@ -116,7 +116,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.5.1) +- Updated application dependencies (`truemail` 2.5.1) - Updated development dependencies - Updated application version @@ -124,7 +124,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.4.6) +- Updated application dependencies (`truemail` 2.4.6) - Updated development dependencies - Updated application version @@ -132,7 +132,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.4.4) +- Updated application dependencies (`truemail` 2.4.4) - Updated development dependencies - Updated application version @@ -140,7 +140,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.4.2) +- Updated application dependencies (`truemail` 2.4.2) - Updated development dependencies - Updated application version - Updated CircleCI config @@ -155,14 +155,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Updated `System::Configuration::COMMAND_LINE_ATTRS` - Updated `Truemail` to latest version (2.4.1) - Updated runtime/development dependencies -- Updated rubocop/codeclimate configs +- Updated `rubocop`/`codeclimate` configs - Updated application readme, version, changelog ## [0.2.11] - 2021-03-24 ### Changed -- Updated application dependencies (truemail 2.3.2) +- Updated application dependencies (`truemail` 2.3.2) - Updated development dependencies - Updated application version @@ -174,7 +174,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.3.0) +- Updated application dependencies (`truemail` 2.3.0) - Updated development dependencies - Updated application version @@ -182,7 +182,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.2.3) +- Updated application dependencies (`truemail` 2.2.3) - Updated Ruby version to 2.6.6 - Updated application version @@ -200,23 +200,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies (truemail 2.2.1) -- Updated develoment dependencies +- Updated application dependencies (`truemail` 2.2.1) +- Updated development dependencies - Updated application version ## [0.2.6] - 2020-11-25 ### Changed -- Updated application dependencies (truemail 2.1.0) -- Updated develoment dependencies +- Updated application dependencies (`truemail` 2.1.0) +- Updated development dependencies - Updated application version ## [0.2.5] - 2020-10-23 ### Changed -- Updated application dependencies (truemail 2.0.1) +- Updated application dependencies (`truemail` 2.0.1) - Updated application version ## [0.2.4] - 2020-08-06 @@ -234,7 +234,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed -- Updated application dependencies, fixed Rack security vulnerability +- Updated application dependencies, fixed `rack` security vulnerability - Updated application version ## [0.2.2] - 2020-05-10 @@ -255,7 +255,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Updated application dependencies - Updated application documentation -- Updated rubocop config +- Updated `rubocop` config - Updated application version ## [0.2.0] - 2020-02-26 @@ -273,4 +273,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Added -- Basic functionality of Truemail server +- Basic functionality of `truemail` server diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2299203..8244923 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,7 +22,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform ## Feature requests -Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible. +Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to _you_ to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible. ## Questions diff --git a/Gemfile b/Gemfile index 99da459..84169e0 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,6 @@ group :development, :test do # Code quality gem 'bundler-audit', '~> 0.9.1', require: false gem 'fasterer', '~> 0.10.0', require: false - gem 'overcommit', '~> 0.59.1', require: false gem 'reek', '~> 6.1', '>= 6.1.4', require: false gem 'rubocop', '~> 1.43', require: false gem 'rubocop-performance', '~> 1.15', '>= 1.15.2', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 741853b..a6d5717 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,6 @@ GEM bundler (>= 1.2.0, < 3) thor (~> 1.0) byebug (11.1.3) - childprocess (4.1.0) coderay (1.1.3) colorize (0.8.1) concurrent-ruby (1.1.10) @@ -37,7 +36,6 @@ GEM colorize (~> 0.7) ruby_parser (>= 3.19.1) ice_nine (0.11.2) - iniparse (1.5.0) json (2.6.3) json_matchers (0.11.1) json_schema @@ -48,10 +46,6 @@ GEM timeout net-smtp (0.3.3) net-protocol - overcommit (0.59.1) - childprocess (>= 0.6.3, < 5) - iniparse (~> 1.4) - rexml (~> 3.2) parallel (1.22.1) parser (3.2.0.0) ast (~> 2.4.1) @@ -139,7 +133,6 @@ DEPENDENCIES fasterer (~> 0.10.0) json_matchers (~> 0.11.1) net-smtp (~> 0.3.3) - overcommit (~> 0.59.1) pry-byebug (~> 3.10, >= 3.10.1) rack (~> 2.2, >= 2.2.6.2) rack-test (~> 2.0, >= 2.0.2) diff --git a/README.md b/README.md index 7ca669b..2553911 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,9 @@ ## Installation - $ git clone https://github.com/truemail-rb/truemail-rack.git +```bash +git clone https://github.com/truemail-rb/truemail-rack.git +``` ## Usage @@ -65,9 +67,9 @@ Before run application you must configure it first. List of available env vars n | `WHITELIST_VALIDATION` | `true` | - | With this option Truemail will validate email which [contains whitelisted domain only](https://truemail-rb.org/truemail-gem/#/validations-layers?id=whitelist-validation-case), i.e. if domain whitelisted, validation will passed to Regex, MX or SMTP validators. Validation of email which not contains whitelisted domain always will return `false`. It is equal `false` by default. | | `BLACKLISTED_MX_IP_ADDRESSES` | `127.0.1.1,127.0.1.2` | - | With this option Truemail will filter out unwanted mx servers via predefined list of ip addresses. It can be used as a part of DEA (disposable email address) validations. Accepts one ore more values separated by commas. | `DNS` | `8.8.8.8,8.8.4.4:53` | - | This option will provide to use custom DNS gateway when Truemail interacts with DNS. If you won't specify nameserver's ports Truemail will use default DNS TCP/UDP port 53. Accepts one ore more values separated by commas. By default Truemail uses DNS gateway from system settings. -| `NOT_RFC_MX_LOOKUP_FLOW` | `true` | - | This option will provide to use not RFC MX lookup flow. It means that MX and Null MX records will be cheked on the DNS validation layer only. By default [this option is disabled](https://truemail-rb.org/truemail-gem/#/validations-layers?id=not-rfc-mx-lookup-flow). | +| `NOT_RFC_MX_LOOKUP_FLOW` | `true` | - | This option will provide to use not RFC MX lookup flow. It means that MX and Null MX records will be checked on the DNS validation layer only. By default [this option is disabled](https://truemail-rb.org/truemail-gem/#/validations-layers?id=not-rfc-mx-lookup-flow). | | `SMTP_PORT` | `2525` | - | SMTP port number. It is equal to `25` by default. | -| `SMTP_FAIL_FAST` | `true` | - | This option will provide to use SMTP fail fast behaviour. When [smtp_fail_fast is enabled](https://truemail-rb.org/truemail-gem/#/validations-layers?id=smtp-fail-fast-enabled) it means that Truemail ends smtp validation session after first attempt on the first mx server in any fail cases (network connection/timeout error, smtp validation error). By default this option is disabled, available for SMTP validation only. | +| `SMTP_FAIL_FAST` | `true` | - | This option will provide to use SMTP fail fast behavior. When [smtp_fail_fast is enabled](https://truemail-rb.org/truemail-gem/#/validations-layers?id=smtp-fail-fast-enabled) it means that Truemail ends smtp validation session after first attempt on the first mx server in any fail cases (network connection/timeout error, smtp validation error). By default this option is disabled, available for SMTP validation only. | | `SMTP_SAFE_CHECK` | `true` | - | This option will be parse bodies of SMTP errors. It will be helpful if SMTP server does not return an exact answer that the email does not exist. By default [this option is disabled](https://truemail-rb.org/truemail-gem/#/validations-layers?id=smtp-safe-check-disabled), available for SMTP validation only. | | `LOG_STDOUT` | `true` | - | This option will be enable log all http requests to stdout. By default this option is disabled. | @@ -238,7 +240,7 @@ Server: thin ## Truemail family -All Truemail solutions: https://truemail-rb.org +All Truemail solutions: | Name | Type | Description | | --- | --- | --- | @@ -252,7 +254,7 @@ All Truemail solutions: https://truemail-rb.org ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/truemail-rb/truemail-rack. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. Please check the [open tickets](https://github.com/truemail-rb/truemail-rack/issues). Be sure to follow Contributor Code of Conduct below and our [Contributing Guidelines](CONTRIBUTING.md). +Bug reports and pull requests are welcome on GitHub at . This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. Please check the [open tickets](https://github.com/truemail-rb/truemail-rack/issues). Be sure to follow Contributor Code of Conduct below and our [Contributing Guidelines](CONTRIBUTING.md). ## License From 02070ba615e448cfae320a04519079feaea668bb Mon Sep 17 00:00:00 2001 From: Vladislav Trotsenko Date: Sun, 22 Jan 2023 15:56:24 +0100 Subject: [PATCH 2/3] Technical/Add changelog linter (#91) * Added changeloglint script * Updated lefthook config * Updated circleci config --- .circleci/config.yml | 4 ++++ .circleci/linter_configs/.lefthook.yml | 5 +++++ .circleci/scripts/changeloglint.sh | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100755 .circleci/scripts/changeloglint.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index ee73ada..464ef7b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -80,6 +80,10 @@ jobs: name: Running code documentation linters command: lefthook run code-documentation-linters + - run: + name: Running release linters + command: lefthook run release-linters + tests: <<: *defaults diff --git a/.circleci/linter_configs/.lefthook.yml b/.circleci/linter_configs/.lefthook.yml index ff36770..05407a5 100644 --- a/.circleci/linter_configs/.lefthook.yml +++ b/.circleci/linter_configs/.lefthook.yml @@ -32,3 +32,8 @@ code-documentation-linters: run: cspell-cli lint -c '.circleci/linter_configs/.cspell.yml' '**/*.{txt,md}' markdownlint: run: markdownlint -c '.circleci/linter_configs/.markdownlint.yml' '**/*.md' + +release-linters: + commands: + changeloglint: + run: .circleci/scripts/changeloglint.sh diff --git a/.circleci/scripts/changeloglint.sh b/.circleci/scripts/changeloglint.sh new file mode 100755 index 0000000..d3140bb --- /dev/null +++ b/.circleci/scripts/changeloglint.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -e + +changelog=$(if [ "$1" = "" ]; then echo "CHANGELOG.md"; else echo "$1"; fi) + +get_current_application_version() { + ruby -r rubygems -e "require_relative 'app/truemail_server/version'; puts TruemailServer::VERSION" +} + +latest_changelog_tag() { + grep -Po "(?<=\#\# \[)[0-9]+\.[0-9]+\.[0-9]+?(?=\])" "$changelog" | head -n 1 +} + +current_application_version="$(get_current_application_version)" + +if [ "$current_application_version" = "$(latest_changelog_tag)" ] +then + echo "SUCCESS: Current application version ($current_application_version) has been found on the top of project changelog." +else + echo "FAILURE: Following to \"Keep a Changelog\" convention current application version ($current_application_version) must be mentioned on the top of project changelog." + exit 1 +fi From f621d3902d148b93b3479070f5213b9ef90f2d96 Mon Sep 17 00:00:00 2001 From: Vladislav Trotsenko Date: Sat, 11 Mar 2023 21:30:29 +0100 Subject: [PATCH 3/3] Technical/Add autoreleasing (#93) * Fixed security vulnerability issue CVE-2023-27530 * Added bunch of linters, configs * Added auto creating release notes on GitHub * Added auto releasing scripts * Updated runtime/development dependencies * Updated CircleCI/CodeClimate configs * Updated application version, changelog --- .circleci/config.yml | 43 ++++++++++++++++++++++++++ .circleci/scripts/release.sh | 42 +++++++++++++++++++++++++ .circleci/scripts/tag.sh | 30 ++++++++++++++++++ .codeclimate.yml | 2 +- CHANGELOG.md | 24 +++++++++++++++ Gemfile | 10 +++--- Gemfile.lock | 56 +++++++++++++++++----------------- app/truemail_server/version.rb | 2 +- 8 files changed, 174 insertions(+), 35 deletions(-) create mode 100755 .circleci/scripts/release.sh create mode 100755 .circleci/scripts/tag.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 464ef7b..79a2f8f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -117,8 +117,51 @@ jobs: command: | ./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input - + tag: + <<: *defaults + + steps: + - checkout + + - add_ssh_keys: + fingerprints: + - "4c:59:4d:fb:7a:74:00:7a:8e:e3:72:88:34:fc:6e:74" + + - run: + name: Publishing new tag to GitHub + command: | + ./.circleci/scripts/tag.sh + + release: + <<: *defaults + + steps: + - checkout + + - add_ssh_keys: + fingerprints: + - "4c:59:4d:fb:7a:74:00:7a:8e:e3:72:88:34:fc:6e:74" + + - run: + name: Publishing new release to GitHub + command: | + ./.circleci/scripts/release.sh + workflows: build: jobs: - linters - tests + - tag: + requires: + - linters + - tests + filters: + branches: + only: master + - release: + filters: + branches: + ignore: /.*/ + tags: + only: /v[0-9]+(\.[0-9]+)*(-.*)*/ diff --git a/.circleci/scripts/release.sh b/.circleci/scripts/release.sh new file mode 100755 index 0000000..3681ac3 --- /dev/null +++ b/.circleci/scripts/release.sh @@ -0,0 +1,42 @@ +#!/bin/sh +set -e + +GH_CLI_RELEASES_URL="https://github.com/cli/cli/releases" +FILE_NAME="gh" +BUILD_ARCHITECTURE="linux_amd64.deb" +DELIMETER="_" +PACKAGE_FILE="$FILE_NAME$DELIMETER$BUILD_ARCHITECTURE" + +gh_cli_latest_release() { + curl -sL -o /dev/null -w '%{url_effective}' "$GH_CLI_RELEASES_URL/latest" | rev | cut -f 1 -d '/'| rev +} + +download_gh_cli() { + test -z "$VERSION" && VERSION="$(gh_cli_latest_release)" + test -z "$VERSION" && { + echo "Unable to get GitHub CLI release." >&2 + exit 1 + } + curl -s -L -o "$PACKAGE_FILE" "$GH_CLI_RELEASES_URL/download/$VERSION/$FILE_NAME$DELIMETER$(printf '%s' "$VERSION" | cut -c 2-100)$DELIMETER$BUILD_ARCHITECTURE" +} + +install_gh_cli() { + sudo dpkg -i "$PACKAGE_FILE" + rm "$PACKAGE_FILE" +} + +get_release_candidate_tag() { + git tag --sort=v:refname | grep -E "v[0-9]+\.[0-9]+\.[0-9]+" | tail -n 1 +} + +RELEASE_CANDIDATE_TAG=$(get_release_candidate_tag) + +release_to_github() { + echo "Downloading and installing latest gh cli..." + download_gh_cli + install_gh_cli + echo "Publishing new release notes to GitHub..." + gh release create "$RELEASE_CANDIDATE_TAG" --generate-notes +} + +release_to_github diff --git a/.circleci/scripts/tag.sh b/.circleci/scripts/tag.sh new file mode 100755 index 0000000..0ecf0a4 --- /dev/null +++ b/.circleci/scripts/tag.sh @@ -0,0 +1,30 @@ +#!/bin/sh +set -e + +SEMVER_REGEX_PATTERN="[0-9]+\.[0-9]+\.[0-9]+" + +latest_changelog_tag() { + grep -Po "(?<=\#\# \[)$SEMVER_REGEX_PATTERN?(?=\])" CHANGELOG.md | head -n 1 +} + +latest_git_tag() { + git tag --sort=v:refname | grep -E "v$SEMVER_REGEX_PATTERN" | tail -n 1 +} + +TAG_CANDIDATE="v$(latest_changelog_tag)" + +if [ "$TAG_CANDIDATE" != "$(latest_git_tag)" ] +then + echo "Configuring git..." + git config --global user.email "${PUBLISHER_EMAIL}" + git config --global user.name "${PUBLISHER_NAME}" + echo "Pushing new semver tag to GitHub..." + git tag "$TAG_CANDIDATE" + git push --tags + echo "Updating develop branch with new semver tag..." + git checkout develop + git merge "$TAG_CANDIDATE" --ff --no-edit + git push origin develop +else + echo "Latest changelog tag ($TAG_CANDIDATE) already released on GitHub. Tagging is not required." +fi diff --git a/.codeclimate.yml b/.codeclimate.yml index 894ab37..177f2d7 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -9,7 +9,7 @@ checks: plugins: rubocop: enabled: true - channel: rubocop-1-43 + channel: rubocop-1-48 reek: enabled: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 89358f3..c1cb3fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,30 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.7.0] - 2023-03-11 + +### Added + +- Added [`cspell`](https://cspell.org) linter +- Added [`markdownlint`](https://github.com/DavidAnson/markdownlint) linter +- Added [`shellcheck`](https://www.shellcheck.net) linter +- Added [`yamllint`](https://yamllint.readthedocs.io) linter +- Added [`lefthook`](https://github.com/evilmartians/lefthook) linters aggregator +- Added `changeloglint` +- Added auto creating release notes on GitHub +- Added auto releasing scripts + +### Fixed + +- Fixed security vulnerability issue [CVE-2023-27530](https://github.com/advisories/GHSA-3h57-hmj3-gj3p) + +### Changed + +- Updated application dependencies (`rack` 2.2.6.3, `truemail` 3.0.7) +- Updated development dependencies +- Updated application version +- Updated readme + ## [0.6.0] - 2023-01-20 ### Fixed diff --git a/Gemfile b/Gemfile index 84169e0..dc82d2d 100644 --- a/Gemfile +++ b/Gemfile @@ -6,9 +6,9 @@ ruby(::File.read(::File.join(::File.dirname(__FILE__), '.ruby-version')).strip[/ gem 'dry-struct', '~> 1.6' gem 'net-smtp', '~> 0.3.3' -gem 'rack', '~> 2.2', '>= 2.2.6.2' +gem 'rack', '~> 2.2', '>= 2.2.6.3' gem 'thin', '~> 1.8', '>= 1.8.1' -gem 'truemail', '~> 3.0', '>= 3.0.5' +gem 'truemail', '~> 3.0', '>= 3.0.7' group :development, :test do gem 'pry-byebug', '~> 3.10', '>= 3.10.1' @@ -19,9 +19,9 @@ group :development, :test do gem 'bundler-audit', '~> 0.9.1', require: false gem 'fasterer', '~> 0.10.0', require: false gem 'reek', '~> 6.1', '>= 6.1.4', require: false - gem 'rubocop', '~> 1.43', require: false - gem 'rubocop-performance', '~> 1.15', '>= 1.15.2', require: false - gem 'rubocop-rspec', '~> 2.18', '>= 2.18.1', require: false + gem 'rubocop', '~> 1.48', require: false + gem 'rubocop-performance', '~> 1.16', require: false + gem 'rubocop-rspec', '~> 2.19', require: false end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index a6d5717..fe75bac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,7 @@ GEM byebug (11.1.3) coderay (1.1.3) colorize (0.8.1) - concurrent-ruby (1.1.10) + concurrent-ruby (1.2.2) daemons (1.4.1) diff-lcs (1.5.0) docile (1.4.0) @@ -25,11 +25,11 @@ GEM dry-types (>= 1.7, < 2) ice_nine (~> 0.11) zeitwerk (~> 2.6) - dry-types (1.7.0) + dry-types (1.7.1) concurrent-ruby (~> 1.0) - dry-core (~> 1.0, < 2) - dry-inflector (~> 1.0, < 2) - dry-logic (>= 1.4, < 2) + dry-core (~> 1.0) + dry-inflector (~> 1.0) + dry-logic (~> 1.4) zeitwerk (~> 2.6) eventmachine (1.2.7) fasterer (0.10.0) @@ -47,7 +47,7 @@ GEM net-smtp (0.3.3) net-protocol parallel (1.22.1) - parser (3.2.0.0) + parser (3.2.1.1) ast (~> 2.4.1) pry (0.14.2) coderay (~> 1.1) @@ -55,7 +55,7 @@ GEM pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) - rack (2.2.6.2) + rack (2.2.6.3) rack-test (2.0.2) rack (>= 1.3) rainbow (3.1.1) @@ -63,13 +63,13 @@ GEM kwalify (~> 0.7.0) parser (~> 3.2.0) rainbow (>= 2.0, < 4.0) - regexp_parser (2.6.2) + regexp_parser (2.7.0) rexml (3.2.5) rspec (3.12.0) rspec-core (~> 3.12.0) rspec-expectations (~> 3.12.0) rspec-mocks (~> 3.12.0) - rspec-core (3.12.0) + rspec-core (3.12.1) rspec-support (~> 3.12.0) rspec-expectations (3.12.2) diff-lcs (>= 1.2.0, < 2.0) @@ -78,28 +78,28 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.0) - rubocop (1.43.0) + rubocop (1.48.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.24.1, < 2.0) + rubocop-ast (>= 1.26.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.24.1) - parser (>= 3.1.1.0) - rubocop-capybara (2.17.0) + rubocop-ast (1.27.0) + parser (>= 3.2.1.0) + rubocop-capybara (2.17.1) rubocop (~> 1.41) - rubocop-performance (1.15.2) + rubocop-performance (1.16.0) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rspec (2.18.1) + rubocop-rspec (2.19.0) rubocop (~> 1.33) rubocop-capybara (~> 2.17) - ruby-progressbar (1.11.0) - ruby_parser (3.19.2) + ruby-progressbar (1.13.0) + ruby_parser (3.20.0) sexp_processor (~> 4.16) sexp_processor (4.16.1) simplecov (0.22.0) @@ -115,17 +115,17 @@ GEM eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) thor (1.2.1) - timeout (0.3.1) - truemail (3.0.5) + timeout (0.3.2) + truemail (3.0.7) simpleidn (~> 0.2.1) unf (0.1.4) unf_ext unf_ext (0.0.8.2) unicode-display_width (2.4.2) - zeitwerk (2.6.6) + zeitwerk (2.6.7) PLATFORMS - x86_64-darwin-22 + arm64-darwin-22 DEPENDENCIES bundler-audit (~> 0.9.1) @@ -134,19 +134,19 @@ DEPENDENCIES json_matchers (~> 0.11.1) net-smtp (~> 0.3.3) pry-byebug (~> 3.10, >= 3.10.1) - rack (~> 2.2, >= 2.2.6.2) + rack (~> 2.2, >= 2.2.6.3) rack-test (~> 2.0, >= 2.0.2) reek (~> 6.1, >= 6.1.4) rspec (~> 3.12) - rubocop (~> 1.43) - rubocop-performance (~> 1.15, >= 1.15.2) - rubocop-rspec (~> 2.18, >= 2.18.1) + rubocop (~> 1.48) + rubocop-performance (~> 1.16) + rubocop-rspec (~> 2.19) simplecov (~> 0.22.0) thin (~> 1.8, >= 1.8.1) - truemail (~> 3.0, >= 3.0.5) + truemail (~> 3.0, >= 3.0.7) RUBY VERSION ruby 3.2.0p0 BUNDLED WITH - 2.4.4 + 2.4.6 diff --git a/app/truemail_server/version.rb b/app/truemail_server/version.rb index f06439b..0493fb4 100644 --- a/app/truemail_server/version.rb +++ b/app/truemail_server/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module TruemailServer - VERSION = '0.6.0' + VERSION = '0.7.0' end