diff --git a/.github/workflows/python-sonar.yml b/.github/workflows/python-sonar.yml index 580d46f1..e378723a 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: @@ -11,6 +15,9 @@ jobs: steps: - uses: actions/checkout@v2 + with: + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v2 @@ -35,25 +42,26 @@ 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: 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: 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` + with: + args: > + -Dsonar.projectDate=${{ env.SONAR_PROJECT_VERSION }} + -Dsonar.projectVersion=${{ env.SONAR_PROJECT_DATE }} diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml deleted file mode 100644 index d71a6fc5..00000000 --- a/.github/workflows/python.yml +++ /dev/null @@ -1,25 +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 - - - run: pipenv run pre-commit run --all-files - name: Run all pre-commit tests