2020-03-06 21:33:29 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-04-27 14:07:14 +02:00
|
|
|
require 'bundler/gem_tasks'
|
|
|
|
require 'rspec/core/rake_task'
|
2018-02-23 11:13:28 +01:00
|
|
|
require 'rubocop/rake_task'
|
2018-10-28 12:57:13 +01:00
|
|
|
require 'bundler/audit/task'
|
2013-04-27 14:07:14 +02:00
|
|
|
|
|
|
|
RSpec::Core::RakeTask.new(:spec)
|
2018-02-23 11:13:28 +01:00
|
|
|
RuboCop::RakeTask.new
|
2018-10-28 12:57:13 +01:00
|
|
|
Bundler::Audit::Task.new
|
2013-04-27 14:07:14 +02:00
|
|
|
|
2020-02-28 15:13:28 +01:00
|
|
|
desc 'Run experimental solargraph type checker'
|
2020-08-22 12:20:23 +02:00
|
|
|
task :solargraph do
|
2020-02-28 15:13:28 +01:00
|
|
|
sh 'solargraph typecheck'
|
|
|
|
end
|
|
|
|
|
2020-08-22 12:20:23 +02:00
|
|
|
namespace :solargraph do
|
|
|
|
desc 'Should be run by developer once to prepare initial solargraph usage (fill caches etc.)'
|
|
|
|
task :init do
|
|
|
|
sh 'solargraph download-core'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-16 22:27:22 +02:00
|
|
|
# renovate: datasource=github-tags depName=hadolint/hadolint
|
2021-11-11 02:12:38 +01:00
|
|
|
hadolint_version = 'v2.8.0'
|
2021-04-16 22:27:22 +02:00
|
|
|
|
2021-12-11 22:02:10 +01:00
|
|
|
# renovate: datasource=github-tags depName=aquasecurity/trivy
|
|
|
|
trivy_version = 'v0.21.2'
|
|
|
|
|
|
|
|
namespace :docker do
|
|
|
|
desc 'Lint Dockerfile'
|
|
|
|
task :lint do
|
|
|
|
sh "if [ ! -e ./hadolint ]; then wget -q -O ./hadolint https://github.com/hadolint/hadolint/releases/download/#{hadolint_version}/hadolint-Linux-x86_64; fi"
|
|
|
|
sh 'chmod a+x ./hadolint'
|
|
|
|
sh './hadolint --ignore DL3018 docker/Dockerfile'
|
|
|
|
sh './hadolint --ignore DL3018 --ignore DL3028 docker/ci/Dockerfile'
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Build CI Docker image'
|
|
|
|
task :build do
|
|
|
|
sh 'docker build -t cmur2/dyndnsd:ci -f docker/ci/Dockerfile .'
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Scan CI Docker image for vulnerabilities'
|
|
|
|
task :scan do
|
|
|
|
ver = trivy_version.gsub('v', '')
|
|
|
|
sh "if [ ! -e ./trivy ]; then wget -q -O - https://github.com/aquasecurity/trivy/releases/download/v#{ver}/trivy_#{ver}_Linux-64bit.tar.gz | tar -xzf - trivy; fi"
|
|
|
|
sh './trivy cmur2/dyndnsd:ci'
|
|
|
|
end
|
2020-08-22 12:20:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
task default: [:rubocop, :spec, 'bundle:audit', :solargraph]
|
2020-02-28 15:13:28 +01:00
|
|
|
|
2020-12-25 18:04:59 +01:00
|
|
|
desc 'Run all tasks desired for CI'
|
2021-12-11 22:02:10 +01:00
|
|
|
task ci: ['solargraph:init', :default, 'docker:lint', :build, 'docker:build']
|