Browse Source

New command signature and Dockerfile

master
Christian Aust 4 weeks ago
parent
commit
b42198596e
5 changed files with 57 additions and 7 deletions
  1. +9
    -5
      Dockerfile
  2. +10
    -1
      README.md
  3. +1
    -0
      lib/sanity.rb
  4. +33
    -0
      lib/sanity/options.rb
  5. +4
    -1
      run.rb

+ 9
- 5
Dockerfile View File

@ -5,11 +5,15 @@ LABEL MAINTAINERS="Christian Aust "
RUN apk --no-cache add build-base
COPY Gemfile* /tmp/
RUN gem install bundler && bundle install --gemfile=/tmp/Gemfile --quiet --deployment
RUN gem install bundler && bundle install --gemfile=/tmp/Gemfile --quiet
RUN mkdir /app
COPY run.rb /app/
COPY lib /app/lib
RUN mkdir /usr/local/sanity
COPY run.rb /usr/local/sanity/
COPY lib /usr/local/sanity/lib
RUN adduser --disabled-password --home /app --no-create-home --uid 993 sanity
USER sanity
VOLUME /app
WORKDIR /app
CMD ["/app/run.rb"]
CMD ["/usr/local/sanity/run.rb", "/app/targets.json"]

+ 10
- 1
README.md View File

@ -2,11 +2,20 @@
[![Build Status](https://drone.software-berater.net/api/badges/christian/sanity/status.svg)](https://drone.software-berater.net/christian/sanity) [![Docker pulls](https://img.shields.io/docker/pulls/datenimperator/sanity.svg)](https://hub.docker.com/repository/docker/datenimperator/sanity)
> “Any daily work task that takes 5 minutes will cost over 20 hours a year, or over half of a work week. Even if it takes 20 hours to automate that daily 5 minute task, the automation will break even in a year.”
> “Any daily work task that takes 5 minutes will cost over 20 hours a year, or over half of a work week. Even if it takes 20 hours to automate that daily 5 minute task, the automation will break even in a year.”
> -- Anthony J. Stieber, Breaking into Information Security
Taking care for a running online application requires repetitive, dull little tasks. Check the web server response. See if certificates will expire (or even worse: Already did.) Check the server time. It adds up for one application, and we certainly have more than one. **Sanity** runs sanity checks on targets you define. It's meant to be run by CI pipelines and the like, producing output like a unit test suite.
## Execution
To run the docker image as provided, use this sequence:
1. Create an empty directory
2. Create a file `targets.json` there (see below for examples)
3. Run `docker run -v $(pwd):/app datenimperator/sanity:latest`
4. Test results will be in directory `./run`.
## Implemented checks
* Static web response sanity

+ 1
- 0
lib/sanity.rb View File

@ -4,6 +4,7 @@ module Sanity
VERSION = '0.1.0'
autoload :Assertions, 'sanity/assertions'
autoload :Options, 'sanity/options'
autoload :Result, 'sanity/result'
autoload :Runner, 'sanity/runner'
autoload :Suite, 'sanity/suite'

+ 33
- 0
lib/sanity/options.rb View File

@ -0,0 +1,33 @@
require 'optparse'
module Sanity
class Options
DEFAULTS = {
target: 'targets.json'
}
def initialize(data={})
@data = DEFAULTS.merge(data)
end
def [](key)
@data[key]
end
def self.parse(cmd_line_options)
app_options = Options.new
OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options] TARGETS"
opts.separator ""
opts.on("-h", "--help", "Prints this help") do
puts opts
exit
end
end.parse!(cmd_line_options)
app_options
end
end
end

+ 4
- 1
run.rb View File

@ -8,4 +8,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'sanity'
Sanity::Runner.new('targets.json').check!
options = Sanity::Options.parse(ARGV)
target = ARGV.pop
raise "No target given" unless target
Sanity::Runner.new(target, options).check!

Loading…
Cancel
Save