From 0dfc8552afd6c86f0d79eb17013d5cdbba813240 Mon Sep 17 00:00:00 2001 From: Aloys Baillet Date: Sat, 17 Oct 2020 20:47:59 +1100 Subject: [PATCH 1/3] Trying testspace Signed-off-by: Aloys Baillet --- .github/workflows/python-sonar.yml | 15 ++++++++++++--- .github/workflows/python.yml | 22 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-sonar.yml b/.github/workflows/python-sonar.yml index 580d46f1..a8ee4199 100644 --- a/.github/workflows/python-sonar.yml +++ b/.github/workflows/python-sonar.yml @@ -11,6 +11,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 50 - name: Set up Python uses: actions/setup-python@v2 @@ -35,9 +37,6 @@ jobs: - name: Run prospector linter run: pipenv run prospector -F python/aswfdocker --output-format xunit > test-prospector-results.xml - - name: Fetch unshallow to help sonar - run: git fetch --unshallow - - name: Install and Run Sonar Scanner env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -57,3 +56,13 @@ jobs: -Dsonar.login=$SONAR_TOKEN \ -Dsonar.projectDate=`git log $tag -n 1 --date=short --pretty="%ad"` \ -Dsonar.projectVersion=`pipenv run python setup.py --version` + if: always() + + - uses: testspace-com/setup-testspace@v1 + with: + domain: aloysbaillet + + - name: Push result to Testspace server + run: | + testspace test*.xml + if: always() diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index d71a6fc5..d35905d5 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -21,5 +21,23 @@ jobs: - run: pipenv install --dev name: Install aswfdocker and dev dependencies with pipenv - - run: pipenv run pre-commit run --all-files - name: Run all pre-commit tests + # python unittests with junit XML report and coverage XML Cobertura report for publishing task + - name: Run pytest + run: pipenv run pytest python/aswfdocker --doctest-modules --junitxml=test-pytest-results.xml --cov=. --cov-report=xml + + # mypy static type checks with junit XML report + - name: Run mypy + run: pipenv run mypy python/aswfdocker --junit-xml=test-mypy-results.xml + + # prospector linter checks with xunit XML report + - name: Run prospector linter + run: pipenv run prospector -F python/aswfdocker --output-format xunit > test-prospector-results.xml + + - uses: testspace-com/setup-testspace@v1 + with: + domain: aloysbaillet + + - name: Push result to Testspace server + run: | + testspace test*.xml + if: always() From b0abbfdf0de2236a7f48d9b8fa66cbfc94936235 Mon Sep 17 00:00:00 2001 From: Aloys Baillet Date: Sat, 17 Oct 2020 22:31:28 +1100 Subject: [PATCH 2/3] Trying to get sonarcloud PR working Signed-off-by: Aloys Baillet --- .github/workflows/python-sonar.yml | 43 ++++++++++++------------------ .github/workflows/python.yml | 43 ------------------------------ 2 files changed, 17 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/python.yml diff --git a/.github/workflows/python-sonar.yml b/.github/workflows/python-sonar.yml index a8ee4199..cb696c7c 100644 --- a/.github/workflows/python-sonar.yml +++ b/.github/workflows/python-sonar.yml @@ -1,9 +1,13 @@ name: Test Python aswfdocker Library - Sonar on: + # Trigger analysis when pushing in master or pull requests, and when creating + # a pull request. push: branches: - master + pull_request: + types: [opened, synchronize, reopened] jobs: sonar: @@ -12,7 +16,8 @@ jobs: steps: - uses: actions/checkout@v2 with: - fetch-depth: 50 + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v2 @@ -37,32 +42,18 @@ jobs: - name: Run prospector linter run: pipenv run prospector -F python/aswfdocker --output-format xunit > test-prospector-results.xml - - name: Install and Run Sonar Scanner + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + if: always() env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - export SONAR_SCANNER_VERSION=4.2.0.1873 - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux - curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - export PATH=$SONAR_SCANNER_HOME/bin:$PATH - export SONAR_SCANNER_OPTS="-server" - sonar-scanner \ - -Dsonar.organization=academysoftwarefoundation \ - -Dsonar.projectKey=AcademySoftwareFoundation_aswf_docker \ - -Dsonar.sources=. \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=$SONAR_TOKEN \ - -Dsonar.projectDate=`git log $tag -n 1 --date=short --pretty="%ad"` \ - -Dsonar.projectVersion=`pipenv run python setup.py --version` - if: always() - - - uses: testspace-com/setup-testspace@v1 with: - domain: aloysbaillet - - - name: Push result to Testspace server - run: | - testspace test*.xml - if: always() + args: > + -Dsonar.organization=academysoftwarefoundation + -Dsonar.projectKey=AcademySoftwareFoundation_aswf_docker + -Dsonar.sources=. + -Dsonar.host.url=https://sonarcloud.io + -Dsonar.login=$SONAR_TOKEN + -Dsonar.projectDate=`git log $tag -n 1 --date=short --pretty="%ad"` + -Dsonar.projectVersion=`pipenv run python setup.py --version` diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml deleted file mode 100644 index d35905d5..00000000 --- a/.github/workflows/python.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Test Python aswfdocker Library - -on: - [push] - -jobs: - python: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - - run: pip3 install pipenv - name: Install pipenv - - - run: pipenv install --dev - name: Install aswfdocker and dev dependencies with pipenv - - # python unittests with junit XML report and coverage XML Cobertura report for publishing task - - name: Run pytest - run: pipenv run pytest python/aswfdocker --doctest-modules --junitxml=test-pytest-results.xml --cov=. --cov-report=xml - - # mypy static type checks with junit XML report - - name: Run mypy - run: pipenv run mypy python/aswfdocker --junit-xml=test-mypy-results.xml - - # prospector linter checks with xunit XML report - - name: Run prospector linter - run: pipenv run prospector -F python/aswfdocker --output-format xunit > test-prospector-results.xml - - - uses: testspace-com/setup-testspace@v1 - with: - domain: aloysbaillet - - - name: Push result to Testspace server - run: | - testspace test*.xml - if: always() From e2f9fbbba3db49e3df686adaf88ee32a3a453188 Mon Sep 17 00:00:00 2001 From: Aloys Baillet Date: Sun, 18 Oct 2020 17:30:51 +1100 Subject: [PATCH 3/3] Fixed up sonar and added report Signed-off-by: Aloys Baillet --- .github/workflows/python-sonar.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-sonar.yml b/.github/workflows/python-sonar.yml index cb696c7c..e378723a 100644 --- a/.github/workflows/python-sonar.yml +++ b/.github/workflows/python-sonar.yml @@ -42,6 +42,19 @@ jobs: - name: Run prospector linter run: pipenv run prospector -F python/aswfdocker --output-format xunit > test-prospector-results.xml + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1.3 + if: always() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + check_name: Unit Test Results + files: "**/test-*.xml" + + - name: Prepare sonar variables + run: | + echo "::set-env name=SONAR_PROJECT_VERSION::`git log $tag -n 1 --date=short --pretty=\"%ad\"`" + echo "::set-env name=SONAR_PROJECT_DATE::`pipenv run python setup.py --version`" + - name: SonarCloud Scan uses: sonarsource/sonarcloud-github-action@master if: always() @@ -50,10 +63,5 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: args: > - -Dsonar.organization=academysoftwarefoundation - -Dsonar.projectKey=AcademySoftwareFoundation_aswf_docker - -Dsonar.sources=. - -Dsonar.host.url=https://sonarcloud.io - -Dsonar.login=$SONAR_TOKEN - -Dsonar.projectDate=`git log $tag -n 1 --date=short --pretty="%ad"` - -Dsonar.projectVersion=`pipenv run python setup.py --version` + -Dsonar.projectDate=${{ env.SONAR_PROJECT_VERSION }} + -Dsonar.projectVersion=${{ env.SONAR_PROJECT_DATE }}