Skip to content

Commit

Permalink
Merge pull request #1 from ffaraone/configure_actions
Browse files Browse the repository at this point in the history
Add actions and sonar config
  • Loading branch information
ffaraone authored Feb 20, 2024
2 parents 414e729 + bb5da5d commit 3da546b
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish SUD

on:
push:
tags:
- '*'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Linting
run: |
flake8
- name: Testing
run: |
pytest
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT"
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
poetry version ${{ steps.get_version.outputs.VERSION }}
poetry build
poetry publish -u $TWINE_USERNAME -p $TWINE_PASSWORD
68 changes: 68 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Test SUD

on:
push:
branches: '*'
tags: '*'
pull_request:
branches: [ main ]

jobs:
test:
name: "Python ${{ matrix.python-version }}"
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Linting
run: |
flake8
- name: Unit tests
run: |
pytest
sonar:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Generate coverage report
run: |
pytest
- name: Fix coverage.xml for Sonar
run: |
sed -i 's/\/home\/runner\/work\/sud\/sud\//\/github\/workspace\//g' coverage.xml
- name: SonarCloud
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![pyversions](https://img.shields.io/pypi/pyversions/sud.svg) [![PyPi Status](https://img.shields.io/pypi/v/sud.svg)](https://pypi.org/project/sud/) [![Test SUD](https://github.com/ffaraone/sud/actions/workflows/test.yml/badge.svg)](https://github.com/ffaraone/sud/actions/workflows/test.yml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=sud&metric=alert_status)](https://sonarcloud.io/dashboard?id=sud) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=sud&metric=coverage)](https://sonarcloud.io/dashboard?id=sud) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=sud&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=sud)


> Sud nuie simme r'o Sud,
> Sud, Sud nuie simme r'o Sud,
> nuie simme curt' e nire,
> nuie simme buone pe' canta
> e faticamm' a faticà
Expand Down
13 changes: 13 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sonar.projectKey=sud
sonar.organization=ffaraone

sonar.language=py

sonar.sources=sud
sonar.tests=tests
sonar.inclusions=sud/**
sonar.exclusions=tests/**,Dockerfile

sonar.python.coverage.reportPaths=coverage.xml
sonar.python.xunit.reportPath=coverage.xml
sonar.python.version=3

0 comments on commit 3da546b

Please sign in to comment.