Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 46 additions & 29 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ jobs:
distribution: 'zulu'
java-version: '11'

- name: Project version
working-directory: code
run: |
VERSION=$( lein project-version )
echo "::set-output name=version::$VERSION"
id: project_version

- name: Setup Sonar Scanner
uses: warchant/setup-sonar-scanner@v3
with:
Expand All @@ -45,36 +52,46 @@ jobs:
run: sonar-scanner
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }}
-Dsonar.projectVersion=${{ steps.project_version.outputs.version }}
-X

- name: Get list of tests
if: always()
id: tests
uses: Rishabh510/Path-lister-action@master
with:
path: "code/test-reports"
type: ".xml"

- name: Fail on failed tests
if: always()
- name: debug
run: |
sudo apt-get update
sudo apt-get install -y libxml2-utils
echo "Found ${{ steps.tests.outputs.path_count }} test report(s)"
if [[ ${{ steps.tests.outputs.path_count }} < 1 ]]; then
echo "ERROR: No unit test reports collected."
exit 1
fi
for f in ${{ steps.tests.outputs.paths }}; do
echo "=== $f ==="
if [[ $(xmllint --xpath "string(//testsuite/@failures)" $f) > 1 ]]; then
echo TEST FAILED: $f
exit 1
fi
if [[ $(xmllint --xpath "string(//testsuite/@errors)" $f) > 1 ]]; then
echo TEST ERRORED: $f
exit 1
fi
done
echo ---------
cat code/.scannerwork/report-task.txt || true
echo ---------
cat code/test-reports/sonar/testExecutions.xml || true
echo ---------

# - name: Get list of tests
# if: always()
# id: tests
# uses: Rishabh510/Path-lister-action@master
# with:
# path: "code/test-reports/xml"
# type: ".xml"
#
# - name: Fail on failed tests
# if: always()
# run: |
# sudo apt-get update
# sudo apt-get install -y libxml2-utils --fix-missing
# echo "Found ${{ steps.tests.outputs.path_count }} test report(s)"
# if [[ ${{ steps.tests.outputs.path_count }} < 1 ]]; then
# echo "ERROR: No unit test reports collected."
# exit 1
# fi
# for f in ${{ steps.tests.outputs.paths }}; do
# echo "=== $f ==="
# if [[ $(xmllint --xpath "string(//testsuite/@failures)" $f) > 1 ]]; then
# echo TEST FAILED: $f
# exit 1
# fi
# if [[ $(xmllint --xpath "string(//testsuite/@errors)" $f) > 1 ]]; then
# echo TEST ERRORED: $f
# exit 1
# fi
# done

- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@v1.0.0
Expand Down Expand Up @@ -117,7 +134,7 @@ jobs:
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: code/test-reports/TEST-*.xml
files: code/test-reports/xml/TEST-*.xml

job-notify:
if: always()
Expand Down
8 changes: 5 additions & 3 deletions code/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
:url "http://www.apache.org/licenses/LICENSE-2.0.txt"
:distribution :repo}

:plugins [[lein-parent "0.3.5"]]
:plugins [[lein-parent "0.3.5"]
[lein-project-version "0.1.0"]]

:parent-project {:coords [sixsq.nuvla/parent ~parent-version]
:inherit [:plugins
Expand Down Expand Up @@ -41,6 +42,7 @@
:profiles
{:test {:source-paths ["test"]
:resource-paths ["test-resources"]
:plugins [[lein-test-report-junit-xml "0.2.0"]]
:test-report-junit-xml {:output-dir "test-reports"}}
:plugins [[org.clojars.konstan/lein-test-report-sonar "0.0.4"]]
:test-report-sonar {:output-dir "test-reports"
:emit-junit-xml true}}
:dev {:dependencies [[clj-kondo "RELEASE"]]}})
4 changes: 2 additions & 2 deletions code/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ sonar.organization=nuvla
sonar.projectKey=nuvla-ring
sonar.projectName=nuvla-ring
sonar.sources=src,project.clj
sonar.tests=test
sonar.clojure.eastwood.enabled=true
sonar.clojure.kibit.enabled=true
sonar.clojure.kondo.enabled=true
Expand All @@ -11,4 +10,5 @@ sonar.clojure.nvd.enabled=true
sonar.clojure.nvd.json-output-location=target/nvd/dependency-check-report.json
sonar.clojure.cloverage.enabled=true
sonar.clojure.cloverage.json-output-location=target/coverage/codecov.json

sonar.tests=test
sonar.testExecutionReportPaths=test-reports/sonar/testExecutions.xml
13 changes: 13 additions & 0 deletions code/src/sixsq/nuvla/server/error.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns sixsq.nuvla.server.error)

(defn sum
[a b]
(+ a b))

(defn mult
[a b]
(* a b))

(defn sub
[a b]
(- a b))
10 changes: 10 additions & 0 deletions code/test/sixsq/nuvla/server/error_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(ns sixsq.nuvla.server.error-test
(:require
[clojure.test :refer :all]
[sixsq.nuvla.server.error :as e]))

(deftest test-sum-failure
(is (= 3 (e/sum 1 1))))

(deftest test-sum
(is (= 2 (e/sum 1 1))))