diff --git a/.coverage b/.coverage new file mode 100644 index 00000000..1947274b Binary files /dev/null and b/.coverage differ diff --git a/.coveragerc b/.coveragerc index fecdbb13..283a3bfe 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,28 +1,10 @@ -# .coveragerc to control coverage.py +# .coveragerc [run] -branch = True -source = src -# omit = bad_file.py - -[paths] -source = - src/ - */site-packages/ - -[report] -# Regexes for lines to exclude from consideration -exclude_lines = - # Have to re-enable the standard pragma - pragma: no cover - - # Don't complain about missing debug-only code: - def __repr__ - if self\.debug - - # Don't complain if tests don't hit defensive assertion code: - raise AssertionError - raise NotImplementedError - - # Don't complain if non-runnable code isn't run: - if 0: - if __name__ == .__main__.: +relative_files = True +omit = + */__init__.py + *__init__.py + *.py_ + tests/* + */app.py + */venv/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf66c587..1f11d550 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,28 +1,37 @@ -name: CI - -# Controls when the action will run. +name: Build on: push: - branches: [ main ] + branches: + - main pull_request: - branches: [ main ] - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel + types: [opened, synchronize, reopened] jobs: - job1: - name: Pruebas + sonarcloud: + environment: prod + name: SonarCloud runs-on: ubuntu-latest steps: - - name: Checkout de repositorio - uses: actions/checkout@v2 - - name: Configuración de entorno de python - uses: actions/setup-python@v2 - with: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup Python + uses: actions/setup-python@v4 + with: python-version: '3.7' - - name: Instalación de librerías y dependencias - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Correr pruebas - id: correr-pruebas - run: python -m unittest discover -s tests + - name: Instalación de librerías y dependencias + run: pip install -r requirements.txt + - name: Correr pruebas + run: | + python -m coverage run -m unittest discover -s tests -v + python -m coverage xml + - name: Run SonarCloud Scan for ServicioFacturacion + uses: SonarSource/sonarcloud-github-action@v2 + with: + args: > + -Dsonar.organization=langelb-1 + -Dsonar.projectKey=langelb_TutorialCancionesTags + -Dsonar.projectBaseDir=. + -Dsonar.sources=. + -Dsonar.python.coverage.reportPaths=coverage.xml + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 7a880eac..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,86 +0,0 @@ -pipeline { - agent any - environment { - HOME = "${WORKSPACE}" - GIT_CREDENTIAL_ID = '67fc884e-63ed-47cc-8a49-e91b798c7178' - GIT_REPO = 'TutorialCancionesTags' - } - stages { - stage('Checkout') { - steps { - scmSkip(deleteBuild: true, skipPattern:'.*\\[ci-skip\\].*') - git branch: 'main', - credentialsId: env.GIT_CREDENTIAL_ID, - url: 'https://github.com/MISW-4101-Practicas/' + env.GIT_REPO - } - } - stage('Install libraries') { - steps { - script { - docker.image('python:3.7.6').inside { - sh 'pip install --user -r requirements.txt' - } - } - } - } - stage('Testing') { - steps { - script { - docker.image('python:3.7.6').inside { - sh 'python -m unittest discover -s tests -v' - } - } - } - } - stage('Coverage') { - steps { - script { - docker.image('python:3.7.6').inside { - sh ''' - python -m coverage run -m unittest discover -s tests -v - python -m coverage html - ''' - } - } - } - } - stage('Report') { - steps { - publishHTML (target : [allowMissing: false, - alwaysLinkToLastBuild: true, - keepAll: true, - reportDir: 'htmlcov/', - reportFiles: 'index.html', - reportName: 'Coverage Report', - reportTitles: 'Coverage Report'] - ) - } - } - stage('Gitinspector') { - steps { - script { - docker.image('gitinspector-isis2603').inside('--entrypoint=""') { - sh ''' - mkdir -p ./reports/ - gitinspector --file-types="py" --format=html --AxU -w -T -x author:Bocanegra -x author:estudiante > ./reports/index.html - ''' - } - } - withCredentials([usernamePassword(credentialsId: env.GIT_CREDENTIAL_ID, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { - sh('git config --global user.email "ci-isis2603@uniandes.edu.co"') - sh('git config --global user.name "ci-isis2603"') - sh('git add ./reports/index.html') - sh('git commit -m "[ci-skip] GitInspector report added"') - sh('git pull https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/MISW-4101-Practicas/${GIT_REPO} main') - sh('git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/MISW-4101-Practicas/${GIT_REPO} main') - } - } - } - } - post { - always { - // Clean workspace - cleanWs deleteDirs: true - } - } -} diff --git a/README.md b/README.md index 00bcb6e3..9323e2b7 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# test \ No newline at end of file +# test \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 69d16165..8ab936b3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -coverage==5.4 +coverage Faker==5.8.0 -PyQt5==5.15.2 +PyQt5 SQLAlchemy==1.3.22 diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..69597729 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,19 @@ +sonar.projectKey=langelb_TutorialCancionesTags +sonar.organization=langelb-1 +sonar.projectName=TutorialCancionesTags + +sonar.projectBaseDir=. +sonar.sources=. +sonar.python.coverage.reportPaths=coverage.xml +sonar.exclusions=**/tests/**,**/__init__.py,**/app.py,**/users/** + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=TutorialCancionesTags +#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 diff --git a/src/logica/coleccion.py b/src/logica/coleccion.py index a7d9d634..000fcb03 100644 --- a/src/logica/coleccion.py +++ b/src/logica/coleccion.py @@ -163,6 +163,14 @@ def buscar_canciones_por_interprete(self, interprete_nombre): Cancion.interpretes.any(Interprete.nombre.ilike('%{0}%'.format(interprete_nombre)))).all() return canciones + def buscar_canciones_por_interpretes(self, interprete_nombre): + if interprete_nombre == "": + canciones = session.query(Cancion).all() + else: + canciones = session.query(Cancion).filter( + Cancion.interpretes.any(Interprete.nombre.ilike('%{0}%'.format(interprete_nombre)))).all() + return canciones + def asociar_cancion(self, cancion_id, album_id): cancion = session.query(Cancion).filter(Cancion.id == cancion_id).first() album = session.query(Album).filter(Album.id == album_id).first()