Skip to content

Commit

Permalink
Add Coveralls support
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-lindquist committed Jul 12, 2019
1 parent 90b7bc8 commit c09c8c8
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ install:
build: off

test_script:
- ros -Q -- c:\Users\appveyor\.roswell\local-projects\ci-utils\roswell\run-fiveam.ros -l ci-utils/test :appveyor-tests :base-tests
- ros -Q -- c:\Users\appveyor\.roswell\local-projects\ci-utils\roswell\run-fiveam.ros -l ci-utils/test :appveyor-tests :base-tests :noncoveralls-tests
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
- run: PATH=~/.roswell/bin:$PATH
- run: curl -L https://raw.githubusercontent.com/roswell/roswell/release/scripts/install-for-ci.sh | bash
- run: echo "(:tree \"$CIRCLE_WORKING_DIRECTORY/\")" > "$HOME/.config/common-lisp/source-registry.conf.d/ci.conf"
- run: roswell/run-fiveam.ros -l ci-utils/test :circleci-tests :base-tests
- run: roswell/run-fiveam.ros -l ci-utils/test :circleci-tests :noncoveralls-tests :base-tests
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ env:
- ROSWELL_INSTALL_DIR=$HOME/.roswell
matrix:
- LISP=sbcl-bin
COVERALLS_TEST=:noncoveralls-tests
- LISP=sbcl-bin COVERALLS=true
COVERALLS_TEST=:coveralls-tests
- LISP=abcl
COVERALLS_TEST=:noncoveralls-tests
- LISP=ecl
COVERALLS_TEST=:noncoveralls-tests
- LISP=alisp
COVERALLS_TEST=:noncoveralls-tests
- LISP=ccl-bin
COVERALLS_TEST=:noncoveralls-tests
- LISP=cmucl
COVERALLS_TEST=:noncoveralls-tests

matrix:
fast_finish: true
Expand All @@ -33,4 +41,4 @@ install:
- curl -L https://raw.githubusercontent.com/roswell/roswell/release/scripts/install-for-ci.sh | sh

script:
- roswell/run-fiveam.ros -l ci-utils/test :travis-tests :base-tests
- roswell/run-fiveam.ros -l ci-utils/test :travis-tests $COVERALLS_TEST :base-tests
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ If the `CI` environmental variable is set, then `:ci` is added to `*features*`.
Otherwise, `:not-ci` is added.
In addition, the following platforms are recognized and supported.
If `CI` is set but the platform is unknown, then `:unknown-ci` is added to `*features*`.
Finally, if the `COVERALLS` environmental variable is set, then `:coveralls` is added to `*features*`.

| Platform | Feature | Tested |
|:---------:|:----------:|:------:|
Expand Down
15 changes: 15 additions & 0 deletions ci-utils.asd
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,26 @@
(:file "ci-utils"))
:in-order-to ((test-op (test-op "ci-utils/test"))))

(defsystem "ci-utils/coveralls"
:description "A set of tools for using CI platforms"
:version "0.0.0"
:author "Neil Lindquist <NeilLindquist5@gmail.com>"
:license "MIT"
:defsystem-depends-on ("ci-utils")
:depends-on ("ci-utils"
(:feature :coveralls "cl-coveralls")
"split-sequence")
:pathname "src"
:serial t
:components ((:file "coveralls")))


(defsystem "ci-utils/test"
:description "Test for CI-Utils"
:author "Neil Lindquist <NeilLindquist5@gmail.com>"
:license "MIT"
:depends-on ("ci-utils"
"ci-utils/coveralls"
"fiveam")
:pathname "t"
:components ((:file "tests"))
Expand Down
20 changes: 3 additions & 17 deletions roswell/run-fiveam.ros
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,14 @@ exec ros -Q -- $0 "$@"
; See NOTICES.md for a copy of the license

;cmucl crashes with silent on
(ql:quickload '(:ci-utils :fiveam :iterate) :silent (not (member :cmu *features*)))
(ql:quickload '(:ci-utils :ci-utils/coveralls :fiveam :iterate) :silent (not (member :cmu *features*)))

(defpackage :ros.script.run-fiveam
(:use :cl
:iterate))
(in-package :ros.script.run-fiveam)


(when (uiop:getenv "COVERALLS")
(ql:quickload :cl-coveralls :silent t))


(defmacro apply-coveralls (exclude &rest body)
"Wraps the body with the `with-coveralls` macro if coveralls is enabled"
(if (uiop:getenv "COVERALLS")
`(,(intern (string :with-coveralls) :coveralls) (:exclude ,exclude)
,@body)
`(progn
; Need to manually load the local repository when not using coveralls
(ci-utils:load-project-systems)
,@body)))


(defun show-help ()
(format t "~
Usage: fiveam-run [options] <test cases and suites>...
Expand Down Expand Up @@ -65,6 +50,7 @@ Options
(finally
(when loaded-systems
(ql:quickload loaded-systems))
(apply-coveralls excluded
(setf excluded (nconc excluded (ci-utils/coveralls:coverage-excluded)))
(ci-utils/coveralls:with-coveralls excluded
(unless (fiveam:run! (mapcar 'read-from-string tests))
(uiop:quit 1))))))
25 changes: 25 additions & 0 deletions src/coveralls.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(uiop:define-package :ci-utils/coveralls
(:use :cl
:ci-utils)
(:export #:with-coveralls))

(in-package :ci-utils/coveralls)


(defmacro with-coveralls (exclude &rest body)
"Wraps the body with the `coveralls:with-coveralls` macro if coveralls is enabled"
#+coveralls `(coveralls:with-coveralls (:exclude ,exclude)
,@body)
#-coveralls`(progn
; Need to manually load the local repository when not using coveralls
(ci-utils:load-project-systems)
,@body))

(defun coverage-excluded ()
"Gets the contents of the COVERAGE_EXCLUDED environemental variable as a list
of path strings"
; Copied from Eitaro Fukamachi's run-prove under the terms of the MIT license
; See NOTICE.md for a copy of the license text
(split-sequence:split-sequence #\:
(or (uiop:getenv "COVERAGE_EXCLUDE") "")
:remove-empty-subseqs t))
3 changes: 3 additions & 0 deletions src/features.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
((uiop:getenvp "GITLAB_CI") :gitlab-ci)
(t :unknown-ci))
*features*)))

(when (uiop:getenvp "COVERALLS")
(pushnew :coveralls *features*))
8 changes: 8 additions & 0 deletions t/tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
(signals unknown-ci-platform (service))
(signals unknown-ci-platform (build-dir)))


(test :coveralls-tests
(is-true (member :coveralls *features*))
(is (equal '("tests" "test-launcher.txt") (coverage-excluded))))

(test :noncoveralls-tests
(is-false (member :coveralls *features*)))

(def-suite* :base-tests
:description "The base tests. These tests will fail on a non-CI platform")

Expand Down

0 comments on commit c09c8c8

Please sign in to comment.