Skip to content

Commit

Permalink
Create code-analysis.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
castroricardo1 authored and DaviMarinho committed Dec 11, 2023
1 parent 68ac194 commit d807139
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/.github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Análise de Código
on: push

jobs:
sonarcloud:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- name: Check out repository code
uses: actions/checkout@v4

- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Creating env file
run: |
echo "${{ vars.ENV_FILE }}" > .env
- name: Setup virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: pip install -r requirements.txt

- name: Executa Pytest
run: PYTHONPATH=src python -m coverage run -m pytest --continue-on-collection-errors --junitxml=./junit.xml
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST: localhost
POSTGRES_DB: postgres
POSTGRES_PORT: 5432

- name: Gera arquivos de testes no formato .xml
run: python3 -m coverage xml

- name: Executa SonarCloud Scan
if: ${{ always() }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.API_TOKEN_GITHUB }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 comments on commit d807139

Please sign in to comment.