Skip to content

Commit

Permalink
Merge pull request #45 from artichoke/rakefile-devtools
Browse files Browse the repository at this point in the history
Add Rakefile and devtools
  • Loading branch information
lopopolo committed Aug 6, 2021
2 parents 1f71779 + 7190688 commit 8605bb7
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: monthly
open-pull-requests-limit: 10
assignees:
- lopopolo
labels:
- A-deps
16 changes: 16 additions & 0 deletions .github/markdown-link-check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"ignorePatterns": [
{
"pattern": "img.shields.io"
}
],
"replacementPatterns": [],
"httpHeaders": [
{
"urls": ["https://crates.io"],
"headers": {
"Accept": "text/html"
}
}
]
}
16 changes: 16 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ jobs:
entrypoint: /bin/hadolint
args: --config /github/workspace/.hadolint.yaml /github/workspace/alpine/Dockerfile

ruby:
name: Lint and format Ruby
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Ruby toolchain
uses: ruby/setup-ruby@v1
with:
ruby-version: ".ruby-version"
bundler-cache: true

- name: Lint and check formatting with Rubocop
run: bundle exec rubocop --format github

text:
name: Lint and format text
runs-on: ubuntu-latest
Expand Down
20 changes: 20 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
require: rubocop-rake
AllCops:
NewCops: enable
TargetRubyVersion: 2.6
DisplayCopNames: true
Exclude:
- "**/node_modules/**/*"
- "**/target/**/*"
- "**/vendor/**/*"
Layout/EndOfLine:
EnforcedStyle: lf
Layout/LineLength:
Enabled: true
Exclude:
- "**/Rakefile"
Metrics:
Enabled: false
Style/Documentation:
Enabled: false
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.2
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'rake', '>= 12.3.3', require: false
gem 'rubocop', '~> 1.18', require: false
gem 'rubocop-rake', '~> 0.6', require: false
37 changes: 37 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
parallel (1.20.1)
parser (3.0.2.0)
ast (~> 2.4.1)
rainbow (3.0.0)
rake (13.0.6)
regexp_parser (2.1.1)
rexml (3.2.5)
rubocop (1.18.4)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.8.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.8.0)
parser (>= 3.0.1.1)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
ruby-progressbar (1.11.0)
unicode-display_width (2.0.0)

PLATFORMS
ruby

DEPENDENCIES
rake (>= 12.3.3)
rubocop (~> 1.18)
rubocop-rake (~> 0.6)

BUNDLED WITH
2.0.2
53 changes: 53 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

require 'open-uri'
require 'shellwords'
require 'rubocop/rake_task'

task default: %i[format lint]

desc 'Lint sources'
task lint: %i[lint:rubocop:auto_correct]

namespace :lint do
RuboCop::RakeTask.new(:rubocop)
end

desc 'Format sources'
task format: %i[format:text]

namespace :format do
desc 'Format text, YAML, and Markdown sources with prettier'
task :text do
sh 'npx prettier --write "**/*"'
end
end

desc 'Format sources'
task fmt: %i[fmt:text]

namespace :fmt do
desc 'Format text, YAML, and Markdown sources with prettier'
task :text do
sh 'npx prettier --write "**/*"'
end
end

namespace :release do
link_check_files = FileList.new('**/*.md') do |f|
f.exclude('node_modules/**/*')
f.exclude('**/target/**/*')
f.exclude('**/vendor/**/*')
f.include('*.md')
f.include('**/vendor/*.md')
end

link_check_files.sort.uniq.each do |markdown|
desc 'Check for broken links in markdown files'
task markdown_link_check: markdown do
command = ['npx', 'markdown-link-check', '--config', '.github/markdown-link-check.json', markdown]
sh command.shelljoin
sleep(rand(1..5))
end
end
end

0 comments on commit 8605bb7

Please sign in to comment.