wagemage 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/tests.yml +18 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +74 -0
- data/LICENSE.txt +21 -0
- data/README.md +242 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/rake +29 -0
- data/bin/setup +6 -0
- data/examples/add_test_file +35 -0
- data/examples/consolidate_pushes_during_release +63 -0
- data/examples/enable_teaspoon_tests +83 -0
- data/examples/find_decorated_test +35 -0
- data/examples/find_teaspoon_tests +32 -0
- data/examples/ignore_remote_rubocop_config +48 -0
- data/examples/nextyear +43 -0
- data/exe/wagemage +9 -0
- data/lib/wagemage.rb +31 -0
- data/lib/wagemage/cli.rb +191 -0
- data/lib/wagemage/helpers.rb +30 -0
- data/lib/wagemage/repo.rb +78 -0
- data/lib/wagemage/version.rb +3 -0
- data/wagemage.gemspec +36 -0
- metadata +157 -0
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "wagemage"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/setup
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Problem: I need a script with which I may test.
|
4
|
+
#
|
5
|
+
# Command to run:
|
6
|
+
#
|
7
|
+
# wagemage \
|
8
|
+
# --repo 'meowsus/wagemage' \
|
9
|
+
# --script examples/add_test_file
|
10
|
+
|
11
|
+
repo_path, repo_name, branch = ARGV
|
12
|
+
|
13
|
+
file_path = [repo_path, 'TEST.md'].join('/')
|
14
|
+
|
15
|
+
abort if File.exist?(file_path)
|
16
|
+
|
17
|
+
File.open(file_path, 'w') do |file|
|
18
|
+
file.write <<~CONTENT
|
19
|
+
# TEST
|
20
|
+
|
21
|
+
This is a test file. It serves no purpose other than to test.
|
22
|
+
|
23
|
+
It should be committed to the #{repo_name} repository and merged into the #{branch} branch.
|
24
|
+
|
25
|
+
And now we've reached the exciting conclusion of the file.
|
26
|
+
CONTENT
|
27
|
+
end
|
28
|
+
|
29
|
+
puts <<~COMMIT_MESSAGE
|
30
|
+
Add test file
|
31
|
+
|
32
|
+
We're adding a test file for testing purposes to the #{branch} branch.
|
33
|
+
COMMIT_MESSAGE
|
34
|
+
|
35
|
+
exit
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Problem: now that Workarea uses GitHub actions we are running out of minutes
|
4
|
+
# due to each plugin pushing a CHANGELOG commit and tags separately.
|
5
|
+
#
|
6
|
+
# This script should be used for plugins, only. Workarea's Rakefile and plugin
|
7
|
+
# template should be handled separately. This might not work on API since it,
|
8
|
+
# too, is a meta-gem.
|
9
|
+
#
|
10
|
+
# Refer to new hotness: https://stackoverflow.com/a/3745250
|
11
|
+
#
|
12
|
+
# Command to run:
|
13
|
+
#
|
14
|
+
# wagemage \
|
15
|
+
# --org workarea-commerce \
|
16
|
+
# --repo '^workarea-commerce/workarea-' \
|
17
|
+
# --branch '(-stable$|^master$)' \
|
18
|
+
# --script examples/consolidate_pushes_during_release \
|
19
|
+
# --reviewers bencrouse,mttdffy,tubbo,jyucis \
|
20
|
+
# --branch-prefix WORKAREA-148
|
21
|
+
|
22
|
+
repo_path = ARGV.first
|
23
|
+
rakefile_path = [repo_path, 'Rakefile'].join('/')
|
24
|
+
|
25
|
+
# Test to see if the Rakefile even exists in the first place
|
26
|
+
abort("No Rakefile") unless File.exist?(rakefile_path)
|
27
|
+
|
28
|
+
# Load Rakefile
|
29
|
+
rakefile = File.open(rakefile_path, 'r+')
|
30
|
+
rakefile_content = rakefile.read
|
31
|
+
rakefile.close
|
32
|
+
|
33
|
+
# Test for release task
|
34
|
+
abort("No release task") unless rakefile_content.include?('task :release')
|
35
|
+
|
36
|
+
# Uncomment Changelog generator while we're in there
|
37
|
+
rakefile_content.gsub!(/(\s+)#(Rake::Task|system)(.*changelog)/i, '\1\2\3')
|
38
|
+
|
39
|
+
# Remove offending initial push
|
40
|
+
rakefile_content.gsub!(/\s+#?system\s*['"]git push origin head['"].*/i, '')
|
41
|
+
|
42
|
+
# Replace extraneous tags push with new hotness
|
43
|
+
rakefile_content.gsub!(/git push --tags/i, 'git push origin HEAD --follow-tags')
|
44
|
+
|
45
|
+
# Write the file
|
46
|
+
rakefile = File.open(rakefile_path, 'w')
|
47
|
+
rakefile.write(rakefile_content)
|
48
|
+
rakefile.close
|
49
|
+
|
50
|
+
# Output the commit message
|
51
|
+
puts <<~COMMIT_MESSAGE
|
52
|
+
Remove extraneous push in Release task
|
53
|
+
|
54
|
+
We're running out of minutes in our GitHub actions due to duplicate pushes
|
55
|
+
during a release. This consolidates the two pushes into one.
|
56
|
+
|
57
|
+
No changelog
|
58
|
+
|
59
|
+
WORKAREA-148
|
60
|
+
COMMIT_MESSAGE
|
61
|
+
|
62
|
+
# Exit cleanly
|
63
|
+
exit
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
# Problem: During our upgrade to Rails 6 we found that Teaspoon wasn't
|
6
|
+
# compatable. As a result we disabled teaspoon tests across all of our builds.A
|
7
|
+
#
|
8
|
+
# Solution: Scan through each repo to find any teaspoon tests. If found, add
|
9
|
+
# the appropriate entry for the corresponding engine to ci.yml.
|
10
|
+
#
|
11
|
+
# Command to run:
|
12
|
+
#
|
13
|
+
# wagemage \
|
14
|
+
# --org workarea-commerce \
|
15
|
+
# --repo '^workarea-commerce/workarea-' \
|
16
|
+
# --branch '(-stable$|^master$)' \
|
17
|
+
# --script examples/enable_teaspoon_tests \
|
18
|
+
# --reviewers bencrouse,mttdffy,tubbo,jyucis \
|
19
|
+
# --branch-prefix WORKAREA-185
|
20
|
+
|
21
|
+
repo_path = ARGV.first
|
22
|
+
ci_file_path = [repo_path, '.github', 'workflows', 'ci.yml'].join('/')
|
23
|
+
rakefile_path = [repo_path, 'Rakefile'].join('/')
|
24
|
+
|
25
|
+
# See if there are no tests to run
|
26
|
+
tests = Dir["#{repo_path}/test/javascript*/**/*.js"]
|
27
|
+
abort('No tests') unless tests.any?
|
28
|
+
|
29
|
+
# Potential entry for ci.yml
|
30
|
+
ci_entry = <<-ENTRY
|
31
|
+
|
32
|
+
teaspoon:
|
33
|
+
runs-on: ubuntu-latest
|
34
|
+
steps:
|
35
|
+
- uses: actions/checkout@v1
|
36
|
+
- uses: actions/setup-ruby@v1
|
37
|
+
with:
|
38
|
+
ruby-version: 2.6.x
|
39
|
+
- uses: workarea-commerce/ci/test@v1
|
40
|
+
with:
|
41
|
+
command: bin/rails app:teaspoon
|
42
|
+
ENTRY
|
43
|
+
|
44
|
+
# Potential entry for rakefile
|
45
|
+
rakefile_entry = <<~ENTRY
|
46
|
+
|
47
|
+
desc "Run the JavaScript tests"
|
48
|
+
ENV["TEASPOON_RAILS_ENV"] = File.expand_path("../test/dummy/config/environment", __FILE__)
|
49
|
+
task teaspoon: "app:teaspoon"
|
50
|
+
|
51
|
+
desc "Start a server at http://localhost:3000/teaspoon for JavaScript tests"
|
52
|
+
task :teaspoon_server do
|
53
|
+
Dir.chdir("test/dummy")
|
54
|
+
teaspoon_env = File.expand_path("../test/teaspoon_env.rb", __FILE__)
|
55
|
+
system "RAILS_ENV=test TEASPOON_ENV=#\{teaspoon_env\} rails s"
|
56
|
+
end
|
57
|
+
ENTRY
|
58
|
+
|
59
|
+
# Write to ci.yml if no reference to teaspoon is found
|
60
|
+
ci_file = File.open(ci_file_path, 'a+')
|
61
|
+
ci_file.write(ci_entry) unless ci_file.read =~ /teaspoon/
|
62
|
+
ci_file.close
|
63
|
+
|
64
|
+
# Write to Rakefile if no reference to teaspoon is found
|
65
|
+
rakefile = File.open(rakefile_path, 'a+')
|
66
|
+
rakefile.write(rakefile_entry) unless rakefile.read =~ /teaspoon/
|
67
|
+
rakefile.close
|
68
|
+
|
69
|
+
# Check to see if any changes were made
|
70
|
+
stdout, _ = Open3.capture3('git status', chdir: repo_path)
|
71
|
+
abort("No changes made") if stdout =~ /nothing to commit/
|
72
|
+
|
73
|
+
# Output commit message
|
74
|
+
puts <<~COMMIT_MESSAGE
|
75
|
+
Enable Teaspoon in CI
|
76
|
+
|
77
|
+
No changelog
|
78
|
+
|
79
|
+
WORKAREA-185
|
80
|
+
COMMIT_MESSAGE
|
81
|
+
|
82
|
+
# Exit cleanly
|
83
|
+
exit
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Problem: a test failure in the workarea-reviews plugin had eluded us for quite
|
4
|
+
# a while. During the hustle-n-bustle of the plugin updates at the end of the
|
5
|
+
# last minor release, the theme plugins just decorated the test. Now that the
|
6
|
+
# test has been fixed we need to obtain a list of plugins that have decorated
|
7
|
+
# this test so that we can go and manually edit them.
|
8
|
+
#
|
9
|
+
# Adds a file to `/tmp/decorated_tests.log` FYI.
|
10
|
+
#
|
11
|
+
# Command to run:
|
12
|
+
#
|
13
|
+
# wagemage \
|
14
|
+
# --org workarea-commerce \
|
15
|
+
# --repo '-theme$' \
|
16
|
+
# --branch '(-stable$|^master$)' \
|
17
|
+
# --script examples/find_decorated_test \
|
18
|
+
# --debug
|
19
|
+
|
20
|
+
repo_path, repo_name, branch = ARGV
|
21
|
+
logfile = File.open("/tmp/decorated_tests.log", 'a')
|
22
|
+
|
23
|
+
decorated_files = Dir[[repo_path, '**/reviews_helper_test.decorator'].join('/')]
|
24
|
+
|
25
|
+
if decorated_files.empty?
|
26
|
+
logfile.close
|
27
|
+
abort("File not found in #{repo_path}")
|
28
|
+
end
|
29
|
+
|
30
|
+
file_content = "in: #{repo_name}:#{branch}\n"
|
31
|
+
|
32
|
+
logfile.write(file_content)
|
33
|
+
logfile.close
|
34
|
+
|
35
|
+
exit
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Problem: Teaspoon isn't ready for Rails 6 and we're brainstorming solutions.
|
4
|
+
# We need to know what plugins even have teaspoon tests written for them.
|
5
|
+
#
|
6
|
+
# Adds a file at `/tmp/javascript_tests_in_plugins.log` FYI.
|
7
|
+
#
|
8
|
+
# Command to run:
|
9
|
+
#
|
10
|
+
# wagemage \
|
11
|
+
# --org workarea-commerce \
|
12
|
+
# --repo '^workarea-commerce/workarea-' \
|
13
|
+
# --branch '(-stable$|^master$)' \
|
14
|
+
# --script examples/find_teaspoon_tests \
|
15
|
+
# --debug
|
16
|
+
|
17
|
+
repo_path, repo_name, branch = ARGV
|
18
|
+
logfile = File.open("/tmp/javascript_tests_in_plugins.log", 'a')
|
19
|
+
|
20
|
+
test_files = Dir[[repo_path, 'test/javascripts/**/*.js'].join('/')]
|
21
|
+
|
22
|
+
if test_files.empty?
|
23
|
+
logfile.close
|
24
|
+
abort("Teaspoon tests not found in #{repo_path}")
|
25
|
+
end
|
26
|
+
|
27
|
+
file_content = "Teaspoon tests found in: #{repo_name}:#{branch}\n"
|
28
|
+
|
29
|
+
logfile.write(file_content)
|
30
|
+
logfile.close
|
31
|
+
|
32
|
+
exit
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Problem: after inheriting our rubocop configuration from the base workarea
|
4
|
+
# gem a file is downloaded to the repo each time Rubocop is run. This is a pain
|
5
|
+
# during a release because my editor will automatically run Rubocop each time
|
6
|
+
# a Ruby file is opened
|
7
|
+
#
|
8
|
+
# Solution: Check .gitignore for the presence of `.rubocop-http`. If it doesn't
|
9
|
+
# exist append `.rubocop-http*` to the end of the file.
|
10
|
+
#
|
11
|
+
# Command to run:
|
12
|
+
#
|
13
|
+
# wagemage \
|
14
|
+
# --org workarea-commerce \
|
15
|
+
# --repo '^workarea-commerce/workarea-' \
|
16
|
+
# --branch '(-stable$|^master$)' \
|
17
|
+
# --script examples/ignore_remote_rubocop_config \
|
18
|
+
# --reviewers bencrouse
|
19
|
+
|
20
|
+
repo_path = ARGV.first
|
21
|
+
gitignore_path = [repo_path, '.gitignore'].join('/')
|
22
|
+
|
23
|
+
# Test to see if the .gitignore even exists in the first place
|
24
|
+
abort("No Gitignore") unless File.exist?(gitignore_path)
|
25
|
+
|
26
|
+
# Load Gitignore content
|
27
|
+
gitignore = File.open(gitignore_path, 'r+')
|
28
|
+
gitignore_content = gitignore.read
|
29
|
+
gitignore.close
|
30
|
+
|
31
|
+
# Test for `.rubocop-http` entry
|
32
|
+
if gitignore_content.include?('.rubocop-http')
|
33
|
+
abort("Already ignoring remote config")
|
34
|
+
end
|
35
|
+
|
36
|
+
gitignore = File.open(gitignore_path, 'a')
|
37
|
+
gitignore.write '.rubocop-http*'
|
38
|
+
gitignore.close
|
39
|
+
|
40
|
+
# Output the commit message
|
41
|
+
puts <<~COMMIT_MESSAGE
|
42
|
+
Ignore remote Rubocop config
|
43
|
+
|
44
|
+
No changelog
|
45
|
+
COMMIT_MESSAGE
|
46
|
+
|
47
|
+
# Exit cleanly
|
48
|
+
exit
|
data/examples/nextyear
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
TICKETS = {
|
6
|
+
'workarea-commerce/workarea-address-verification' => 'WEBADDVER-4',
|
7
|
+
'workarea-commerce/workarea-stripe' => 'STRIPE-2',
|
8
|
+
'workarea-commerce/workarea-quotes' => 'QUOTES-3',
|
9
|
+
'workarea-commerce/workarea-oms' => 'OMS-5',
|
10
|
+
# 'workarea-commerce/workarea-global-e' => 'GLOBALE-3',
|
11
|
+
'workarea-commerce/workarea-gift-cards' => 'GIFTCARDS-6',
|
12
|
+
'workarea-commerce/workarea-forter' => 'FORTER-2',
|
13
|
+
'workarea-commerce/workarea-bopus' => 'BOPUS-3',
|
14
|
+
'workarea-commerce/workarea-payware-connect' => 'PAYWARE-1'
|
15
|
+
}
|
16
|
+
|
17
|
+
path, repo, _branch = ARGV
|
18
|
+
plugin = Pathname.new(path)
|
19
|
+
ticket = TICKETS[repo]
|
20
|
+
@changed = false
|
21
|
+
|
22
|
+
plugin.glob('test/**/*.{rb,decorator}').each do |test|
|
23
|
+
fixed = test.read.to_s.gsub(/2020,/, 'next_year,')
|
24
|
+
.gsub(/'2020'/, 'next_year.to_s')
|
25
|
+
.gsub(/"2020",/, 'next_year.to_s,')
|
26
|
+
@changed = fixed != test.read.to_s
|
27
|
+
|
28
|
+
test.write(fixed)
|
29
|
+
end
|
30
|
+
|
31
|
+
gemfile = plugin.join('Gemfile')
|
32
|
+
gemfile.write(gemfile.read.to_s.gsub(/:master/, "'v3.5-stable'"))
|
33
|
+
|
34
|
+
STDERR.puts "Ticket Not Found For Repo '#{repo}'" if ticket.nil? && @changed
|
35
|
+
|
36
|
+
puts <<~COMMIT_MESSAGE
|
37
|
+
Fix Tests for 2020
|
38
|
+
|
39
|
+
Update all tests so that they no longer depend on the year 2020 as an
|
40
|
+
expiration year. Instead, use the `next_year` method provided by Workarea.
|
41
|
+
|
42
|
+
#{ticket}
|
43
|
+
COMMIT_MESSAGE
|
data/exe/wagemage
ADDED
data/lib/wagemage.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'open3'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
require 'slop'
|
6
|
+
require 'colorize'
|
7
|
+
require 'octokit'
|
8
|
+
|
9
|
+
module Slop
|
10
|
+
class PathOption < Option
|
11
|
+
def call(value)
|
12
|
+
Pathname.new(value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Octokit.configure do |c|
|
18
|
+
c.auto_paginate = true
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'wagemage/version'
|
22
|
+
require 'wagemage/helpers'
|
23
|
+
require 'wagemage/cli'
|
24
|
+
require 'wagemage/repo'
|
25
|
+
|
26
|
+
module Wagemage
|
27
|
+
class Error < StandardError; end
|
28
|
+
class OptionError < Slop::MissingRequiredOption; end
|
29
|
+
|
30
|
+
extend Helpers
|
31
|
+
end
|