diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index d232096..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Build -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] -jobs: - sonarcloud: - name: SonarCloud - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 3cfc3a5..89127e2 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -16,27 +16,37 @@ jobs: build: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - name: Set up Python 3.10 uses: actions/setup-python@v3 with: python-version: "3.10" + fetch-depth: 0 # fetch all history for all branches and tags - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip \ + install -r requirements.txt; fi - name: Lint with flake8 run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest + # stop the build if there are Python syntax \ + errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 \ + --show-source --statistics + # exit-zero treats all errors as warnings. \ + The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 \ + --max-line-length=127 --statistics + - name: Test with pytest # Using --cov=. --cov-report=xml to create a coverage and export it as an xml file run: | - pytest + pytest --cov=. --cov-report=xml + - name: SonarCloud Scan # Add a SonarCloud Scan step to make the connection with SonarCloud + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} build-docker-image: runs-on: ubuntu-latest diff --git a/sonar-project.properties b/sonar-project.properties index 228ff85..fde0ccc 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,13 +1,4 @@ -sonar.projectKey=Nicomatox_Industrialisation-tp2 -sonar.organization=nicomatox - -# This is the name and version displayed in the SonarCloud UI. -#sonar.projectName=Industrialisation-tp2 -#sonar.projectVersion=1.0 - - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 \ No newline at end of file +sonar.python.coverage.reportPaths \ +=coverage.xml +sonar.coverage.exclusions= \ +**/tests/**,**/controller/**,setup.py,test_wheel.py \ No newline at end of file