Skip to content

Commit

Permalink
Move coverage reporting into image
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Oct 8, 2016
1 parent aefc78b commit 8175ae3
Show file tree
Hide file tree
Showing 130 changed files with 411 additions and 365 deletions.
44 changes: 39 additions & 5 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ print_help() {
EOF
}

report_coverage() {
python "${SMALLTALK_CI_HOME}/lib/coveralls_notifier.py" \
"${SMALLTALK_CI_BUILD}"
}

is_empty() {
local var=$1

Expand Down Expand Up @@ -224,6 +219,45 @@ to_lowercase() {
echo $1 | tr "[:upper:]" "[:lower:]"
}

git_log() {
local format_value=$1
git --no-pager log -1 --pretty=format:"${format_value}"
}

export_coveralls_data() {
local service_name

if is_travis_build; then
service_name="travis-ci"
elif is_appveyor_build; then
service_name="appveyor"
fi

cat >"${SMALLTALK_CI_BUILD}/coveralls_data.json" <<EOL
{
"git": {
"branch": "${TRAVIS_BRANCH:-${APPVEYOR_REPO_BRANCH:-}}",
"head": {
"author_email": "$(git_log "%ae")",
"author_name": "$(git_log "%aN")",
"committer_email": "$(git_log "%ce")",
"committer_name": "$(git_log "%cN")",
"id": "$(git_log "%H")",
"message": "$(git_log "%s")"
},
"remotes": [
{
"url": "https://github.com/${TRAVIS_REPO_SLUG:-${APPVEYOR_REPO_NAME:-}}.git",
"name": "origin"
}
]
},
"service_job_id": "${TRAVIS_JOB_ID:-${APPVEYOR_BUILD_ID:-}}",
"service_name": "${service_name}"
}
EOL
}


################################################################################
# Travis-related helper functions (based on https://git.io/vzcTj).
Expand Down
115 changes: 0 additions & 115 deletions lib/coveralls_notifier.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ baseline: spec
group: 'tests'
with: #('SmalltalkCI-Tests' 'SmalltalkCI-Excluded-Tests');
yourself ].
spec
for: #'squeakCommon'
do: [
spec
project: 'WebClient' with: [
spec
className: 'ConfigurationOfWebClient';
version: #stable;
repository: 'http://www.squeaksource.com/MetacelloRepository' ].
spec
package: 'SmalltalkCI-Core' with: [ spec requires: #('WebClient') ];
yourself ].
spec
for: #'squeak'
do: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"class" : {
},
"instance" : {
"baseline:" : "fn 6/21/2016 21:08" } }
"baseline:" : "fn 10/8/2016 17:39" } }
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(name 'BaselineOfSmalltalkCI-fn.11' message 'Update baseline after restructuring packages' id '51f2c8aa-c47e-4909-a412-8a45a97a2a22' date '22 June 2016' time '12:50:09.923 am' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-fn.10' message 'Adjust after renaming GemStone-specific packages' id 'aa9fcd68-086c-43d7-9579-261a1225eb83' date '13 June 2016' time '9:55:55.954 am' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-fn.9' message 'Update baseline after splitting SmalltalkCI-Pharo into two packages' id 'd46c1fc2-c3be-41af-a93b-3d9bc85b54b5' date '15 April 2016' time '11:42:41.978 pm' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-fn.8' message 'Update baseline after splitting SmalltalkCI-Squeak into two packages' id '75834ab5-c4be-4930-ab74-55d52f3873b4' date '15 April 2016' time '11:12:08.898 pm' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-fn.7' message 'Merge tests into one baseline' id '89c9d6ff-286f-4dd2-8ac6-ee42c6cd0ae9' date '15 April 2016' time '5:04:47.233 pm' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-dkh.6' message '#109 tweak the STON reference from the baseline for Pharo a bit ' id '27db0cf5-16f4-4ef1-89e7-21d7505ad7c0' date '3 April 2016' time '11:57:04 am' author 'dkh' ancestors ((name 'BaselineOfSmalltalkCI-dkh.5' message '#108 first cut at fix for this issue' id 'ebc278d9-ed5c-47cd-9809-13db868abcc4' date '3 April 2016' time '10:35:58 am' author 'dkh' ancestors ((name 'BaselineOfSmalltalkCI-dkh.4' message 'remove the SmalltalkCI-Report package from the baseline' id '919faf31-cf32-4f17-8bd5-bb4459f990f8' date '23 February 2016' time '7:12:25 pm' author 'dkh' ancestors ((name 'BaselineOfSmalltalkCI-dkh.3' message 'PR #51: merge the pharo/squeak BaselineOfSmalltalkCI into the gemstone variant... ' id '91444a03-00df-4abd-a259-121d87a8dc8d' date '23 February 2016' time '6:47:08 am' author 'dkh' ancestors ((name 'BaselineOfSmalltalkCI-TravisCI.2' message 'Issue #48: add SmalltalkCI-Report without porting ...' id 'cc69f0b7-c00a-46d7-8bc1-446a71f4e764' date '4 February 2016' time '4:48:18 pm' author 'TravisCI' ancestors ((name 'BaselineOfSmalltalkCI-dkh.1' message 'initial configuration' id 'd88909e6-d8b8-46c7-b261-09ff40d9be8b' date '4 February 2016' time '12:04:36 pm' author 'dkh' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
(name 'BaselineOfSmalltalkCI-fn.12' message 'Add WebClient dependency' id '3ecfcac6-7857-4362-9bf8-1ba73f3b2dbb' date '8 October 2016' time '5:39:45.204 pm' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-fn.11' message 'Update baseline after restructuring packages' id '51f2c8aa-c47e-4909-a412-8a45a97a2a22' date '22 June 2016' time '12:50:09.923 am' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-fn.10' message 'Adjust after renaming GemStone-specific packages' id 'aa9fcd68-086c-43d7-9579-261a1225eb83' date '13 June 2016' time '9:55:55.954 am' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-fn.9' message 'Update baseline after splitting SmalltalkCI-Pharo into two packages' id 'd46c1fc2-c3be-41af-a93b-3d9bc85b54b5' date '15 April 2016' time '11:42:41.978 pm' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-fn.8' message 'Update baseline after splitting SmalltalkCI-Squeak into two packages' id '75834ab5-c4be-4930-ab74-55d52f3873b4' date '15 April 2016' time '11:12:08.898 pm' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-fn.7' message 'Merge tests into one baseline' id '89c9d6ff-286f-4dd2-8ac6-ee42c6cd0ae9' date '15 April 2016' time '5:04:47.233 pm' author 'fn' ancestors ((name 'BaselineOfSmalltalkCI-dkh.6' message '#109 tweak the STON reference from the baseline for Pharo a bit ' id '27db0cf5-16f4-4ef1-89e7-21d7505ad7c0' date '3 April 2016' time '11:57:04 am' author 'dkh' ancestors ((name 'BaselineOfSmalltalkCI-dkh.5' message '#108 first cut at fix for this issue' id 'ebc278d9-ed5c-47cd-9809-13db868abcc4' date '3 April 2016' time '10:35:58 am' author 'dkh' ancestors ((name 'BaselineOfSmalltalkCI-dkh.4' message 'remove the SmalltalkCI-Report package from the baseline' id '919faf31-cf32-4f17-8bd5-bb4459f990f8' date '23 February 2016' time '7:12:25 pm' author 'dkh' ancestors ((name 'BaselineOfSmalltalkCI-dkh.3' message 'PR #51: merge the pharo/squeak BaselineOfSmalltalkCI into the gemstone variant... ' id '91444a03-00df-4abd-a259-121d87a8dc8d' date '23 February 2016' time '6:47:08 am' author 'dkh' ancestors ((name 'BaselineOfSmalltalkCI-TravisCI.2' message 'Issue #48: add SmalltalkCI-Report without porting ...' id 'cc69f0b7-c00a-46d7-8bc1-446a71f4e764' date '4 February 2016' time '4:48:18 pm' author 'TravisCI' ancestors ((name 'BaselineOfSmalltalkCI-dkh.1' message 'initial configuration' id 'd88909e6-d8b8-46c7-b261-09ff40d9be8b' date '4 February 2016' time '12:04:36 pm' author 'dkh' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
constants
coverallsAPI
^ 'https://coveralls.io/api/v1/jobs'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
constants
coverallsDataFilename
^ 'coveralls_data.json'
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
coverage
compatibility
methodReferenceFor: aClass selector: aSelector
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
coverage
compatibility
packageNameForClass: aClass
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
executing
run: aBlock cover: classesToCover spec: aSmalltalkCISpec in: projectDirectory
^ self new run: aBlock cover: classesToCover spec: aSmalltalkCISpec in: projectDirectory
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
helpers
classesToCover
"This method needs to return an OrderedCollection. TestCoverage wrappers do not initialize correctly for some reason if this returns for example a Set"
spec testing at: #coverage
ifPresent: [ :co | ^ (SmalltalkCI classesFrom: co) asOrderedCollection ]
ifAbsent: [ ^ OrderedCollection new ]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage
helpers
coverageDictFor: aCompiledMethod in: aDirectoryName
| fileName coverageSymbol |
fileName := (self fileNameFor: aCompiledMethod in: aDirectoryName).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
coverageWrappers: anObject

coverageWrappers := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialize-release
coverageWrappersFor: classesToCover
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
coverallsData: anObject

coverallsData := anObject
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage
helpers
fileNameFor: aCompiledMethod in: aDirectoryName
"Generates the filename for the file where the method related to aCompiledMethod is specified in.
aDirectoryName (a String) states the subfolder in the projectDirectory where the method comes from."
Expand All @@ -9,8 +9,8 @@ fileNameFor: aCompiledMethod in: aDirectoryName
ifTrue: [ instanceOrClass := 'class' ]
ifFalse: [ instanceOrClass := 'instance' ].
package := self class packageNameForClass: class.
^ aDirectoryName, self class slash,
package, '.package', self class slash,
class name, '.class', self class slash,
instanceOrClass, self class slash,
^ aDirectoryName, SmalltalkCI pathNameDelimiter,
package, '.package', SmalltalkCI pathNameDelimiter,
class name, '.class', SmalltalkCI pathNameDelimiter,
instanceOrClass, SmalltalkCI pathNameDelimiter,
(method asString replaceAll: $: with: $.), '.st'
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
initialize-release
finishUp
| sourceFiles |
sourceFiles := OrderedCollection new.

coverageWrappers do: [ :wrapper | | directory |
wrapper uninstall.
directory := (spec loading
collect: [ :loadspec |
projectDirectory, SmalltalkCI pathNameDelimiter, loadspec directory ])
detect: [ :dir |
SmalltalkCI platformClass fileExists: (self fileNameFor: wrapper in: dir)]
ifNone: [].
directory ifNotNil: [
sourceFiles add: (self coverageDictFor: wrapper in: directory) ] ].

coverallsData at: 'source_files' put: sourceFiles asArray.
self uploadResults
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialize-release
initialize
coverallsData := self readCoverallsData
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialize-release
installCoverageWrappersFor: classesToCover
coverageWrappers := self coverageWrappersFor: classesToCover.
coverageWrappers do: [ :each | each install ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
coverage
helpers
linesForFile: aFilename
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
coverage
helpers
md5ForFile: aFilename
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
projectDirectory: anObject

projectDirectory := anObject
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
coverage
coverageWrappers
helpers
readCoverallsData
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
executing
run: aBlock cover: classesToCover spec: aSmalltalkCISpec in: aProjectDirectory
spec := aSmalltalkCISpec.
projectDirectory := aProjectDirectory.
self installCoverageWrappersFor: classesToCover.
[ ^ aBlock value ] ensure:
[ self finishUp ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
spec: anObject

spec := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
helpers
uploadResults
| result |
result := WebClient httpPost: self class coverallsAPI multipartFields: {
'json_file' -> (MIMEDocument
contentType: 'application/octet-stream'
content: (STON toJsonString: coverallsData)
url: FileDirectory default url, 'json_file.json')
}.
SmalltalkCI printToStdout: 'Coveralls: ', self content, '(Status: ', self status ,')'
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"class" : {
"coverallsAPI" : "fn 10/8/2016 16:27",
"coverallsDataFilename" : "fn 10/8/2016 15:27",
"methodReferenceFor:selector:" : "fn 10/8/2016 15:10",
"packageNameForClass:" : "fn 10/8/2016 15:11",
"run:cover:spec:in:" : "fn 10/8/2016 15:52" },
"instance" : {
"classesToCover" : "fn 10/8/2016 15:50",
"coverageDictFor:in:" : "fn 10/8/2016 14:53",
"coverageWrappers:" : "fn 10/8/2016 16:48",
"coverageWrappersFor:" : "fn 10/8/2016 15:04",
"coverallsData:" : "fn 10/8/2016 16:48",
"fileNameFor:in:" : "fn 10/8/2016 16:25",
"finishUp" : "fn 10/8/2016 16:26",
"initialize" : "fn 10/8/2016 15:38",
"installCoverageWrappersFor:" : "fn 10/8/2016 16:24",
"linesForFile:" : "fn 10/8/2016 14:52",
"md5ForFile:" : "fn 10/8/2016 14:52",
"projectDirectory:" : "fn 10/8/2016 16:48",
"readCoverallsData" : "fn 10/8/2016 15:26",
"run:cover:spec:in:" : "fn 10/8/2016 15:52",
"spec:" : "fn 10/8/2016 16:48",
"uploadResults" : "fn 10/8/2016 17:24" } }
Loading

0 comments on commit 8175ae3

Please sign in to comment.