rolemodel-rails 0.26.0 → 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 +4 -4
- data/lib/generators/rolemodel/base_generator.rb +2 -0
- data/lib/generators/rolemodel/github/README.md +14 -17
- data/lib/generators/rolemodel/github/USAGE +4 -1
- data/lib/generators/rolemodel/github/github_generator.rb +23 -17
- data/lib/generators/rolemodel/github/templates/CODEOWNERS +8 -0
- data/lib/generators/rolemodel/github/templates/dependabot.yml +87 -0
- data/lib/generators/rolemodel/github/templates/instructions +1 -0
- data/lib/generators/rolemodel/github/templates/pull_request_template.md +18 -0
- data/lib/generators/rolemodel/github/templates/workflows/ci.yml.tt +81 -0
- data/lib/generators/rolemodel/testing/rspec/templates/support/helpers/capybara_helper.rb +0 -46
- data/lib/generators/rolemodel/testing/rspec/templates/support/helpers/playwright_helper.rb +0 -60
- data/lib/rolemodel/version.rb +1 -1
- data/lib/rolemodel-rails.rb +2 -0
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0fc94b9f1782c5251c05b2ec1e9f8de40ff8021383c4d358c1cf67dae0c2e86
|
|
4
|
+
data.tar.gz: 8eb5debdc363920c4b21f06381b4c6789162a5dcd984c40ba377fecfb1eb90a2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be60dc3620a2d22b8ed1148a1966219c830d685e48df12ed5abafd884cd1f749f4251360173f42b355b10865238f000a95da825624c21ee898fde25c7c9dc9d9
|
|
7
|
+
data.tar.gz: b76c9375e38755a22e66aff75109727a7a03273d9ee4dc9e44049774259f2b60ca793f3a550b79550cdd729cca9154e400547a2472f2565fe18fedb05cfd10e3
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
# Github Generator
|
|
2
2
|
|
|
3
3
|
## Prerequisites
|
|
4
|
-
You will need the parallel_tests generator to run the CI tests.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### ci.yml
|
|
9
|
-
A sensible default `ci.yml` to get you started with Github Actions. This will run linters, model tests, and system tests.
|
|
10
|
-
|
|
11
|
-
Along with the `ci.yml`, your `database.yml` will be modified to be able to be run in GHA.
|
|
12
|
-
|
|
13
|
-
### Pull Request Template
|
|
5
|
+
It doesn't need to be run first, but the parallel_tests generator must be run in order for the CI workflow to run successfully on GitHub.
|
|
14
6
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Helpful for reminding collaborators to add specific details to the PR.
|
|
18
|
-
|
|
19
|
-
### Copilot Instructions
|
|
7
|
+
## What you get
|
|
20
8
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
- CI workflow
|
|
10
|
+
- A sensible default `ci.yml` to get you started with Github Actions. This will run linters, model tests, and system tests.
|
|
11
|
+
- Along with the `ci.yml`, your `database.yml` will be modified to be able to be run in GHA.
|
|
12
|
+
- Pull Request Template
|
|
13
|
+
- When you open a Pull Request in Github it will use the Markdown file as a [template](./templates/pull_request_template.md) for the content of the PR.
|
|
14
|
+
- Helpful for reminding collaborators to add specific details to the PR.
|
|
15
|
+
- Copilot Instructions
|
|
16
|
+
- Installed into `.github/instructions`, these are context-specific instructions for Copilot to help it give more accurate
|
|
17
|
+
and relevant results. These are a good starting point but they should be tweaked for your project's frameworks and
|
|
18
|
+
standards.
|
|
19
|
+
- Dependabot Configuration
|
|
20
|
+
- defines a set of rules that dependabot will use to keep your applications dependencies up-to-date on a weekly basis.
|
|
@@ -2,30 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
module Rolemodel
|
|
4
4
|
class GithubGenerator < BaseGenerator
|
|
5
|
-
|
|
6
|
-
#
|
|
7
|
-
|
|
5
|
+
GITHUB_ACTIONS_REPO = 'https://github.com/RoleModel/actions.git'
|
|
6
|
+
# Files which are both used by the gem source and copied to the target app without modification
|
|
7
|
+
# are placed in the `.github` folder at the top level of this repository. This folder is then
|
|
8
|
+
# symlinked to the `templates` folder relative to this generator so they can still be copied over.
|
|
9
|
+
# Any files which are significantly different or not used by the gem source are just in `templates`.
|
|
10
|
+
source_root File.expand_path('templates', __dir__)
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
class_option :playwright, type: :boolean, default: true,
|
|
13
|
+
desc: 'Request Playwright Setup in CI workflow for system tests?'
|
|
14
|
+
|
|
15
|
+
def set_rm_actions_version
|
|
16
|
+
tags = `git ls-remote --tags #{GITHUB_ACTIONS_REPO}` rescue 'refs/tags/v3'
|
|
17
|
+
@rm_actions_version = tags.scan(%r{refs/tags/v(\d+)\s*$}).flatten.max_by(&:to_i)
|
|
11
18
|
end
|
|
12
19
|
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
"* [ ] Run `bin/bump_version` or `bin/bump_version --patch`\n",
|
|
16
|
-
''
|
|
20
|
+
def set_webdriver
|
|
21
|
+
@webdriver = options.playwright? ? 'playwright' : 'selenium'
|
|
17
22
|
end
|
|
18
23
|
|
|
19
|
-
def
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
copy_file 'instructions/ruby.instructions.md', '.github/instructions/ruby.instructions.md'
|
|
24
|
-
copy_file 'instructions/slim.instructions.md', '.github/instructions/slim.instructions.md'
|
|
24
|
+
def install_github_config
|
|
25
|
+
directory 'instructions', '.github/instructions'
|
|
26
|
+
directory 'workflows', '.github/workflows', force: true
|
|
27
|
+
template 'pull_request_template.md', '.github/pull_request_template.md'
|
|
25
28
|
end
|
|
26
29
|
|
|
27
|
-
def
|
|
28
|
-
copy_file '
|
|
30
|
+
def install_dependabot_and_codeowners
|
|
31
|
+
copy_file 'dependabot.yml', '.github/dependabot.yml', force: true
|
|
32
|
+
copy_file 'CODEOWNERS', '.github/CODEOWNERS'
|
|
33
|
+
|
|
34
|
+
say '👉 See CODEOWNERS file for important instructions.', %i[bold red on_blue]
|
|
29
35
|
end
|
|
30
36
|
|
|
31
37
|
def update_database_yml_for_ci
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# This file is used by Dependabot (and more broadly GitHub) to determine who needs to review
|
|
2
|
+
# pull requests which contain changes to specific files. Specifically, the setup below allows
|
|
3
|
+
# for the dependabot PRs to automatically assign (and notify) the Craftsman and Support Dev.
|
|
4
|
+
|
|
5
|
+
# Dependabot / Dependency reviewers:
|
|
6
|
+
# TODO: Update and uncomment the following lines.
|
|
7
|
+
# yarn.lock @craftsman @supportdev
|
|
8
|
+
# Gemfile.lock @craftsman @supportdev
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
registries:
|
|
3
|
+
ruby-github:
|
|
4
|
+
type: rubygems-server
|
|
5
|
+
url: https://rubygems.pkg.github.com/RoleModel
|
|
6
|
+
token: ${{ secrets.ROLEMODEL_PACKAGE_REPO_READ_TOKEN }}
|
|
7
|
+
|
|
8
|
+
updates:
|
|
9
|
+
- package-ecosystem: bundler
|
|
10
|
+
insecure-external-code-execution: allow
|
|
11
|
+
registries:
|
|
12
|
+
- ruby-github
|
|
13
|
+
directory: /
|
|
14
|
+
schedule:
|
|
15
|
+
interval: weekly
|
|
16
|
+
day: monday
|
|
17
|
+
# Ignore specific dependencies or update types which may cause issues. For example:
|
|
18
|
+
# ignore:
|
|
19
|
+
# - dependency-name: 'some-gem'
|
|
20
|
+
# - update-types: ['version-update:semver-major']
|
|
21
|
+
groups:
|
|
22
|
+
production-security:
|
|
23
|
+
dependency-type: production
|
|
24
|
+
applies-to: security-updates
|
|
25
|
+
production-major-updates:
|
|
26
|
+
dependency-type: production
|
|
27
|
+
applies-to: version-updates
|
|
28
|
+
update-types:
|
|
29
|
+
- major
|
|
30
|
+
production-minor-updates:
|
|
31
|
+
dependency-type: production
|
|
32
|
+
applies-to: version-updates
|
|
33
|
+
update-types:
|
|
34
|
+
- minor
|
|
35
|
+
- patch
|
|
36
|
+
development-security:
|
|
37
|
+
dependency-type: development
|
|
38
|
+
applies-to: security-updates
|
|
39
|
+
development-major-updates:
|
|
40
|
+
dependency-type: development
|
|
41
|
+
applies-to: version-updates
|
|
42
|
+
update-types:
|
|
43
|
+
- major
|
|
44
|
+
development-minor-updates:
|
|
45
|
+
dependency-type: development
|
|
46
|
+
applies-to: version-updates
|
|
47
|
+
update-types:
|
|
48
|
+
- minor
|
|
49
|
+
- patch
|
|
50
|
+
- package-ecosystem: npm
|
|
51
|
+
directory: /
|
|
52
|
+
schedule:
|
|
53
|
+
interval: weekly
|
|
54
|
+
day: monday
|
|
55
|
+
# Ignore specific dependencies or update types which may cause issues. For example:
|
|
56
|
+
# ignore:
|
|
57
|
+
# - dependency-name: 'some-package'
|
|
58
|
+
# - update-types: ['version-update:semver-major']
|
|
59
|
+
groups:
|
|
60
|
+
production-security:
|
|
61
|
+
dependency-type: production
|
|
62
|
+
applies-to: security-updates
|
|
63
|
+
production-major-updates:
|
|
64
|
+
dependency-type: production
|
|
65
|
+
applies-to: version-updates
|
|
66
|
+
update-types:
|
|
67
|
+
- major
|
|
68
|
+
production-minor-updates:
|
|
69
|
+
dependency-type: production
|
|
70
|
+
applies-to: version-updates
|
|
71
|
+
update-types:
|
|
72
|
+
- minor
|
|
73
|
+
- patch
|
|
74
|
+
development-security:
|
|
75
|
+
dependency-type: development
|
|
76
|
+
applies-to: security-updates
|
|
77
|
+
development-major-updates:
|
|
78
|
+
dependency-type: development
|
|
79
|
+
applies-to: version-updates
|
|
80
|
+
update-types:
|
|
81
|
+
- major
|
|
82
|
+
development-minor-updates:
|
|
83
|
+
dependency-type: development
|
|
84
|
+
applies-to: version-updates
|
|
85
|
+
update-types:
|
|
86
|
+
- minor
|
|
87
|
+
- patch
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
../../../../../.github/instructions
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
## Why?
|
|
2
|
+
|
|
3
|
+
Why were the changes needed? What issues were the changes addressing?
|
|
4
|
+
(Note: some changes may seem unrelated to the ticket, this is a great place to explain further.)
|
|
5
|
+
|
|
6
|
+
## What Changed
|
|
7
|
+
|
|
8
|
+
What changed in this PR?
|
|
9
|
+
|
|
10
|
+
* [ ] Change 1
|
|
11
|
+
|
|
12
|
+
## Pre-merge checklist
|
|
13
|
+
|
|
14
|
+
* [ ] Update relevant READMEs
|
|
15
|
+
|
|
16
|
+
## Screenshots
|
|
17
|
+
|
|
18
|
+
If any UI changes need to be shown off, please add screenshots here.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
concurrency:
|
|
8
|
+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
9
|
+
cancel-in-progress: true
|
|
10
|
+
|
|
11
|
+
env:
|
|
12
|
+
CI: true
|
|
13
|
+
RAILS_ENV: test
|
|
14
|
+
POSTGRES_USER: postgres
|
|
15
|
+
POSTGRES_PASSWORD: password
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
project-stats:
|
|
19
|
+
name: Project Stats
|
|
20
|
+
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
21
|
+
timeout-minutes: 3
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v6
|
|
24
|
+
- uses: RoleModel/actions/project-stats@v<%= @rm_actions_version %>
|
|
25
|
+
|
|
26
|
+
compile-assets:
|
|
27
|
+
name: Compile Assets
|
|
28
|
+
runs-on: blacksmith-8vcpu-ubuntu-2404
|
|
29
|
+
timeout-minutes: 5
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v6
|
|
32
|
+
- uses: RoleModel/actions/compile-assets@v<%= @rm_actions_version %>
|
|
33
|
+
id: check-asset-cache
|
|
34
|
+
|
|
35
|
+
non-system-test:
|
|
36
|
+
name: Linting & Ruby Non-System Tests
|
|
37
|
+
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
38
|
+
timeout-minutes: 5
|
|
39
|
+
services:
|
|
40
|
+
postgres:
|
|
41
|
+
image: postgres:17
|
|
42
|
+
ports: [ "5432:5432" ]
|
|
43
|
+
env:
|
|
44
|
+
POSTGRES_USER: postgres
|
|
45
|
+
POSTGRES_PASSWORD: password
|
|
46
|
+
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@v6
|
|
49
|
+
- uses: ruby/setup-ruby@v1
|
|
50
|
+
with: { bundler-cache: true }
|
|
51
|
+
- run: bin/bundler-audit
|
|
52
|
+
- run: bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error
|
|
53
|
+
- run: bundle exec rubocop --format github
|
|
54
|
+
- uses: RoleModel/actions/linting-and-non-system-tests@v<%= @rm_actions_version %>
|
|
55
|
+
with:
|
|
56
|
+
needs-compiled-assets: false
|
|
57
|
+
|
|
58
|
+
system-test:
|
|
59
|
+
name: Ruby System Tests
|
|
60
|
+
runs-on: blacksmith-8vcpu-ubuntu-2404
|
|
61
|
+
timeout-minutes: 15
|
|
62
|
+
needs: compile-assets
|
|
63
|
+
services:
|
|
64
|
+
postgres:
|
|
65
|
+
image: postgres:17
|
|
66
|
+
ports: [ "5432:5432" ]
|
|
67
|
+
env:
|
|
68
|
+
POSTGRES_USER: postgres
|
|
69
|
+
POSTGRES_PASSWORD: password
|
|
70
|
+
|
|
71
|
+
steps:
|
|
72
|
+
- uses: actions/checkout@v6
|
|
73
|
+
# Uncomment the following if your app require VIPS for processing ActiveStorage variant images in system tests.
|
|
74
|
+
# - name: Setup vips
|
|
75
|
+
# run: |
|
|
76
|
+
# sudo apt-get update
|
|
77
|
+
# sudo apt-get install -y libvips
|
|
78
|
+
- uses: RoleModel/actions/system-tests@v<%= @rm_actions_version %>
|
|
79
|
+
with:
|
|
80
|
+
web-driver: <%= @webdriver %>
|
|
81
|
+
# failure-screenshot-dir: tmp/screenshots
|
|
@@ -1,51 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Update the link_or_button selector so that we can use `click_on` with gc-menu-item
|
|
4
|
-
Capybara.modify_selector(:link_or_button) do
|
|
5
|
-
label 'link or button'
|
|
6
|
-
|
|
7
|
-
xpath do |locator, **options|
|
|
8
|
-
%i[link button].map do |selector|
|
|
9
|
-
expression_for(selector, locator, **options)
|
|
10
|
-
end.reduce(:union)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
module LoadStateWaitingLogic
|
|
15
|
-
module_function
|
|
16
|
-
|
|
17
|
-
def add_wait_for_load_state(method_names)
|
|
18
|
-
method_names.each do |method_name|
|
|
19
|
-
define_method(method_name) do |*args, **kwargs, &block|
|
|
20
|
-
super(*args, **kwargs, &block).tap do
|
|
21
|
-
return unless CapybaraHelper.supports_javascript?
|
|
22
|
-
|
|
23
|
-
Capybara.page.driver.with_playwright_page do |page|
|
|
24
|
-
page.wait_for_load_state(state: 'networkidle')
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
module LoadStateWaiter
|
|
33
|
-
include LoadStateWaitingLogic
|
|
34
|
-
|
|
35
|
-
INTERACTIVE_METHODS = %i[choose check uncheck select fill_in].freeze
|
|
36
|
-
LoadStateWaitingLogic.add_wait_for_load_state(INTERACTIVE_METHODS)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
module ElementLoadStateWaiter
|
|
40
|
-
include LoadStateWaitingLogic
|
|
41
|
-
|
|
42
|
-
INTERACTIVE_METHODS = %i[send_keys click select].freeze
|
|
43
|
-
LoadStateWaitingLogic.add_wait_for_load_state(INTERACTIVE_METHODS)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
Capybara::Node::Actions.prepend(LoadStateWaiter)
|
|
47
|
-
Capybara::Node::Element.prepend(ElementLoadStateWaiter)
|
|
48
|
-
|
|
49
3
|
module CapybaraHelper
|
|
50
4
|
TIMEOUT = 10
|
|
51
5
|
|
|
@@ -22,64 +22,4 @@ module PlaywrightHelper
|
|
|
22
22
|
|
|
23
23
|
puts "Screenshot saved to \e[4;96m#{directory}/#{filename}.png\e[0m" if print_message
|
|
24
24
|
end
|
|
25
|
-
|
|
26
|
-
def self.scope_stack
|
|
27
|
-
@scope_stack ||= []
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def current_scope
|
|
31
|
-
PlaywrightHelper.scope_stack.last || pw_page
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def within(selector, **, &block)
|
|
35
|
-
if supports_javascript?
|
|
36
|
-
begin
|
|
37
|
-
pw_locator = if selector.is_a?(Capybara::Node::Element)
|
|
38
|
-
pw_page.locator("xpath=#{selector.path}")
|
|
39
|
-
else
|
|
40
|
-
pw_page.locator(selector)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
PlaywrightHelper.scope_stack.push(pw_locator)
|
|
44
|
-
|
|
45
|
-
super
|
|
46
|
-
ensure
|
|
47
|
-
PlaywrightHelper.scope_stack.pop
|
|
48
|
-
end
|
|
49
|
-
else
|
|
50
|
-
super
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def click_on(text = nil, **args)
|
|
55
|
-
if supports_javascript? && text.present?
|
|
56
|
-
scope = current_scope
|
|
57
|
-
locator = nil
|
|
58
|
-
|
|
59
|
-
%w[button link gc-menu-item summary].each do |tag|
|
|
60
|
-
loc = scope.get_by_role(tag).get_by_text(text)
|
|
61
|
-
loc = scope.get_by_role(tag).get_by_text(text, exact: true) if loc.count > 1
|
|
62
|
-
loc = scope.locator(tag).get_by_text(text) unless loc.count == 1
|
|
63
|
-
locator = loc if loc.count == 1
|
|
64
|
-
break if locator.present?
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
locator = scope.get_by_text(text, exact: true) if locator.blank?
|
|
68
|
-
|
|
69
|
-
raise "No element matching text: '#{text}'" if locator.count < 1
|
|
70
|
-
|
|
71
|
-
if locator.count > 1
|
|
72
|
-
raise "Multiple elements matching text: '#{text}'" unless args[:match] == :first
|
|
73
|
-
|
|
74
|
-
result = locator.first.click
|
|
75
|
-
else
|
|
76
|
-
result = locator.click
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
pw_page.wait_for_load_state(state: 'networkidle')
|
|
80
|
-
result
|
|
81
|
-
else
|
|
82
|
-
Capybara.click_on(text, **args)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
25
|
end
|
data/lib/rolemodel/version.rb
CHANGED
data/lib/rolemodel-rails.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rolemodel-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- RoleModel Software Inc
|
|
@@ -157,6 +157,11 @@ files:
|
|
|
157
157
|
- lib/generators/rolemodel/github/README.md
|
|
158
158
|
- lib/generators/rolemodel/github/USAGE
|
|
159
159
|
- lib/generators/rolemodel/github/github_generator.rb
|
|
160
|
+
- lib/generators/rolemodel/github/templates/CODEOWNERS
|
|
161
|
+
- lib/generators/rolemodel/github/templates/dependabot.yml
|
|
162
|
+
- lib/generators/rolemodel/github/templates/instructions
|
|
163
|
+
- lib/generators/rolemodel/github/templates/pull_request_template.md
|
|
164
|
+
- lib/generators/rolemodel/github/templates/workflows/ci.yml.tt
|
|
160
165
|
- lib/generators/rolemodel/good_job/README.md
|
|
161
166
|
- lib/generators/rolemodel/good_job/USAGE
|
|
162
167
|
- lib/generators/rolemodel/good_job/good_job_generator.rb
|