From 9b9bd4e0528d49d69c322a37ee42fbab8829e6e0 Mon Sep 17 00:00:00 2001 From: Yota Toyama Date: Thu, 16 Nov 2017 22:10:17 +0900 Subject: [PATCH] Initialize command code and test --- .circleci/config.yml | 32 ++++++++++++++++++++++ .gitignore | 3 +++ Gemfile | 2 ++ Gemfile.lock | 44 ++++++++++++++++++++++++++++++ examples/aruba.rb | 1 + examples/read.feature | 5 ++++ main.go | 4 +++ rakefile.rb | 63 +++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 154 insertions(+) create mode 100644 .circleci/config.yml create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 examples/aruba.rb create mode 100644 examples/read.feature create mode 100644 main.go create mode 100644 rakefile.rb diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..25837ed --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,32 @@ +version: 2 +jobs: + build: + docker: + - image: golang + working_directory: /go/src/github.com/raviqqe/linkcheck + steps: + - checkout + - run: + name: Setup + command: | + apt -y update --fix-missing + apt -y install rake + apt -y install bundler rake + - run: + name: Dependencies + command: rake deps + - run: + name: Lint + command: rake lint + - run: + name: Unit Test + command: rake unit_test + - run: + name: Command Test + command: rake command_test + - run: + name: Build + command: rake build + - run: + name: Install + command: rake install diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8dd89ca --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +bin +coverage.txt +tmp diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..16dca47 --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'aruba', '~> 0.14.2' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..90c20f0 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,44 @@ +GEM + remote: https://rubygems.org/ + specs: + aruba (0.14.2) + childprocess (~> 0.5.6) + contracts (~> 0.9) + cucumber (>= 1.3.19) + ffi (~> 1.9.10) + rspec-expectations (>= 2.99) + thor (~> 0.19) + builder (3.2.3) + childprocess (0.5.9) + ffi (~> 1.0, >= 1.0.11) + contracts (0.16.0) + cucumber (2.4.0) + builder (>= 2.1.2) + cucumber-core (~> 1.5.0) + cucumber-wire (~> 0.0.1) + diff-lcs (>= 1.1.3) + gherkin (~> 4.0) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.2) + cucumber-core (1.5.0) + gherkin (~> 4.0) + cucumber-wire (0.0.1) + diff-lcs (1.3) + ffi (1.9.18) + gherkin (4.1.3) + multi_json (1.12.1) + multi_test (0.1.2) + rspec-expectations (3.6.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) + thor (0.19.4) + +PLATFORMS + ruby + +DEPENDENCIES + aruba (~> 0.14.2) + +BUNDLED WITH + 1.15.0 diff --git a/examples/aruba.rb b/examples/aruba.rb new file mode 100644 index 0000000..fb0a661 --- /dev/null +++ b/examples/aruba.rb @@ -0,0 +1 @@ +require 'aruba/cucumber' diff --git a/examples/read.feature b/examples/read.feature new file mode 100644 index 0000000..c47d012 --- /dev/null +++ b/examples/read.feature @@ -0,0 +1,5 @@ +Feature: Markdown + Scenario: Check an empty markdown file + Given a file named "foo.md" with "" + When I successfully run `linkcheck foo.md` + Then the stdout should contain exactly "" diff --git a/main.go b/main.go new file mode 100644 index 0000000..da29a2c --- /dev/null +++ b/main.go @@ -0,0 +1,4 @@ +package main + +func main() { +} diff --git a/rakefile.rb b/rakefile.rb new file mode 100644 index 0000000..e5269c6 --- /dev/null +++ b/rakefile.rb @@ -0,0 +1,63 @@ +TOTAL_COVERAGE_FILE = 'coverage.txt'.freeze # This path is specified by codecov. +BIN_PATH = File.absolute_path 'bin' + +task :deps do + sh 'go get github.com/alecthomas/gometalinter github.com/mattn/goveralls' + sh 'gometalinter --install' + sh 'go get -d -t ./...' + sh 'gem install rake rubocop' +end + +task :build do + sh 'go build -o bin/linkcheck' +end + +task :fast_unit_test do + sh 'go test ./...' +end + +task :unit_test do + sh "go test -covermode atomic -coverprofile #{TOTAL_COVERAGE_FILE}" +end + +task command_test: :build do + sh 'bundler install' + sh %W[bundler exec cucumber + -r examples/aruba.rb + PATH=#{BIN_PATH}:$PATH + examples].join ' ' +end + +task test: %i[unit_test command_test] + +task :format do + sh 'go fix ./...' + sh 'go fmt ./...' + + Dir.glob '**/*.go' do |file| + sh "goimports -w #{file}" + end + + sh 'rubocop -a' +end + +task :lint do + sh %w[gometalinter + --disable gocyclo + --disable vetshadow + --enable gofmt + --enable goimports + --enable misspell + ./...].join ' ' + sh 'rubocop' +end + +task install: %i[deps test build] do + sh 'go get ./...' +end + +task default: %i[test build] + +task :clean do + sh 'git clean -dfx' +end