diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..1e88a37 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7b984e7 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 }} diff --git a/README.md b/README.md index abdd588..4eada18 100644 --- a/README.md +++ b/README.md @@ -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Ă  diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..4e00536 --- /dev/null +++ b/sonar-project.properties @@ -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