-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
84 lines (72 loc) · 1.97 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
task :default => [:run]
desc "run server (default port 9002)"
task :run do
system %{ go run . }
status = $?&.exitstatus || 1
rescue Interrupt
status = 0
ensure
exit status
end
task :command_exists, [:command] do |_, args|
abort "#{args.command} doesn't exists" if `command -v #{args.command} > /dev/null 2>&1 && echo $?`.chomp.empty?
end
task :is_repo_clean do
abort 'please commit your changes first!' unless `git status -s | wc -l`.strip.to_i.zero?
end
task :has_bump_my_version do
Rake::Task['command_exists'].invoke('bump-my-version')
end
AVAILABLE_REVISIONS = %w[major minor patch].freeze
task :bump, [:revision] => [:has_bump_my_version] do |_, args|
args.with_defaults(revision: 'patch')
unless AVAILABLE_REVISIONS.include?(args.revision)
abort "Please provide valid revision: #{AVAILABLE_REVISIONS.join(',')}"
end
system %{ bump-my-version bump #{args.revision} }
exit $?.exitstatus
end
desc "release new version #{AVAILABLE_REVISIONS.join(',')}, default: patch"
task :release, [:revision] => [:is_repo_clean] do |_, args|
args.with_defaults(revision: 'patch')
Rake::Task['bump'].invoke(args.revision)
end
DOCKER_IMAGE_NAME = "basichttpdebugger:latest"
namespace :docker do
desc "build docker image locally"
task :build do
system %{
GOOS="linux"
GOARCH=$(go env GOARCH)
docker build \
--build-arg="GOOS=${GOOS}" \
--build-arg="GOARCH=${GOARCH}" \
-t #{DOCKER_IMAGE_NAME} .
}
exit $?.exitstatus
end
desc "run docker image locally"
task :run do
system %{
docker run -p "9002:9002" #{DOCKER_IMAGE_NAME}
}
status = $?&.exitstatus || 1
rescue Interrupt
status = 0
ensure
exit status
end
end
desc 'run test'
task :test do
system %{ go test -v -coverprofile=coverage.out ./... }
exit $?.exitstatus
end
desc 'show test coverage'
task :coverage do
system %{
go test -v -coverprofile=coverage.out ./... &&
go tool cover -html=coverage.out
}
exit $?.exitstatus
end