From b9b41fc0c568218a01181be965e2e401612ecc12 Mon Sep 17 00:00:00 2001 From: Mike Terzo Date: Fri, 12 Jan 2018 06:01:21 -0500 Subject: [PATCH 1/2] Update for RuboCop compliance. --- lib/facter/gitlab_systemd.rb | 4 +- spec/acceptance/class_spec.rb | 11 ++--- spec/acceptance/gitlabci_spec.rb | 7 ++- spec/acceptance/travis_ci_acceptance_spec.rb | 49 +++++++++----------- spec/classes/cirunner_spec.rb | 12 ++--- spec/classes/init_spec.rb | 8 ++-- spec/spec_helper_acceptance.rb | 8 ++-- 7 files changed, 43 insertions(+), 56 deletions(-) diff --git a/lib/facter/gitlab_systemd.rb b/lib/facter/gitlab_systemd.rb index d42ba8b2..0178f413 100644 --- a/lib/facter/gitlab_systemd.rb +++ b/lib/facter/gitlab_systemd.rb @@ -1,6 +1,6 @@ # Fact: gitlab_systemd # -# Purpose: +# Purpose: # Determine whether SystemD is the init system on the node # # Resolution: @@ -11,7 +11,7 @@ # Facter.add(:gitlab_systemd) do - confine :kernel => :linux + confine kernel: :linux setcode do Facter::Util::Resolution.exec('ps -p 1 -o comm=') == 'systemd' end diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 6ef29321..0be1cafb 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,10 +1,9 @@ require 'spec_helper_acceptance' describe 'gitlab class' do - context 'default parameters' do # Using puppet_apply as a helper - it 'should work idempotently with no errors' do + it 'idempotently with no errors' do pp = <<-EOS class { 'gitlab': external_url => "http://${::fqdn}", @@ -12,21 +11,19 @@ class { 'gitlab': EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) end describe package('gitlab-ce') do it { is_expected.to be_installed } end - it 'allows http connection on port 8080' do shell 'sleep 15' # give it some time to start up describe command('curl 0.0.0.0:80/users/sign_in') do - its(:stdout) { should match /GitLab|password/ } + its(:stdout) { is_expected.to match %r{/GitLab|password/} } end end - end end diff --git a/spec/acceptance/gitlabci_spec.rb b/spec/acceptance/gitlabci_spec.rb index 8dc53753..4c778abd 100644 --- a/spec/acceptance/gitlabci_spec.rb +++ b/spec/acceptance/gitlabci_spec.rb @@ -1,17 +1,16 @@ require 'spec_helper_acceptance' describe 'gitlab:;cirunner class' do - context 'default parameters' do # Using puppet_apply as a helper - it 'should work idempotently with no errors' do + it 'idempotently with no errors' do pp = <<-EOS class { 'gitlab::cirunner': } EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) end describe package('gitlab-runner') do diff --git a/spec/acceptance/travis_ci_acceptance_spec.rb b/spec/acceptance/travis_ci_acceptance_spec.rb index bfe36c89..fb3c3578 100644 --- a/spec/acceptance/travis_ci_acceptance_spec.rb +++ b/spec/acceptance/travis_ci_acceptance_spec.rb @@ -1,10 +1,9 @@ require 'spec_helper_acceptance' describe 'gitlab class' do - context 'travis specific docker tests' do # Using puppet_apply as a helper - it 'should work idempotently with no errors' do + it 'idempotently with no errors' do pp = <<-EOS class { 'gitlab': external_url => "http://${::fqdn}", @@ -13,12 +12,11 @@ class { 'gitlab': EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) end - it 'should run reconfigure when config changes' do - + it 'reconfigure when config changes' do # gitlab-omnibus works differently in docker # Requires manual kick for travis beaker docker tests docker_workaround = <<-EOS @@ -27,7 +25,7 @@ class { 'gitlab': } EOS - apply_manifest(docker_workaround, :catch_failures => true) + apply_manifest(docker_workaround, catch_failures: true) start_service_pp = <<-EOS class { 'gitlab': @@ -36,8 +34,8 @@ class { 'gitlab': } EOS - apply_manifest(start_service_pp, :catch_failures => true, :show_diff => true) do |r| - expect(r.stdout).to match(/Scheduling refresh of Exec\[gitlab_reconfigure\]/) + apply_manifest(start_service_pp, catch_failures: true, show_diff: true) do |r| + expect(r.stdout).to match(%r{/Scheduling refresh of Exec\[gitlab_reconfigure\]/}) end end @@ -47,31 +45,28 @@ class { 'gitlab': context 'allows http connection on port 80' do describe command('curl 0.0.0.0:80/users/sign_in') do - its(:stdout) { should match /reset_password_token|GitLab/ } + its(:stdout) { is_expected.to match %r{/reset_password_token|GitLab/} } end end end describe 'gitlab::cirunner class' do - context 'basic parameters without docker' do + it 'idempotently with no errors' do + pp = <<-EOS + class { 'gitlab::cirunner': + manage_docker => false, # Running docker in docker in travis breaks things + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end - it 'should work idempotently with no errors' do - pp = <<-EOS - class { 'gitlab::cirunner': - manage_docker => false, # Running docker in docker in travis breaks things - } - EOS - - # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe package('gitlab-runner') do - it { is_expected.to be_installed } + describe package('gitlab-runner') do + it { is_expected.to be_installed } + end end end end - -end diff --git a/spec/classes/cirunner_spec.rb b/spec/classes/cirunner_spec.rb index 03acb7fd..e003e65b 100644 --- a/spec/classes/cirunner_spec.rb +++ b/spec/classes/cirunner_spec.rb @@ -29,9 +29,10 @@ let(:params) { {} } let(:facts) do { - osfamily: 'redhat', + osfamily: 'RedHat', operatingsystem: 'CentOS', operatingsystemmajrelease: '6', + operatingsystemrelease: '6.5', os: { architecture: 'x86_64', family: 'RedHat', @@ -46,9 +47,6 @@ enabled: false } }, - osfamily: 'RedHat', - operatingsystemmajrelease: '6', - operatingsystemrelease: '6.5', kernelversion: '2.6.32', kernelrelease: '2.6.32-573.8.1.el6.x86_64' } @@ -65,9 +63,10 @@ describe 'gitlab::cirunner class OS-independent behavior' do let(:facts) do { - osfamily: 'redhat', + osfamily: 'RedHat', operatingsystem: 'CentOS', operatingsystemmajrelease: '6', + operatingsystemrelease: '6.5', os: { architecture: 'x86_64', family: 'RedHat', @@ -82,9 +81,6 @@ enabled: false } }, - osfamily: 'RedHat', - operatingsystemmajrelease: '6', - operatingsystemrelease: '6.5', kernelversion: '2.6.32', kernelrelease: '2.6.32-573.8.1.el6.x86_64' } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index eb227f46..fb5e3ad9 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -44,7 +44,7 @@ it { is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(/^\s*external_url 'http:\/\/gitlab\.mycompany\.com\/'$/) + with_content(%r{^\s*external_url 'http:\/\/gitlab\.mycompany\.com\/'$}) } end describe 'external_port' do @@ -155,7 +155,7 @@ it { is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(/^\s*gitlab_rails\['backup_path'\] = "\/opt\/gitlab_backup"$/) + with_content(%r{^\s*gitlab_rails\['backup_path'\] = "\/opt\/gitlab_backup"$}) } end describe 'rack_attack_git_basic_auth with Numbers and Strings' do @@ -183,7 +183,7 @@ it { is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(/^\s*mattermost_external_url 'https:\/\/mattermost\.myserver\.tld'$/) + with_content(%r{^\s*mattermost_external_url 'https:\/\/mattermost\.myserver\.tld'$}) } end describe 'mattermost with hash value' do @@ -216,7 +216,7 @@ it do is_expected.to contain_file('/etc/gitlab/gitlab.rb'). - with_content(/^\s*git_data_dirs\(\{\"alt\"\=\>\"\/opt\/data\"\,\s\"default\"=>\"\/var\/opt\/gitlab\/data\"\}\)/) + with_content(%r{^\s*git_data_dirs\(\{\"alt\"\=\>\"\/opt\/data\"\,\s\"default\"=>\"\/var\/opt\/gitlab\/data\"\}\)}) end end describe 'without data_dirs' do diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 41f79813..b067c7b1 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -14,11 +14,11 @@ # Configure all nodes in nodeset c.before :suite do # Install module and dependencies - puppet_module_install(:source => proj_root, :module_name => 'gitlab') + puppet_module_install(source: proj_root, module_name: 'gitlab') hosts.each do |host| - on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0] } - on host, puppet('module', 'install', 'puppetlabs-apt'), { :acceptable_exit_codes => [0] } - on host, puppet('module', 'install', 'garethr-docker'), { :acceptable_exit_codes => [0] } + on host, puppet('module', 'install', 'puppetlabs-stdlib'), acceptable_exit_codes: [0] + on host, puppet('module', 'install', 'puppetlabs-apt'), acceptable_exit_codes: [0] + on host, puppet('module', 'install', 'garethr-docker'), acceptable_exit_codes: [0] end end end From a89fbf7d2de527c595744d2d115ab0d8c7cb9f93 Mon Sep 17 00:00:00 2001 From: Mike Terzo Date: Fri, 12 Jan 2018 06:14:12 -0500 Subject: [PATCH 2/2] Update references CI image for travis --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1a4a136..7b9ec970 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This Puppet module installs and manages [Gitlab](https://about.gitlab.com/). It makes use of the provided [Omnibus](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md) packages and the [packagecloud package repositories](https://packages.gitlab.com/gitlab). -[![Build Status](https://api.travis-ci.org/vshn/puppet-gitlab.svg?branch=master)](https://travis-ci.org/vshn/puppet-gitlab) +[![Build Status](https://api.travis-ci.org/voxpupuli/puppet-gitlab.svg?branch=master)](https://travis-ci.org/voxpupuli/puppet-gitlab) [![vshn-gitlab](https://img.shields.io/puppetforge/v/vshn/gitlab.svg)](https://forge.puppetlabs.com/vshn/gitlab) ## Module Description