From 9e44f0ef736164d5aa4de6cff4f0ecfcfe425aef Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Tue, 6 Apr 2021 21:54:15 -0400 Subject: [PATCH 1/7] Add sonarqube properties file. --- sonar-project.properties | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..fc6fcfa --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,2 @@ +sonar.projectKey=sprockets_sprockets-statsd +sonar.organization=sprockets From 4cb93c59d513d76e8f138b31d97b7f5aa21d4b1f Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Tue, 6 Apr 2021 22:00:25 -0400 Subject: [PATCH 2/7] Add sonarqube badge. --- README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index d949f58..28e218f 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,6 @@ Asynchronously send metrics to a statsd_ instance. -|build| |coverage| |source| +|build| |coverage| |sonar| |source| .. COMMENTED OUT FOR THE TIME BEING |docs| |download| |license| @@ -131,5 +131,7 @@ not connected to the server and will be sent in the order received when the task :target: https://pypi.org/project/sprockets-statsd/ .. |license| image:: https://img.shields.io/pypi/l/sprockets-statsd.svg?style=social :target: https://github.com/sprockets/sprockets-statsd/blob/master/LICENSE.txt +.. |sonar| image:: https://img.shields.io/sonar/quality_gate/sprockets_sprockets-statsd?server=https%3A%2F%2Fsonarcloud.io&style=social + :target: https://sonarcloud.io/dashboard?id=sprockets_sprockets-statsd .. |source| image:: https://img.shields.io/badge/source-github.com-green.svg?style=social :target: https://github.com/sprockets/sprockets-statsd From 396f66759877a6441cbbfdbb111d6541788ebcba Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Tue, 6 Apr 2021 22:01:46 -0400 Subject: [PATCH 3/7] Add docs badge. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 28e218f..f319cdc 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,6 @@ Asynchronously send metrics to a statsd_ instance. -|build| |coverage| |sonar| |source| +|build| |coverage| |sonar| |docs| |source| .. COMMENTED OUT FOR THE TIME BEING |docs| |download| |license| From 40708fa70c4eaa4641a598a09a866697ff6eeace Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Wed, 7 Apr 2021 07:27:30 -0400 Subject: [PATCH 4/7] Pass coverage.xml to sonar analysis. Since the code doesn't contain any version specific stuff, we don't need to combine coverage output files (thank $diety). --- .github/workflows/run-tests.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 7c6d983..b94d560 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -8,6 +8,7 @@ on: jobs: test: + name: Tests and style checks runs-on: ubuntu-latest strategy: matrix: @@ -34,21 +35,32 @@ jobs: coverage run -m unittest coverage report coverage xml -o ./coverage.xml - - name: Upload coverage + - name: Send coverage to codecov.io uses: codecov/codecov-action@v1.3.2 with: token: ${{secrets.CODECOV_TOKEN}} file: ./coverage.xml flags: unittests fail_ci_if_error: true - verbose: true + - name: Save coverage report + if: ${{ matrix.python-version == "3.9" }} + uses: actions/upload-artifact@v2 + with: + name: coverage.xml + path: ./coverage.xml + sonarcloud: name: SonarCloud runs-on: ubuntu-latest + if: ${{ secrets.SONAR_TOKEN }} steps: - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Download coverage report + uses: actions/download-artifact@v2 + with: + name: coverage.xml - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: From 4986aa28685ced12345e35c5db2ba935ed8f100a Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Wed, 7 Apr 2021 07:29:45 -0400 Subject: [PATCH 5/7] Add more detail in sonar-project.properties. --- sonar-project.properties | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index fc6fcfa..ef18cfd 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,2 +1,10 @@ -sonar.projectKey=sprockets_sprockets-statsd sonar.organization=sprockets +sonar.projectKey=sprockets_sprockets-statsd +sonar.projectName=sprockets-statsd +sonar.links.ci=https://github.com/sprockets/sprockets-statsd/actions/workflows/run-tests.yml +sonar.links.homepage=https://sprockets-statsd.readthedocs.io/en/latest/ +sonar.links.issue=https://github.com/sprockets/sprockets-statsd/issues +sonar.links.scm=https://github.com/sprockets/sprockets-statsd +sonar.inclusions=sprockets_statsd/**/*.py +sonar.test.inclusions=tests/**/*.py +sonar.python.coverage.reportPaths=coverage.xml From 27c357f14a70ba7973da42efe1bd07d9c297addd Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Wed, 7 Apr 2021 07:35:03 -0400 Subject: [PATCH 6/7] Fix workflow syntax error... hopefully --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b94d560..20c84c1 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -43,7 +43,7 @@ jobs: flags: unittests fail_ci_if_error: true - name: Save coverage report - if: ${{ matrix.python-version == "3.9" }} + if: ${{ matrix.python-version == '3.9' }} uses: actions/upload-artifact@v2 with: name: coverage.xml From e35f903744738586bcca0a17fb014f32f5314f20 Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Wed, 7 Apr 2021 07:44:04 -0400 Subject: [PATCH 7/7] Update sonar upload to only run on main. --- .github/workflows/run-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 20c84c1..535e8bc 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -52,7 +52,8 @@ jobs: sonarcloud: name: SonarCloud runs-on: ubuntu-latest - if: ${{ secrets.SONAR_TOKEN }} + if: ${{ github.event == 'push' && github.ref == 'refs/heads/main' }} + needs: test steps: - uses: actions/checkout@v2 with: