Dzahn has submitted this change and it was merged.
Change subject: Only run puppet-lint against HEAD by default
......................................................................
Only run puppet-lint against HEAD by default
When invoking 'rake test' such as on CI, we end up passing puppet-lint
on every single puppet manifest. That typically takes a couple minutes.
To speed that up we have a Jenkins job that list .pp files changed in
HEAD and only invoke puppet-lint against that small subset. The script
can be found in integration/jenkins.git has git-changed-in-head.sh
Port the Jenkins script to pure ruby directly in the Rakefile.
Add a 'puppetlint_head' tasks that runs puppet on the list of manifests
found in HEAD.
Add an intermediary 'lint_head' task as a convenience.
Change the 'test' task to invoke 'lint_head' instead of 'lint'.
Change-Id: I261e50fb923e0c5b268d8355ada44afeaf599282
---
M Gemfile
M Gemfile.lock
M Rakefile
3 files changed, 26 insertions(+), 1 deletion(-)
Approvals:
Hashar: Looks good to me, but someone else must approve
Dzahn: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Gemfile b/Gemfile
index dae62c9..6a2a44f 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,5 +5,6 @@
gem 'puppetlabs_spec_helper', '< 2.0.0'
gem 'rake', '~> 10.4', '>= 10.4.2'
+gem 'git', '1.3.0'
gem 'puppet-lint', '1.1.0'
gem 'rubocop', '~> 0.35.1', require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index 291a558..5a0fdbe 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -6,6 +6,7 @@
parser (~> 2.2)
diff-lcs (1.2.5)
facter (1.7.6)
+ git (1.3.0)
hiera (1.3.4)
json_pure
json_pure (1.8.3)
@@ -60,6 +61,7 @@
ruby
DEPENDENCIES
+ git (= 1.3.0)
puppet (~> 3.4.3)
puppet-lint (= 1.1.0)
puppetlabs_spec_helper (< 2.0.0)
diff --git a/Rakefile b/Rakefile
index 622390d..67dbc09 100644
--- a/Rakefile
+++ b/Rakefile
@@ -25,8 +25,22 @@
# Continuous integration invokes 'bundle exec rake test'.
require 'bundler/setup'
+require 'git'
require 'puppet-lint/tasks/puppet-lint'
require 'rubocop/rake_task'
+
+# Find files modified in HEAD
+def git_changed_in_head(file_exts=[])
+ g = Git.open('.')
+ diff = g.diff('HEAD^')
+ files = diff.name_status.select { |_, status| 'ACM'.include? status}.keys
+
+ if file_exts.empty?
+ files
+ else
+ files.select { |fname| fname.end_with?(*file_exts) }
+ end
+end
RuboCop::RakeTask.new(:rubocop)
@@ -35,6 +49,11 @@
PuppetLint::RakeTask.new :puppetlint do |config|
config.fail_on_warnings = true # be strict
config.log_format = '%{path}:%{line} %{KIND} %{message} (%{check})'
+end
+PuppetLint::RakeTask.new :puppetlint_head do |config|
+ config.fail_on_warnings = true # be strict
+ config.log_format = '%{path}:%{line} %{KIND} %{message} (%{check})'
+ config.pattern = git_changed_in_head ['.pp']
end
# Only care about color when using a tty.
@@ -60,11 +79,14 @@
task :default => [:help]
desc 'Run all build/tests commands (CI entry point)'
-task test: [:lint]
+task test: [:lint_head]
desc 'Run all linting commands'
task lint: [:rubocop, :puppetlint]
+desc 'Run all linting commands against HEAD'
+task lint_head: [:rubocop, :puppetlint_head]
+
desc 'Show the help'
task :help do
--
To view, visit https://gerrit.wikimedia.org/r/288629
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I261e50fb923e0c5b268d8355ada44afeaf599282
Gerrit-PatchSet: 7
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Hashar <[email protected]>
Gerrit-Reviewer: Dduvall <[email protected]>
Gerrit-Reviewer: Dzahn <[email protected]>
Gerrit-Reviewer: Gehel <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Zfilipin <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits