Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup CI and Gem Publishing + better form validation #10

Merged
merged 20 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
91279a4
Add CI file for running specs automatically
Austio Feb 8, 2021
0b8a5ef
Merge remote-tracking branch 'origin' into setup-ci
Austio Feb 11, 2021
7197900
Add standardrb and ci step for this
Austio Feb 11, 2021
0086778
trigger ci
seanriordan08 Feb 11, 2021
ee1f7ae
Change Environmental to Environment in text field description
Austio Feb 11, 2021
4b19f9b
Add feature to filter the table based on the filter table input whene…
Austio Feb 11, 2021
0d4668a
Add light validation to html form for submitting rake tasks
Austio Feb 11, 2021
4eab900
Put actions at the front of tables
Austio Feb 12, 2021
4d1d8ef
Wrap table in div and set word-break so that the columns flow better.
Austio Feb 12, 2021
a2fbcaa
Collapse comment column into task name column
Austio Feb 12, 2021
3b071a3
Adjust CI Config so that it is doing a bundle install instaed of loca…
Austio Feb 12, 2021
b0b796f
Update specificity of tests to not be a personal home directory
Austio Feb 12, 2021
0169747
Tell Rake Task manager to record desc when loading
Austio Feb 12, 2021
1cf21b9
Remove local path desciptions in test files
Austio Feb 12, 2021
708820a
Update README on security, change app controller guard to be a black …
Austio Feb 12, 2021
d785b26
Expose to and from safe_identifier. Update rake_task_test to use sta…
Austio Feb 12, 2021
7e7448c
Remove no-fix from standardrb
Austio Feb 12, 2021
d7d98c6
Add CHANGELOG for 0.0.1 release
Austio Feb 12, 2021
33e40a4
Set gem version for 0.0.1
Austio Feb 12, 2021
80f93a3
Add publish to rubygems step
Austio Feb 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---

version: 2.1

orbs:
gem: doximity/gem-publisher@0

executors:
ruby-latest:
resource_class: small
docker:
- image: circleci/ruby:2.7.2
environment:
BUNDLE_VERSION: "~> 2.2.8"

# yaml anchor filters
master_only: &master_only
filters:
branches:
only: master
tags:
ignore: /.*/
pr_only: &pr_only
filters:
branches:
ignore: master
tags:
ignore: /.*/
version_tags_only: &version_tags_only
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/

jobs:
build:
executor: ruby-latest
steps:
- checkout
- run:
name: Install Bundler specific version
command: |
gem install bundler --version "${BUNDLE_VERSION}" --force
- restore_cache:
keys:
- v1-bundle-{{ checksum "Gemfile.lock" }}-
- run:
name: Install Bundler specific version
command: |
gem install bundler --version "~> 1.17" --force
- run:
name: Install Ruby Dependencies
command: bundle check --path=vendor/bundle || bundle install
- save_cache:
key: v1-bundle-{{ checksum "Gemfile.lock" }}-
paths:
- vendor/bundle
- run:
name: Run Tests
command: bundle exec rake test
- store_test_results:
name: Store test results
path: tmp/test-results
- run:
name: Run StandardRB
command: bundle exec standardrb
- store_artifacts:
name: Saves documentation
path: doc
- persist_to_workspace:
root: .
paths:
- vendor/bundle

workflows:
version: 2

pull-requests:
jobs:
- build:
<<: *pr_only
- gem/build:
executor: ruby-latest
requires:
- build
- pre-release-approval:
type: approval
requires:
- gem/build
- gem/publish:
to_nexus: true
pre_release: true
requires:
- pre-release-approval
context: artifact_publishing

trunk:
jobs:
- build:
<<: *master_only
- gem/build:
executor: ruby-latest
requires:
- build

final-release:
jobs:
- build:
<<: *version_tags_only
- gem/build:
<<: *version_tags_only
executor: ruby-latest
requires:
- build
- gem/publish:
<<: *version_tags_only
name: gem-publish
to_rubygems: true
pre_release: false
requires:
- gem/build
context: artifact_publishing
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.

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).

## [Unreleased]
## [0.0.1]
* Setup CI and Gem Publishing, add better form Validations
[#10](https://github.com/doximity/rake-ui/pull/10)
* Add Search Filtering, Remove Jbuilder and Fix Bug in Dir Existing
[#12](https://github.com/doximity/rake-ui/pull/12)
* Add StandardRB
[#10](https://github.com/doximity/rake-ui/pull/11)
* Fix But with FILE_ITEM_SEPARATOR reference
[#9](https://github.com/doximity/rake-ui/pull/9)
* Add View for Rake Task Logs
[#8](https://github.com/doximity/rake-ui/pull/8)
* Add VitalCSS
[#7](https://github.com/doximity/rake-ui/pull/7)
* Add Ability to track task execution status
[#6](https://github.com/doximity/rake-ui/pull/6)
* Add RakeTaskLog model
[#4](https://github.com/doximity/rake-ui/pull/4)
* Add ability to execute a RakeTask
[#3](https://github.com/doximity/rake-ui/pull/3)
* Add RakeTask Model
[#2](https://github.com/doximity/rake-ui/pull/2)
* Initialize Rake UI Engine
[#1](https://github.com/doximity/rake-ui/pull/1)
31 changes: 30 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rake-ui (0.1.0)
rake-ui (0.0.1)
actionpack
activesupport
railties
Expand Down Expand Up @@ -65,6 +65,7 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
ast (2.4.2)
builder (3.2.4)
coderay (1.1.3)
concurrent-ruby (1.1.8)
Expand Down Expand Up @@ -92,6 +93,9 @@ GEM
racc (~> 1.4)
nokogiri (1.11.1-x86_64-linux)
racc (~> 1.4)
parallel (1.20.1)
parser (3.0.0.0)
ast (~> 2.4.1)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -125,7 +129,25 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
rake (13.0.3)
regexp_parser (2.0.3)
rexml (3.2.4)
rubocop (1.8.1)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.2.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.4.1)
parser (>= 2.7.1.5)
rubocop-performance (1.9.2)
rubocop (>= 0.90.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -134,10 +156,16 @@ GEM
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
standard (0.12.0)
rubocop (= 1.8.1)
rubocop-performance (= 1.9.2)
standardrb (1.0.0)
standard
thor (1.1.0)
thread_safe (0.3.6)
tzinfo (1.2.9)
thread_safe (~> 0.1)
unicode-display_width (2.0.0)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -152,6 +180,7 @@ DEPENDENCIES
rails
rake-ui!
sqlite3
standardrb

BUNDLED WITH
2.2.8
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ Rake UI is a Rails engine that enables the discovery and execution rake tasks in
Add this line to your application's Gemfile:

```ruby
gem 'rake-ui'
group :development do
gem 'rake-ui'
end
```

And then execute:
Expand All @@ -21,10 +23,21 @@ $ gem install rake-ui
once it is installed, mount the engine
```rb
Rails.application.routes.draw do
mount RakeUi::Engine => "/rake-ui"
# only mounting when defined will allow us only include in development/test
if defined? RakeUi::Engine
mount RakeUi::Engine => "/rake-ui"
end
end
```

### Securing RakeUi

This tool is built to enable developer productivity in development. It exposes rake tasks through a UI.

This tool will currently not work in production because we add a guard in the root controller to respond not found if the environment is development or test.

We recommend adding guards in your route to ensure that the proper authentication is in place to ensure that users are authenticated so that if this were ever to be rendered in production, you would be covered. The best way for that is [router constraints](https://guides.rubyonrails.org/routing.html#specifying-constraints)

## Testing

`bundle exec rake test`
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/rake_ui/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module RakeUi
class ApplicationController < ActionController::Base
before_action :guard_not_production
before_action :black_hole_production

private

def guard_not_production
respond :unauthorized unless Rails.env.test? || Rails.env.development?
def black_hole_production
raise ActionController::RoutingError, "Not Found" unless Rails.env.test? || Rails.env.development?
end
end
end
17 changes: 15 additions & 2 deletions app/models/rake_ui/rake_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@

module RakeUi
class RakeTask
def self.to_safe_identifier(id)
CGI.escape(id)
end

def self.from_safe_identifier(id)
CGI.unescape(id)
end

def self.load
# Enables 'desc' to show up as full_comments
if Rake::TaskManager.respond_to? :record_task_metadata
Rake::TaskManager.record_task_metadata = true
end

Rails.application.load_tasks
Rake::Task.tasks
end
Expand All @@ -21,7 +34,7 @@ def self.internal

def self.find_by_id(id)
t = all
i = CGI.unescape(id)
i = from_safe_identifier(id)

t.find do |task|
task.name == i
Expand All @@ -36,7 +49,7 @@ def initialize(task)
end

def id
CGI.escape(name)
RakeUi::RakeTask.to_safe_identifier(name)
end

# actions will be something like #<Proc:0x000055a2737fe778@/some/rails/app/lib/tasks/auto_annotate_models.rake:4>
Expand Down
4 changes: 2 additions & 2 deletions app/models/rake_ui/rake_task_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def self.all

def self.find_by_id(id)
all.find do |a|
a.id == id || a.id == CGI.escape(id)
a.id == id || a.id == RakeUi::RakeTask.to_safe_identifier(id)
end
end

Expand Down Expand Up @@ -139,7 +139,7 @@ def parsed_log_file_name
@parsed_log_file_name ||= {}.tap do |parsed|
date, name = id.split(FILE_DELIMITER, 2)
parsed[:date] = date
parsed[:name] = CGI.unescape(name)
parsed[:name] = RakeUi::RakeTask.from_safe_identifier(name)
end
end

Expand Down
Loading