gotsha 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f2f8e413b08cc4c531c60d42c0a94d8d2bae874faca37d425fe60812463717d
4
- data.tar.gz: 4be2788036a8dd4c6521d760628e121a4f71225a40a846c597e7c5c9f12d269d
3
+ metadata.gz: 55d7f3b23fbf837a44f3c10ea96f7032191dfba43b8bb93f19ec6dbe7cda27d9
4
+ data.tar.gz: 279ee3f46b1e4ffe687e5ea74bc7b234b3dde5eb9dbff3665bb4530639872ca6
5
5
  SHA512:
6
- metadata.gz: fab24bd0facf01de5495f87287b71c15467d4eff740a39eeb4481915f54ca03fa4524202413d4387cae19204f4275e8288f14403df117b4dff1049019b607ef7
7
- data.tar.gz: dfb3901e72631f08e605926b8c76000cb1965c01c6898b333194f3c63944ea4585cf2e2236708e553cf28c102f640a7a4c0a726894d9be07804f6688b386d4ec
6
+ metadata.gz: f138cbd4c7553b59bdf115a3bb293b558400a7688b4d1015061396f02e7cfc59dc9b5c75189c799a77f1f9488f4e190bc48fbb33b67d532f1cbe5f1c14ddb89f
7
+ data.tar.gz: 31771423505ca2abef9e91371dc2bc8a3ce9ebc5b34e91f56359cadf082934bf5e1b26c833a74db820e06c52a500d6f628d3bc08e88784811e26aef4c47c38a4
data/README.md CHANGED
@@ -1,6 +1,14 @@
1
- # Gotsha — your local CI (alpha coming soon)
1
+ # Gotsha — your local testing CI (alpha version)
2
2
  Pushing untested commits? Gotsha!
3
3
 
4
+ ## Installation
5
+ ```bash
6
+ gem install gotsha # or add `gem "gotsha"` to you Gemfile and run `bundle install`
7
+
8
+ gotsha
9
+ ```
10
+ Then just follow the prompts — Gotsha will guide you through the setup. It won't take more than 3 minutes!
11
+
4
12
  ## What is it?
5
13
  Gotsha is a tiny tool that lets you “sign off” your commit locally: it runs your tests and then stores the test results with the commit SHA (hence the gem name: got-SHA). Your pull request can then be verified against that record, so reviewers know you actually ran the checks before asking for review.
6
14
 
@@ -3,6 +3,8 @@
3
3
  module Gotsha
4
4
  module Actions
5
5
  class Commit
6
+ DESCRIPTION = "creates a dummy commit and runs tests on it"
7
+
6
8
  def call
7
9
  BashCommand.silent_run!('git -c core.hooksPath=/dev/null commit --allow-empty -m "Run Gotsha"')
8
10
 
@@ -3,8 +3,15 @@
3
3
  module Gotsha
4
4
  module Actions
5
5
  class Help
6
+ DESCRIPTION = "shows available commands"
7
+
6
8
  def call
7
- commands = Gotsha::Actions.constants.map(&:downcase).sort.join("\n")
9
+ commands = Gotsha::Actions.constants.map do |command|
10
+ name = command.downcase
11
+ description = Kernel.const_get("Gotsha::Actions::#{command}::DESCRIPTION")
12
+
13
+ "#{name} # #{description}"
14
+ end.sort.join("\n")
8
15
 
9
16
  "Available commands: \n\n#{commands}"
10
17
  end
@@ -3,6 +3,8 @@
3
3
  module Gotsha
4
4
  module Actions
5
5
  class Init
6
+ DESCRIPTION = "first setup"
7
+
6
8
  def call
7
9
  puts "Creating files..."
8
10
 
@@ -3,6 +3,8 @@
3
3
  module Gotsha
4
4
  module Actions
5
5
  class Show
6
+ DESCRIPTION = "shows last commit test results"
7
+
6
8
  def call
7
9
  command = BashCommand.silent_run!("git --no-pager notes --ref=gotsha show")
8
10
 
@@ -3,6 +3,8 @@
3
3
  module Gotsha
4
4
  module Actions
5
5
  class Status
6
+ DESCRIPTION = "displays last commit tests status"
7
+
6
8
  def call
7
9
  last_commit_sha = BashCommand.run!("git --no-pager rev-parse HEAD").text_output
8
10
 
@@ -3,6 +3,8 @@
3
3
  module Gotsha
4
4
  module Actions
5
5
  class Test
6
+ DESCRIPTION = "runs and stores tests (don't use this; prefer autorun via hooks, or `gotsha commit`)"
7
+
6
8
  TESTS_PASSED_NOTE_PREFIX = "Tests passed:"
7
9
  TESTS_FAILED_NOTE_PREFIX = "Tests failed:"
8
10
 
@@ -3,6 +3,8 @@
3
3
  module Gotsha
4
4
  module Actions
5
5
  class Uninstall
6
+ DESCRIPTION = "removes all Gotsha files and configurations"
7
+
6
8
  def call
7
9
  puts "Removing config files..."
8
10
 
@@ -3,18 +3,22 @@
3
3
  module Gotsha
4
4
  class UserConfig
5
5
  def self.get(key)
6
- config = TomlRB.load_file(Config::CONFIG_FILE).transform_keys(&:to_sym)
6
+ config = new.to_h
7
7
 
8
8
  ENV["GOTSHA_#{key.to_s.upcase}"] || # this allows changing config via ENV vars
9
9
  config[key]
10
- rescue Errno::ENOENT
11
- nil
12
10
  end
13
11
 
14
12
  def self.blank?
15
- TomlRB.load_file(Config::CONFIG_FILE).empty?
13
+ new.to_h.empty?
14
+ end
15
+
16
+ def to_h
17
+ TomlRB.load_file(Config::CONFIG_FILE).transform_keys(&:to_sym)
16
18
  rescue Errno::ENOENT
17
- true
19
+ {}
20
+ rescue TomlRB::ParseError => e
21
+ raise Errors::HardFail, "Syntax error in config file\n\n#{e.message}"
18
22
  end
19
23
  end
20
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gotsha
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/web/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <link rel="icon" href="favicon.ico" />
5
5
  <meta charset="utf-8" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <title>Gotsha — your local CI</title>
7
+ <title>Gotsha — your local testing CI</title>
8
8
  <meta name="description" content="Gotsha — sign off your commits locally by running tests & linters and proving it in your PR." />
9
9
  <style>
10
10
  :root{
@@ -91,46 +91,52 @@
91
91
  <!-- Checkmark integrated near 'SHA' -->
92
92
  <path class="stroke" d="M660,120 l35,35 70,-80"/>
93
93
  </svg>
94
- <div class="title">Your local CI</div>
94
+ <div class="title">Your local testing CI</div>
95
95
  </header>
96
96
 
97
97
  <main>
98
98
  <section class="hero" aria-labelledby="hero-title">
99
99
  <h1 id="hero-title">Sign-off your commits locally — and let others see it.</h1>
100
- <p>Run tests & linters on your machine, store results as Git notes, and let your PR show your tests output. Quickly and automatically.</p>
100
+ <p>Run tests & linters on your machine, store complete results, and let your PR show your tests output and status. Quickly and automatically.</p>
101
101
  <div class="actions">
102
- <a class="btn primary" href="https://github.com/melounvitek/gotsha" target="_blank">View more details on Github</a>
102
+ <a class="btn primary" href="https://github.com/melounvitek/gotsha" target="_blank">More details on Github</a>
103
103
  <a class="btn secondary" href="https://github.com/melounvitek/gotsha/pull/35" target="_blank">Demo pull request</a>
104
104
  </div>
105
105
  </section>
106
106
 
107
- <section class="grid">
108
- <article class="card">
107
+ <section class="card" id="install" aria-labelledby="install-title">
108
+ <h2 id="install-title">Install</h3>
109
+ <p>Gotsha is distrubuted as a Ruby gem, so you need to
110
+ have <strong>Ruby</strong> working in your system. Apart from that, the only
111
+ other dependency is <strong>Git</strong>.</p>
112
+ <h3>Install gem</h3>
113
+ <pre><code># Install manually
114
+ gem install gotsha
115
+
116
+ # Or via your Gemfile
117
+ gem 'gotsha'
118
+ </code></pre>
119
+ <h3>Run <code>gotsha</code></h3>
120
+ <p>Then just run <code>gotsha</code> command and follow the prompts — Gotsha will guide you through the setup. It won't take more than 3 minutes!</p>
121
+ </section>
122
+
123
+ <section class="card">
124
+ <h2>How does it work?</h2>
125
+ <article>
109
126
  <h3>1) Runs locally</h3>
110
127
  <p>Gotsha runs the project test suite on your machine. This can happen automatically (for every Git commit or push), or manually; right before you ask for review. You can easily configure it whatever way suits your project best.</p>
111
128
  </article>
112
- <article class="card">
129
+ <article>
113
130
  <h3>2) Stores test results for commit SHA</h3>
114
131
  <p>Test results from every run are attached as <em>Git notes</em> for the recent commit SHA. (Got-SHA... you get it, right?)</p>
115
132
  </article>
116
- <article class="card">
133
+ <article>
117
134
  <h3>3) Displays results in your GitHub PR</h3>
118
135
  <p>Push as usual — the note follows your commit, and tiny Github Action instantly verifies it
119
136
  and makes the tests result visible to reviewers. <a target="_blank" href="https://gotsha.org/failed_build.png">Check it out</a>; it even persist all the colors!</p>
120
137
  </article>
121
138
  </section>
122
139
 
123
- <!--
124
- <section class="card" id="install" aria-labelledby="install-title">
125
- <h3 id="install-title">Install</h3>
126
- <p>Install</p>
127
- <pre><code># RubyGems
128
- gem install gotsha
129
-
130
- # Or add to your Gemfile
131
- gem 'gotsha'</code></pre>
132
- </section>
133
- -->
134
140
 
135
141
  <p class="foot">
136
142
  © <span id="y"></span> <a target="_blank" href="https://x.com/melounvitek">Vítek Meloun</a> (<a target="_blank" href="mailto:vitek@meloun.info">vitek@meloun.info</a>)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gotsha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitek Meloun