From 9a698596b173622039dd24cfb5318c6bddc4373f Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Miranda Date: Sat, 19 Jul 2025 18:52:53 -0300 Subject: [PATCH] Update and rename pylint.yml to pylint_sonarqube.yml Add RUFF and SonarQube scanning --- .github/workflows/pylint.yml | 24 ----------- .github/workflows/pylint_sonarqube.yml | 60 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 24 deletions(-) delete mode 100644 .github/workflows/pylint.yml create mode 100644 .github/workflows/pylint_sonarqube.yml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml deleted file mode 100644 index e1e14af..0000000 --- a/.github/workflows/pylint.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Pylint - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.10"] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - pip install pylint - - name: Analysing the code with pylint - run: | - pylint --disable=C0114,C0115,C0116 --exit-zero $(git ls-files '*.py') diff --git a/.github/workflows/pylint_sonarqube.yml b/.github/workflows/pylint_sonarqube.yml new file mode 100644 index 0000000..60d434e --- /dev/null +++ b/.github/workflows/pylint_sonarqube.yml @@ -0,0 +1,60 @@ +name: Pylint and SonarCloud + +on: + push: + branches: [ main, master, staging ] + pull_request: + branches: [ main, master, staging ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10"] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Needed for SonarCloud + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install pylint ruff coverage pytest + + - name: Analysing the code with pylint (console output) + run: | + pylint --disable=C0114,C0115,C0116 --exit-zero $(git ls-files '*.py') + + - name: Generate Pylint report for SonarCloud + run: | + pylint --disable=C0114,C0115,C0116 --output-format=json --exit-zero $(git ls-files '*.py') > pylint-report.json + + - name: Run Ruff + run: | + ruff check --output-format=json . > ruff-report.json || true + + - name: Run tests with coverage (if you have tests) + run: | + if [ -d "tests" ] || [ -f "test_*.py" ] || [ -f "*_test.py" ]; then + coverage run -m pytest || true + coverage xml + fi + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.python.pylint.reportPaths=pylint-report.json + -Dsonar.python.coverage.reportPaths=coverage.xml + -Dsonar.python.ruff.reportPaths=ruff-report.json +