Skip to content

Commit

Permalink
🐛 Add coverage in SonarCloud (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
llaumgui committed May 1, 2024
1 parent f306a76 commit 7dd0cf1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
55 changes: 29 additions & 26 deletions .github/workflows/devops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: DevOps
on:
[push, pull_request]
env:
pythonLastVersion: '3.11'
pythonLastVersion: '3.12'
GHCR_REGISTRY: ghcr.io
IMAGE_NAME: llaumgui/seedboxsync

Expand All @@ -25,17 +25,18 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev-requirements.txt') }}
cache: 'pip'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
run: pip install -r requirements-dev.txt
- name: Make all tests with make
run: make test
run: |
make comply
python -m pytest -v --cov=seedboxsync --cov-report=term --cov-report=xml --capture=sys tests/
- uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: coverage.xml


##############################################################################
# Markdownlint
Expand All @@ -52,6 +53,7 @@ jobs:
files: "*.md docs/*.md"
config_file: ".markdownlint.yaml"


##############################################################################
# Dockerfile tests
#
Expand All @@ -67,6 +69,7 @@ jobs:
with:
recursive: true


##############################################################################
# SonarCloud job
#
Expand All @@ -84,6 +87,14 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/download-artifact@v4
with:
name: coverage-${{ env.pythonLastVersion }}
- name: Display structure of downloaded files
run: |
pwd
ls -R
cat coverage.xml
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
Expand All @@ -93,6 +104,7 @@ jobs:
args: >
-Dsonar.verbose=true
##############################################################################
# Package job
#
Expand All @@ -109,15 +121,9 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ env.pythonLastVersion }}
- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev-requirements.txt') }}
cache: 'pip'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
run: pip install -r requirements-dev.txt
- name: Package
run: make dist
- name: Archive package
Expand All @@ -126,6 +132,7 @@ jobs:
name: seedboxsync-${{ github.sha }}.tar.gz
path: dist/*.tar.gz


##############################################################################
# Build and tests Docker image
#
Expand Down Expand Up @@ -170,6 +177,7 @@ jobs:
with:
sarif_file: 'trivy-results.sarif'


##############################################################################
# Build and deploy job (only on main)
#
Expand Down Expand Up @@ -235,6 +243,7 @@ jobs:
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:latest
cache-to: type=inline


##############################################################################
# Release job
#
Expand All @@ -254,15 +263,9 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ env.pythonLastVersion }}
- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev-requirements.txt') }}
cache: 'pip'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
run: pip install -r requirements-dev.txt
- name: Package
run: make dist
- name: Create GitHub release
Expand Down
3 changes: 1 addition & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sonar.projectName=SeedboxSync
sonar.version=3.0.1

# Project URLs
sonar.host.url=https://sonarcloud.io/dashboard?id=llaumgui%3Aseedboxsync
sonar.host.url=https://sonarcloud.io/project/overview?id=llaumgui_seedboxsync
sonar.links.homepage=https://github.com/llaumgui/seedboxsync
sonar.links.ci=https://github.com/llaumgui/seedboxsync/actions
sonar.links.issue=https://github.com/llaumgui/seedboxsync/issues
Expand All @@ -14,5 +14,4 @@ sonar.links.issue=https://github.com/llaumgui/seedboxsync/issues
sonar.sources=seedboxsync
sonar.tests=tests
sonar.exclusions=tests/**/*,docs/**/*
sonar.python.xunit.reportPath=coverage-report/pytest-report.xml
sonar.python.coverage.reportPaths=coverage.xml

0 comments on commit 7dd0cf1

Please sign in to comment.