way_of_working 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +30 -0
- data/CODE_OF_CONDUCT.md +133 -0
- data/LICENSE.txt +22 -0
- data/README.md +101 -0
- data/exe/way_of_working +5 -0
- data/lib/tasks/audit_gems.rake +60 -0
- data/lib/way_of_working/cli.rb +125 -0
- data/lib/way_of_working/generators/changelog/init.rb +110 -0
- data/lib/way_of_working/generators/code_of_conduct/init.rb +32 -0
- data/lib/way_of_working/generators/decision_record/init.rb +29 -0
- data/lib/way_of_working/generators/decision_record/new.rb +67 -0
- data/lib/way_of_working/generators/linter/exec.rb +77 -0
- data/lib/way_of_working/generators/linter/init.rb +60 -0
- data/lib/way_of_working/generators/rake_tasks/init.rb +47 -0
- data/lib/way_of_working/git/repo_reader.rb +72 -0
- data/lib/way_of_working/git/summary_tag.rb +27 -0
- data/lib/way_of_working/paths.rb +16 -0
- data/lib/way_of_working/sub_command_base.rb +16 -0
- data/lib/way_of_working/tasks.rb +8 -0
- data/lib/way_of_working/templates/.github/linters/.markdown-link-check.json +13 -0
- data/lib/way_of_working/templates/.github/linters/rubocop_defaults.yml +55 -0
- data/lib/way_of_working/templates/.github/workflows/mega-linter.yml +82 -0
- data/lib/way_of_working/templates/.mega-linter.yml +129 -0
- data/lib/way_of_working/templates/.rubocop +1 -0
- data/lib/way_of_working/templates/CODE_OF_CONDUCT.md.tt +134 -0
- data/lib/way_of_working/templates/docs/decisions/README.md +7 -0
- data/lib/way_of_working/templates/docs/decisions/adr-template.md.tt +79 -0
- data/lib/way_of_working/version.rb +5 -0
- data/lib/way_of_working.rb +10 -0
- data/way_of_working.gemspec +43 -0
- metadata +121 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'way_of_working/paths'
|
5
|
+
|
6
|
+
module WayOfWorking
|
7
|
+
module Generators
|
8
|
+
module DecisionRecord
|
9
|
+
# This generator add a new MADR decision record to the doc/decisions folder
|
10
|
+
class New < Thor::Group
|
11
|
+
argument :name, type: :string, required: true, desc: 'The title of the decision record'
|
12
|
+
|
13
|
+
include Thor::Actions
|
14
|
+
|
15
|
+
source_root ::WayOfWorking.source_root
|
16
|
+
|
17
|
+
def create_decision_record_file
|
18
|
+
case behavior
|
19
|
+
when :invoke
|
20
|
+
invoke_decision_record_file
|
21
|
+
when :revoke
|
22
|
+
revoke_decision_record_file
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def invoke_decision_record_file
|
29
|
+
@decision_date = Date.today.strftime('%Y-%m-%d')
|
30
|
+
@title = name
|
31
|
+
|
32
|
+
# from https://raw.githubusercontent.com/adr/madr/3.0.0/template/adr-template.md
|
33
|
+
template 'docs/decisions/adr-template.md',
|
34
|
+
"docs/decisions/#{next_decision_number}-#{dashed_name}.md"
|
35
|
+
end
|
36
|
+
|
37
|
+
def revoke_decision_record_file
|
38
|
+
matching_files = Dir.glob("[0-9][0-9][0-9][0-9]-#{dashed_name}.md",
|
39
|
+
base: File.join(destination_root, 'docs/decisions'))
|
40
|
+
raise "No matching decision record for '#{dashed_name}'" if matching_files.empty?
|
41
|
+
|
42
|
+
# based on Thor's remove_file
|
43
|
+
path = File.expand_path("docs/decisions/#{matching_files.first}", destination_root)
|
44
|
+
|
45
|
+
say_status :remove, relative_to_original_destination_root(path)
|
46
|
+
return unless !options[:pretend] && (File.exist?(path) || File.symlink?(path))
|
47
|
+
|
48
|
+
require 'fileutils'
|
49
|
+
::FileUtils.rm_rf(path)
|
50
|
+
end
|
51
|
+
|
52
|
+
def next_decision_number
|
53
|
+
existing_decisions = Dir.glob('[0-9][0-9][0-9][0-9]-*.md',
|
54
|
+
base: File.join(destination_root, 'docs/decisions'))
|
55
|
+
last_number = existing_decisions.map do |filename|
|
56
|
+
filename.match(/\A(\d{4})-/)[1].to_i
|
57
|
+
end.max || -1
|
58
|
+
format('%04d', last_number + 1)
|
59
|
+
end
|
60
|
+
|
61
|
+
def dashed_name
|
62
|
+
name.downcase.gsub(/[\s_()]/, '-').gsub(/-+/, '-')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'rainbow'
|
5
|
+
|
6
|
+
module WayOfWorking
|
7
|
+
module Generators
|
8
|
+
module Linter
|
9
|
+
# This generator runs the linter
|
10
|
+
class Exec < Thor::Group
|
11
|
+
argument :path, type: :string, required: false, desc: 'Optional path of the file to lint'
|
12
|
+
|
13
|
+
desc 'This runs the linter on this project'
|
14
|
+
|
15
|
+
def run_first
|
16
|
+
@start_time = Time.now
|
17
|
+
|
18
|
+
say(Rainbow("Limiting linters to #{path}\n").yellow) if path
|
19
|
+
end
|
20
|
+
|
21
|
+
# Run RuboCop
|
22
|
+
def prep_and_run_rubocop
|
23
|
+
say(Rainbow('Running RuboCop...').yellow)
|
24
|
+
|
25
|
+
@rubocop_ok = run_rubocop(ARGV[2..])
|
26
|
+
end
|
27
|
+
|
28
|
+
# Run MegaLinter
|
29
|
+
def prep_and_run_megalinter
|
30
|
+
command = ['npx', 'mega-linter-runner', '--remove-container']
|
31
|
+
# Configure MegaLinter to only lint a specific file or folder, if defined
|
32
|
+
command.prepend("MEGALINTER_FILES_TO_LINT=\"#{path}\"") if path
|
33
|
+
# We only want reports created in the working directory
|
34
|
+
command.prepend('env', "GITHUB_WORKSPACE=\"#{Dir.pwd}\"")
|
35
|
+
|
36
|
+
say(Rainbow("\nRunning MegaLinter...").yellow)
|
37
|
+
|
38
|
+
@megalinter_ok = run_megalinter(command)
|
39
|
+
end
|
40
|
+
|
41
|
+
# We run this last to enable all the linters to run first
|
42
|
+
def run_last
|
43
|
+
say(Rainbow("\nTotal time taken: #{(Time.now - @start_time).to_i} seconds").yellow)
|
44
|
+
|
45
|
+
if !@rubocop_ok || !@megalinter_ok
|
46
|
+
abort(Rainbow("\nLinter failed!").red)
|
47
|
+
else
|
48
|
+
say(Rainbow("\nLinter Succeeded!").green)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def path_directory
|
55
|
+
return path if File.directory?(path)
|
56
|
+
|
57
|
+
File.dirname(path)
|
58
|
+
end
|
59
|
+
|
60
|
+
def run_rubocop(arguments)
|
61
|
+
# We lazy-load RuboCop so that the task doesn't dramatically impact the
|
62
|
+
# load time of our commands.
|
63
|
+
require 'rubocop'
|
64
|
+
|
65
|
+
cli = RuboCop::CLI.new
|
66
|
+
!cli.run(arguments).nonzero?
|
67
|
+
end
|
68
|
+
|
69
|
+
def run_megalinter(arguments)
|
70
|
+
arguments.prepend('time')
|
71
|
+
|
72
|
+
system(*arguments)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'way_of_working/paths'
|
5
|
+
|
6
|
+
module WayOfWorking
|
7
|
+
module Generators
|
8
|
+
module Linter
|
9
|
+
# This generator add the MADR files to the doc/decisions folder
|
10
|
+
class Init < Thor::Group
|
11
|
+
include Thor::Actions
|
12
|
+
|
13
|
+
source_root ::WayOfWorking.source_root
|
14
|
+
|
15
|
+
# TODO: copy_rubocop_github_workflow_action
|
16
|
+
|
17
|
+
def copy_github_linters_rubocop_config_file
|
18
|
+
copy_file '.github/linters/rubocop_defaults.yml'
|
19
|
+
end
|
20
|
+
|
21
|
+
def copy_github_linters_markdown_link_check_config_file
|
22
|
+
copy_file '.github/linters/.markdown-link-check.json'
|
23
|
+
end
|
24
|
+
|
25
|
+
def copy_megalinter_github_workflow_action
|
26
|
+
copy_file '.github/workflows/mega-linter.yml'
|
27
|
+
end
|
28
|
+
|
29
|
+
def copy_megalinter_dot_file
|
30
|
+
copy_file '.mega-linter.yml'
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_gitignore_if_missing
|
34
|
+
create_file_if_missing '.gitignore'
|
35
|
+
end
|
36
|
+
|
37
|
+
def gitignore_reports_folder
|
38
|
+
append_to_file '.gitignore', "megalinter-reports/\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
def gitignore_rubocop_cached_file
|
42
|
+
append_to_file '.gitignore', ".rubocop-https---*\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
def copy_rubocop_options_file
|
46
|
+
copy_file '.rubocop'
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def create_file_if_missing(path)
|
52
|
+
path = File.join(destination_root, path)
|
53
|
+
return if behavior == :revoke || File.exist?(path)
|
54
|
+
|
55
|
+
File.open(path, 'w', &:write)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WayOfWorking
|
4
|
+
module Generators
|
5
|
+
module RakeTasks
|
6
|
+
# This generator installs way of working rake tasks into this project
|
7
|
+
class Init < Thor::Group
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
RAKEFILE_FILENAME = 'Rakefile'
|
11
|
+
RAILS_LOC = %r{require_relative ["']config/application["']\n}.freeze
|
12
|
+
BUNDLER_LOC = %r{require ["']bundler/gem_tasks["']\n}.freeze
|
13
|
+
|
14
|
+
def add_to_rakefile
|
15
|
+
case rakefile_type
|
16
|
+
when :rails
|
17
|
+
inject_into_file RAKEFILE_FILENAME,
|
18
|
+
"require 'way_of_working/tasks' if Rails.env.development? " \
|
19
|
+
"|| Rails.env.test?\n",
|
20
|
+
after: RAILS_LOC
|
21
|
+
when :bundler
|
22
|
+
inject_into_file RAKEFILE_FILENAME,
|
23
|
+
"require 'way_of_working/tasks'\n",
|
24
|
+
after: BUNDLER_LOC
|
25
|
+
when :none
|
26
|
+
create_file RAKEFILE_FILENAME, "\nrequire 'way_of_working/tasks'\n"
|
27
|
+
else
|
28
|
+
append_to_file RAKEFILE_FILENAME, "\nrequire 'way_of_working/tasks'\n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def rakefile_type
|
35
|
+
content = File.read(File.expand_path(RAKEFILE_FILENAME, destination_root))
|
36
|
+
|
37
|
+
return :rails if content.match?(RAILS_LOC)
|
38
|
+
return :bundler if content.match?(BUNDLER_LOC)
|
39
|
+
|
40
|
+
:other
|
41
|
+
rescue Errno::ENOENT
|
42
|
+
:none
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'git'
|
4
|
+
require_relative 'summary_tag'
|
5
|
+
|
6
|
+
module WayOfWorking
|
7
|
+
module Git
|
8
|
+
# This class holds a summary of a git tag
|
9
|
+
class RepoReader
|
10
|
+
attr_reader :base
|
11
|
+
|
12
|
+
def initialize(base)
|
13
|
+
@base = base
|
14
|
+
end
|
15
|
+
|
16
|
+
def summary_tags
|
17
|
+
tags = @base.tags.map do |tag|
|
18
|
+
SummaryTag.new(tag.name, base.gcommit(tag.objectish).date)
|
19
|
+
end.sort
|
20
|
+
|
21
|
+
ensure_versions_are_valid_and_increasing!(tags)
|
22
|
+
capture_change_types(tags)
|
23
|
+
|
24
|
+
tags
|
25
|
+
end
|
26
|
+
|
27
|
+
def likely_upstream_remote_url
|
28
|
+
likely_upstream_remote&.url&.sub(/\.git\z/, '')
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def ensure_versions_are_valid_and_increasing!(tags)
|
34
|
+
previous_version = nil
|
35
|
+
tags.each do |tag|
|
36
|
+
next if tag.version.nil?
|
37
|
+
|
38
|
+
if previous_version && tag.version <= previous_version
|
39
|
+
raise 'Tag versions are not incremental over time'
|
40
|
+
end
|
41
|
+
|
42
|
+
previous_version = tag.version
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def capture_change_types(tags)
|
47
|
+
previous_version_segments = [-1, -1, -1]
|
48
|
+
tags.each do |tag|
|
49
|
+
tag.change_type = if tag.version.segments[0] > previous_version_segments[0]
|
50
|
+
:major
|
51
|
+
elsif tag.version.segments[1] > previous_version_segments[1]
|
52
|
+
:minor
|
53
|
+
else
|
54
|
+
:patch
|
55
|
+
end
|
56
|
+
|
57
|
+
previous_version_segments = tag.version.segments
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def likely_upstream_remote
|
62
|
+
remotes = @base.remotes
|
63
|
+
return remotes.first if remotes.count == 1
|
64
|
+
|
65
|
+
remotes = remotes.reject { |remote| remote.name == 'origin' }
|
66
|
+
return remotes.first if remotes.count == 1
|
67
|
+
|
68
|
+
remotes.last
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'git'
|
4
|
+
|
5
|
+
module WayOfWorking
|
6
|
+
module Git
|
7
|
+
# This convenience class holds a summary of a git tag
|
8
|
+
class SummaryTag
|
9
|
+
attr_accessor :change_type, :commit_date, :name
|
10
|
+
|
11
|
+
def initialize(name, commit_date)
|
12
|
+
@name = name
|
13
|
+
@commit_date = commit_date
|
14
|
+
end
|
15
|
+
|
16
|
+
# This method returns the tag version as a Gem::Version
|
17
|
+
def version
|
18
|
+
Gem::Version.new(name.sub(/\Av\.?/, ''))
|
19
|
+
end
|
20
|
+
|
21
|
+
# This enables tag summaries to be sorted by commit date
|
22
|
+
def <=>(other)
|
23
|
+
commit_date <=> other.commit_date
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
# Mixin that provides a couple of pathname convenience methods
|
6
|
+
module WayOfWorking
|
7
|
+
class << self
|
8
|
+
def root
|
9
|
+
Pathname.new(File.expand_path('../..', __dir__))
|
10
|
+
end
|
11
|
+
|
12
|
+
def source_root
|
13
|
+
root.join('lib', 'way_of_working', 'templates')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
# This class enables subcommands to work correctly with help. See:
|
6
|
+
# https://github.com/rails/thor/wiki/Subcommands#subcommands-that-work-correctly-with-help
|
7
|
+
class SubCommandBase < Thor
|
8
|
+
def self.banner(command, _namespace = nil, _subcommand = false)
|
9
|
+
"#{basename} #{subcommand_prefix} #{command.usage}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.subcommand_prefix
|
13
|
+
name.gsub(/.*::/, '').gsub(/^[A-Z]/) { |match| match[0].downcase }.
|
14
|
+
gsub(/[A-Z]/) { |match| "-#{match[0].downcase}" }
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
require:
|
3
|
+
- ndr_dev_support
|
4
|
+
|
5
|
+
inherit_mode:
|
6
|
+
merge:
|
7
|
+
- Exclude
|
8
|
+
|
9
|
+
AllCops:
|
10
|
+
TargetRubyVersion: 2.7
|
11
|
+
|
12
|
+
# Ignore rules related to templated files
|
13
|
+
Layout/EmptyLines:
|
14
|
+
Exclude:
|
15
|
+
- "config/**/*.rb"
|
16
|
+
|
17
|
+
Layout/SpaceInsideArrayLiteralBrackets:
|
18
|
+
Exclude:
|
19
|
+
- "config/**/*.rb"
|
20
|
+
|
21
|
+
Rails/Date:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Rails/TimeZone:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/Documentation:
|
28
|
+
Exclude:
|
29
|
+
- "app/helpers/application_helper.rb"
|
30
|
+
- "config/**/*.rb"
|
31
|
+
|
32
|
+
Style/GlobalStdStream:
|
33
|
+
Exclude:
|
34
|
+
- "config/environments/production.rb"
|
35
|
+
|
36
|
+
Style/OptionalBooleanParameter:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Style/RedundantConstantBase:
|
40
|
+
Exclude:
|
41
|
+
- "config/environments/production.rb"
|
42
|
+
|
43
|
+
Style/RedundantFetchBlock:
|
44
|
+
Exclude:
|
45
|
+
- "config/puma.rb"
|
46
|
+
|
47
|
+
Style/StringLiterals:
|
48
|
+
Exclude:
|
49
|
+
- "config.ru"
|
50
|
+
- "config/**/*.rb"
|
51
|
+
- "Rakefile"
|
52
|
+
|
53
|
+
Style/SymbolArray:
|
54
|
+
Exclude:
|
55
|
+
- "config/initializers/filter_parameter_logging.rb"
|
@@ -0,0 +1,82 @@
|
|
1
|
+
---
|
2
|
+
# MegaLinter GitHub Action configuration file
|
3
|
+
# More info at https://megalinter.io
|
4
|
+
name: MegaLinter
|
5
|
+
|
6
|
+
on:
|
7
|
+
# Trigger mega-linter at every push. Action will also be visible from Pull Requests to master
|
8
|
+
push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions)
|
9
|
+
pull_request:
|
10
|
+
branches: [master, main]
|
11
|
+
|
12
|
+
env: # Comment env block if you do not want to apply fixes
|
13
|
+
# Apply linter fixes configuration
|
14
|
+
APPLY_FIXES: none # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool)
|
15
|
+
APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all)
|
16
|
+
APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request)
|
17
|
+
|
18
|
+
concurrency:
|
19
|
+
group: ${{ github.ref }}-${{ github.workflow }}
|
20
|
+
cancel-in-progress: true
|
21
|
+
|
22
|
+
jobs:
|
23
|
+
build:
|
24
|
+
name: MegaLinter
|
25
|
+
runs-on: ubuntu-latest
|
26
|
+
steps:
|
27
|
+
# Git Checkout
|
28
|
+
- name: Checkout Code
|
29
|
+
uses: actions/checkout@v3
|
30
|
+
with:
|
31
|
+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
32
|
+
fetch-depth: 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances
|
33
|
+
|
34
|
+
# MegaLinter
|
35
|
+
- name: MegaLinter
|
36
|
+
id: ml
|
37
|
+
# You can override MegaLinter flavor used to have faster performances
|
38
|
+
# More info at https://megalinter.io/flavors/
|
39
|
+
uses: oxsecurity/megalinter@v6
|
40
|
+
env:
|
41
|
+
# All available variables are described in documentation
|
42
|
+
# https://megalinter.io/configuration/
|
43
|
+
VALIDATE_ALL_CODEBASE: true # Set ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} to validate only diff with main branch
|
44
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
45
|
+
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
|
46
|
+
|
47
|
+
# # Upload MegaLinter artifacts
|
48
|
+
# - name: Archive production artifacts
|
49
|
+
# if: ${{ success() }} || ${{ failure() }}
|
50
|
+
# uses: actions/upload-artifact@v3
|
51
|
+
# with:
|
52
|
+
# name: MegaLinter reports
|
53
|
+
# path: |
|
54
|
+
# megalinter-reports
|
55
|
+
# mega-linter.log
|
56
|
+
|
57
|
+
# # Create pull request if applicable (for now works only on PR from same repository, not from forks)
|
58
|
+
# - name: Create Pull Request with applied fixes
|
59
|
+
# id: cpr
|
60
|
+
# if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
|
61
|
+
# uses: peter-evans/create-pull-request@v4
|
62
|
+
# with:
|
63
|
+
# token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
64
|
+
# commit-message: "[MegaLinter] Apply linters automatic fixes"
|
65
|
+
# title: "[MegaLinter] Apply linters automatic fixes"
|
66
|
+
# labels: bot
|
67
|
+
# - name: Create PR output
|
68
|
+
# if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
|
69
|
+
# run: |
|
70
|
+
# echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
71
|
+
# echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
72
|
+
|
73
|
+
# # Push new commit if applicable (for now works only on PR from same repository, not from forks)
|
74
|
+
# - name: Prepare commit
|
75
|
+
# if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
|
76
|
+
# run: sudo chown -Rc $UID .git/
|
77
|
+
# - name: Commit and push applied linter fixes
|
78
|
+
# if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
|
79
|
+
# uses: stefanzweifel/git-auto-commit-action@v4
|
80
|
+
# with:
|
81
|
+
# branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
|
82
|
+
# commit_message: "[MegaLinter] Apply linters fixes"
|
@@ -0,0 +1,129 @@
|
|
1
|
+
---
|
2
|
+
# Configuration file for MegaLinter
|
3
|
+
# See all available variables at https://megalinter.io/configuration/ and in linters documentation
|
4
|
+
|
5
|
+
APPLY_FIXES: none # all, none, or list of linter keys
|
6
|
+
ENABLE_LINTERS: # If you use ENABLE_LINTERS variable, all other linters will be disabled by default
|
7
|
+
# Languages
|
8
|
+
- BASH_EXEC # in Super-Linter
|
9
|
+
- BASH_SHELLCHECK # in Super-Linter
|
10
|
+
- BASH_SHFMT # in Super-Linter
|
11
|
+
- C_CPPLINT
|
12
|
+
# - CLOJURE_CLJ_KONDO # in Super-Linter
|
13
|
+
- COFFEE_COFFEELINT # in Super-Linter
|
14
|
+
- CPP_CPPLINT # in Super-Linter
|
15
|
+
- CSHARP_DOTNET_FORMAT # in Super-Linter
|
16
|
+
- DART_DARTANALYZER # in Super-Linter
|
17
|
+
- GO_GOLANGCI_LINT # in Super-Linter
|
18
|
+
- GO_REVIVE
|
19
|
+
# - GROOVY_NPM_GROOVY_LINT # in Super-Linter
|
20
|
+
- JAVA_CHECKSTYLE # in Super-Linter
|
21
|
+
- JAVA_PMD
|
22
|
+
- JAVASCRIPT_ES # in Super-Linter
|
23
|
+
# - JAVASCRIPT_PRETTIER
|
24
|
+
- JAVASCRIPT_STANDARD # in Super-Linter
|
25
|
+
- JSX_ESLINT
|
26
|
+
- KOTLIN_KTLINT # in Super-Linter
|
27
|
+
# - LUA_LUACHECK # in Super-Linter
|
28
|
+
- MAKEFILE_CHECKMAKE
|
29
|
+
# - PERL_PERLCRITIC # in Super-Linter
|
30
|
+
# - PHP_PHPCS # in Super-Linter
|
31
|
+
# - PHP_PHPLINT # in Super-Linter
|
32
|
+
# - PHP_PHPSTAN # in Super-Linter
|
33
|
+
# - PHP_PSALM # in Super-Linter
|
34
|
+
# - POWERSHELL_POWERSHELL
|
35
|
+
# - POWERSHELL_POWERSHELL_FORMATTER
|
36
|
+
- PYTHON_BANDIT
|
37
|
+
- PYTHON_BLACK # in Super-Linter
|
38
|
+
- PYTHON_FLAKE8 # in Super-Linter
|
39
|
+
- PYTHON_ISORT # in Super-Linter
|
40
|
+
- PYTHON_MYPY
|
41
|
+
- PYTHON_PYLINT # in Super-Linter
|
42
|
+
- PYTHON_PYRIGHT
|
43
|
+
- R_LINTR # in Super-Linter
|
44
|
+
# - RAKU_RAKU # in Super-Linter
|
45
|
+
# - RUBY_RUBOCOP # in Super-Linter
|
46
|
+
- RUST_CLIPPY # in Super-Linter
|
47
|
+
# - SALESFORCE_SFDX_SCANNER_APEX
|
48
|
+
# - SALESFORCE_SFDX_SCANNER_AURA
|
49
|
+
# - SALESFORCE_SFDX_SCANNER_LWC
|
50
|
+
- SCALA_SCALAFIX
|
51
|
+
- SQL_SQL_LINT # in Super-Linter
|
52
|
+
- SQL_SQLFLUFF # in Super-Linter
|
53
|
+
- SQL_TSQLLINT
|
54
|
+
- SWIFT_SWIFTLINT
|
55
|
+
- TSX_ESLINT
|
56
|
+
- TYPESCRIPT_ES # in Super-Linter
|
57
|
+
# - TYPESCRIPT_PRETTIER
|
58
|
+
- TYPESCRIPT_STANDARD # in Super-Linter
|
59
|
+
# - VBDOTNET_DOTNET_FORMAT
|
60
|
+
|
61
|
+
# Formats
|
62
|
+
- CSS_SCSS_LINT
|
63
|
+
- CSS_STYLELINT # in Super-Linter
|
64
|
+
- ENV_DOTENV_LINTER # in Super-Linter
|
65
|
+
# - GRAPHQL_GRAPHQL_SCHEMA_LINTER
|
66
|
+
# - HTML_DJLINT # Refuses to see config file
|
67
|
+
- HTML_HTMLHINT # in Super-Linter
|
68
|
+
- JSON_ESLINT_PLUGIN_JSONC # in Super-Linter
|
69
|
+
- JSON_JSONLINT
|
70
|
+
- JSON_NPM_PACKAGE_JSON_LINT
|
71
|
+
# - JSON_PRETTIER
|
72
|
+
- JSON_V8R
|
73
|
+
# - LATEX_CHKTEX # in Super-Linter
|
74
|
+
- MARKDOWN_MARKDOWNLINT # in Super-Linter
|
75
|
+
- MARKDOWN_MARKDOWN_LINK_CHECK
|
76
|
+
- MARKDOWN_MARKDOWN_TABLE_FORMATTER
|
77
|
+
- MARKDOWN_REMARK_LINT
|
78
|
+
# - PROTOBUF_PROTOLINT # in Super-Linter
|
79
|
+
# - RST_RSTCHECK
|
80
|
+
# - RST_RSTFMT
|
81
|
+
# - RST_RST_LINT
|
82
|
+
- XML_XMLLINT # in Super-Linter
|
83
|
+
# - YAML_PRETTIER
|
84
|
+
- YAML_V8R
|
85
|
+
- YAML_YAMLLINT # in Super-Linter
|
86
|
+
|
87
|
+
# Tooling
|
88
|
+
- ACTION_ACTIONLINT # in Super-Linter
|
89
|
+
- ANSIBLE_ANSIBLE_LINT # in Super-Linter
|
90
|
+
- ARM_ARM_TTK # in Super-Linter
|
91
|
+
# - BICEP_BICEP_LINTER
|
92
|
+
- CLOUDFORMATION_CFN_LINT # in Super-Linter
|
93
|
+
- DOCKERFILE_HADOLINT # in Super-Linter
|
94
|
+
- EDITORCONFIG_EDITORCONFIG_CHECKER # in Super-Linter
|
95
|
+
# - GHERKIN_GHERKIN_LINT # in Super-Linter
|
96
|
+
- KUBERNETES_KUBECONFORM
|
97
|
+
- KUBERNETES_KUBEVAL # in Super-Linter
|
98
|
+
- OPENAPI_SPECTRAL # in Super-Linter
|
99
|
+
- PUPPET_PUPPET_LINT
|
100
|
+
# - SNAKEMAKE_LINT # in Super-Linter
|
101
|
+
# - SNAKEMAKE_SNAKEFMT # in Super-Linter
|
102
|
+
# - TEKTON_TEKTON_LINT # in Super-Linter
|
103
|
+
- TERRAFORM_CHECKOV
|
104
|
+
- TERRAFORM_KICS
|
105
|
+
- TERRAFORM_TERRAFORM_FMT # in Super-Linter
|
106
|
+
- TERRAFORM_TERRAGRUNT # in Super-Linter
|
107
|
+
- TERRAFORM_TERRASCAN # in Super-Linter
|
108
|
+
- TERRAFORM_TFLINT # in Super-Linter
|
109
|
+
|
110
|
+
# Code quality checkers
|
111
|
+
- COPYPASTE_JSCPD # in Super-Linter
|
112
|
+
- REPOSITORY_CHECKOV
|
113
|
+
- REPOSITORY_DEVSKIM
|
114
|
+
- REPOSITORY_DUSTILOCK
|
115
|
+
- REPOSITORY_GITLEAKS # in Super-Linter
|
116
|
+
- REPOSITORY_GIT_DIFF
|
117
|
+
- REPOSITORY_GOODCHECK
|
118
|
+
- REPOSITORY_SECRETLINT
|
119
|
+
- REPOSITORY_SEMGREP
|
120
|
+
- REPOSITORY_SYFT
|
121
|
+
- REPOSITORY_TRIVY
|
122
|
+
# - SPELL_CSPELL
|
123
|
+
- SPELL_MISSPELL
|
124
|
+
- SPELL_PROSELINT
|
125
|
+
|
126
|
+
SHOW_ELAPSED_TIME: false
|
127
|
+
FILEIO_REPORTER: false
|
128
|
+
FAIL_IF_MISSING_LINTER_IN_FLAVOR: true
|
129
|
+
# DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass
|
@@ -0,0 +1 @@
|
|
1
|
+
--config .github/linters/rubocop_defaults.yml
|