Skip to content

Commit 60dedfe

Browse files
authored
Merge branch 'master' into resource_validation
2 parents 6e6bd5e + ec42303 commit 60dedfe

File tree

8 files changed

+87
-18
lines changed

8 files changed

+87
-18
lines changed

.travis.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@ script: "script/cibuild"
77
matrix:
88
include:
99
# Build with latest ruby
10-
- rvm: 2.4
11-
env: RUBOCOP_TEST="true" RSPEC_TEST="true"
10+
- rvm: 2.5
11+
env: RUBOCOP_TEST="false" RSPEC_TEST="true" ENFORCE_COVERAGE="true" PUPPET_VERSIONS="3.8.7"
12+
- rvm: 2.5
13+
env: RUBOCOP_TEST="false" RSPEC_TEST="true" ENFORCE_COVERAGE="true" PUPPET_VERSIONS="4.10.8"
14+
- rvm: 2.5
15+
env: RUBOCOP_TEST="true" RSPEC_TEST="true" ENFORCE_COVERAGE="true" PUPPET_VERSIONS="5.0.0"
1216
# Build with older ruby versions
17+
- rvm: 2.4
18+
env: RUBOCOP_TEST="false" RSPEC_TEST="true" PUPPET_VERSIONS="3.8.7"
1319
- rvm: 2.3.2
14-
env: RUBOCOP_TEST="false" RSPEC_TEST="true"
20+
env: RUBOCOP_TEST="false" RSPEC_TEST="true" PUPPET_VERSIONS="4.10.8"
1521
- rvm: 2.2.3
16-
env: RUBOCOP_TEST="false" RSPEC_TEST="true"
22+
env: RUBOCOP_TEST="false" RSPEC_TEST="true" PUPPET_VERSIONS="5.0.0"
1723
- rvm: 2.1
18-
env: RUBOCOP_TEST="false" RSPEC_TEST="true"
24+
env: RUBOCOP_TEST="false" RSPEC_TEST="true" PUPPET_VERSIONS="3.8.7"
25+
- rvm: 2.0
26+
env: RUBOCOP_TEST="false" RSPEC_TEST="true" PUPPET_VERSIONS="3.8.7"
1927
- rvm: 2.0
20-
env: RUBOCOP_TEST="false" RSPEC_TEST="true"
28+
env: RUBOCOP_TEST="false" RSPEC_TEST="true" PUPPET_VERSIONS="5.0.0"

lib/octocatalog-diff/util/util.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def self.object_is_any_of?(object, classes)
2727
def self.safe_dup(object)
2828
object.dup
2929
rescue TypeError
30+
# :nocov:
3031
object
32+
# :nocov:
3133
end
3234

3335
# Utility Method!

octocatalog-diff.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ EOF
3737
s.add_development_dependency 'rubocop', '= 0.48.1'
3838

3939
s.add_development_dependency 'simplecov', '~> 0.14.1'
40-
s.add_development_dependency 'simplecov-json'
40+
s.add_development_dependency 'simplecov-erb', '~> 0.1.1'
4141

4242
puppet_version = ENV['PUPPET_VERSION'] || DEFAULT_PUPPET_VERSION
4343
s.add_development_dependency 'puppet', "~> #{puppet_version}"

script/cibuild

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
# with one or more Puppet versions, with PUPPET_VERSIONS set to a space-separated list
77
# of versions to test.
88

9-
[ -z "$PUPPET_VERSIONS" ] && export PUPPET_VERSIONS='3.8.7 4.10.8 5.0.0'
9+
if [ -z "$PUPPET_VERSIONS" ]; then
10+
echo "Required PUPPET_VERSIONS!"
11+
exit 255
12+
fi
13+
1014
[ -z "$RUBOCOP_TEST" ] && export RUBOCOP_TEST='true'
1115
[ -z "$RSPEC_TEST" ] && export RSPEC_TEST='true'
1216

@@ -19,9 +23,7 @@ env
1923
echo "travis_fold:end:cibuild-environment-dump"
2024

2125
# Create a temporary file to capture output of various steps.
22-
export OUTPUT_FILE="$(mktemp)"
2326
function cleanup() {
24-
rm -rf "$OUTPUT_FILE"
2527
rm -f "${DIR}/.ruby-version"
2628
}
2729
trap cleanup EXIT
@@ -67,6 +69,7 @@ fi
6769
if [ "$RSPEC_TEST" = "true" ]; then
6870
SAVED_PATH="$PATH"
6971
RSPEC_EXITCODE="0"
72+
COVERAGE_EXITCODE="0"
7073
for pv in $PUPPET_VERSIONS ; do
7174
export PUPPET_VERSION="$pv"
7275

@@ -95,23 +98,63 @@ if [ "$RSPEC_TEST" = "true" ]; then
9598
fi
9699

97100
# Run the tests
98-
echo "Running tests"
99-
time bundle exec rake test
101+
echo "Running rspec unit tests"
102+
export COVERAGE=true
103+
time bundle exec rspec "${DIR}/spec/octocatalog-diff/tests"
100104
exitcode=$?
105+
unset COVERAGE
101106
if [ "$exitcode" -ne 0 ]; then RSPEC_EXITCODE="$exitcode"; fi
102-
cat "$OUTPUT_FILE"
107+
108+
# Quick coverage report
109+
cat "$DIR/coverage/coverage.txt"
110+
if grep -q "100% test coverage. You're all set, friend" "$DIR/coverage/coverage.txt"; then
111+
:
112+
else
113+
COVERAGE_EXITCODE=1
114+
fi
103115
echo ""
116+
117+
# To avoid travis getting hung if it gets confused, we'll run each of these
118+
# scripts individually with a timeout. This will hopefully address the problem
119+
# of hung builds.
120+
echo "Running rspec integration tests"
121+
for file in "${DIR}"/spec/octocatalog-diff/integration/*_spec.rb; do
122+
retry=1
123+
for try in 1 2 3 ; do
124+
if [ $retry -eq 1 ]; then
125+
retry=0
126+
echo "$(basename "$file") try ${try}"
127+
"$DIR/script/timeout" 180 bundle exec rspec "$file"
128+
exitcode=$?
129+
if [ $exitcode -eq 124 ] && [ $try -eq 3 ]; then
130+
RSPEC_EXITCODE="255"
131+
elif [ $exitcode -eq 124 ] && [ $try -lt 3 ]; then
132+
retry=1
133+
elif [ $exitcode -ne 0 ]; then
134+
RSPEC_EXITCODE="$exitcode"
135+
fi
136+
fi
137+
done
138+
done
104139
done
105140
export PATH="$SAVED_PATH"
106141
unset PUPPET_VERSION
107142
rm -f "${DIR}/.puppet_version"
108143
else
109144
RSPEC_EXITCODE=-1
145+
COVERAGE_EXITCODE=-1
110146
echo ""
111147
fi
112148

113149
# Finish off script
114150
echo "Finished script/cibuild:"
115-
[ "$RUBOCOP_EXITCODE" -ge 0 ] && echo " - rubocop: exit ${RUBOCOP_EXITCODE}"
116-
[ "$RSPEC_EXITCODE" -ge 0 ] && echo " - rspec: exit ${RSPEC_EXITCODE}"
117-
if [ "$RUBOCOP_EXITCODE" -gt 0 ] || [ "$RSPEC_EXITCODE" -gt 0 ]; then exit 1; else exit 0; fi
151+
[ "$RUBOCOP_EXITCODE" -ge 0 ] && echo " - rubocop: exit ${RUBOCOP_EXITCODE}"
152+
[ "$RSPEC_EXITCODE" -ge 0 ] && echo " - rspec: exit ${RSPEC_EXITCODE}"
153+
[ "$COVERAGE_EXITCODE" -ge 0 ] && echo " - coverage: exit ${COVERAGE_EXITCODE}"
154+
if [ "$RUBOCOP_EXITCODE" -gt 0 ] || [ "$RSPEC_EXITCODE" -gt 0 ]; then
155+
exit 1
156+
fi
157+
if [ "$COVERAGE_EXITCODE" -gt 0 ] && [ "$ENFORCE_COVERAGE" == "true" ]; then
158+
exit 1
159+
fi
160+
exit 0

script/timeout

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'shellwords'
4+
require 'timeout'
5+
6+
seconds = ARGV.shift
7+
raise "Usage: #{__FILE__} <seconds> <command>" unless seconds
8+
begin
9+
Timeout::timeout(seconds.to_i) do
10+
system ARGV.map { |i| Shellwords.escape(i) }.join(" ")
11+
exit $?.exitstatus
12+
end
13+
rescue Timeout::Error
14+
STDERR.puts "Timed out after #{seconds} seconds"
15+
exit 124
16+
end

spec/octocatalog-diff/tests/spec_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
# Enable SimpleCov coverage testing?
88
if ENV['COVERAGE']
99
require 'simplecov'
10-
require 'simplecov-json'
10+
require 'simplecov-erb'
1111
SimpleCov.formatters = [
1212
SimpleCov::Formatter::HTMLFormatter,
13-
SimpleCov::Formatter::JSONFormatter
13+
SimpleCov::Formatter::ERBFormatter
1414
]
1515
SimpleCov.start do
1616
# don't show specs as missing coverage for themselves

vendor/cache/simplecov-erb-0.1.1.gem

5.5 KB
Binary file not shown.

vendor/cache/simplecov-json-0.2.gem

-4.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)