diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml new file mode 100644 index 0000000..0f11d9b --- /dev/null +++ b/.github/workflows/PR.yml @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2024 Shell Global Solutions International B.V. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +name: PullRequest + +on: + pull_request: + types: [opened, synchronize, reopened, review_requested] + branches: + - main + +jobs: + CodeFormat: + uses: sede-open/pyELQ/.github/workflows/code_formatting.yml@main + secrets: inherit + + Pydocstyle: + uses: sede-open/pyELQ/.github/workflows/pydocstyle_check.yml@main + needs: CodeFormat + + Pylint: + uses: sede-open/pyELQ/.github/workflows/pylint_check.yml@main + needs: Pydocstyle + + Tests: + uses: sede-open/pyELQ/.github/workflows/run_tests.yml@main + needs: CodeFormat + + SonarCloud: + uses: sede-open/pyELQ/.github/workflows/sonarcloud_analysis.yml@main + needs: Tests + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml index 23956d9..8968b28 100644 --- a/.github/workflows/build_package.yml +++ b/.github/workflows/build_package.yml @@ -3,10 +3,10 @@ # SPDX-License-Identifier: Apache-2.0 name: Building the package + on: - push: - branches: - - 'main' + workflow_call: + jobs: Build: runs-on: ubuntu-latest @@ -15,20 +15,24 @@ jobs: python-version: [ "3.11" ] steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install --upgrade build + pip install --upgrade twine - name: Build the package run: | python -m build - name: Upload build files - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pyelq_whl path: ./dist/*.whl + - name: Upload build files + run: | + twine upload --username __token__ --password ${{ secrets.PYPI_TOKEN }} --verbose dist/* diff --git a/.github/workflows/code_formatting.yml b/.github/workflows/code_formatting.yml index 2d5f965..caa30f8 100644 --- a/.github/workflows/code_formatting.yml +++ b/.github/workflows/code_formatting.yml @@ -3,8 +3,10 @@ # SPDX-License-Identifier: Apache-2.0 name: Code formatting + on: - - push + workflow_call: + jobs: Black: runs-on: ubuntu-latest @@ -14,9 +16,9 @@ jobs: python-version: [ "3.11" ] steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..29d65b0 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,46 @@ +# SPDX-FileCopyrightText: 2024 Shell Global Solutions International B.V. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +name: Main + +on: + push: + branches: + - main + +jobs: + CodeFormat: + uses: sede-open/pyELQ/.github/workflows/code_formatting.yml@main + secrets: inherit + + Pydocstyle: + uses: sede-open/pyELQ/.github/workflows/pydocstyle_check.yml@main + needs: CodeFormat + + Pylint: + uses: sede-open/pyELQ/.github/workflows/pylint_check.yml@main + needs: Pydocstyle + + Tests: + uses: sede-open/pyELQ/.github/workflows/run_tests.yml@main + needs: CodeFormat + + SonarCloud: + uses: sede-open/pyELQ/.github/workflows/sonarcloud_analysis.yml@main + needs: Tests + secrets: inherit + + ReleaseTag: + uses: sede-open/pyELQ/.github/workflows/release_tagging.yml@main + needs: [CodeFormat, Pydocstyle, Pylint, Tests] + secrets: inherit + + Build: + uses: sede-open/pyELQ/.github/workflows/build_package.yml@main + needs: ReleaseTag + secrets: inherit + + PublishDocs: + uses: sede-open/pyELQ/.github/workflows/publish_docs.yml@main + needs: Build \ No newline at end of file diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml index 7c2b12d..110ed7d 100644 --- a/.github/workflows/publish_docs.yml +++ b/.github/workflows/publish_docs.yml @@ -3,20 +3,20 @@ # SPDX-License-Identifier: Apache-2.0 name: publish documentation + on: - push: - branches: - - main + workflow_call: + permissions: contents: write jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: 3.x + python-version: 3.11 - uses: actions/cache@v2 with: key: ${{ github.ref }} diff --git a/.github/workflows/pydocstyle_check.yml b/.github/workflows/pydocstyle_check.yml index 336a187..fb4c362 100644 --- a/.github/workflows/pydocstyle_check.yml +++ b/.github/workflows/pydocstyle_check.yml @@ -3,8 +3,10 @@ # SPDX-License-Identifier: Apache-2.0 name: pydocstyle + on: - - push + workflow_call: + jobs: pydocstyle: runs-on: ubuntu-latest @@ -14,9 +16,9 @@ jobs: python-version: [ "3.11" ] steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/pylint_check.yml b/.github/workflows/pylint_check.yml index 845db8c..0ce6980 100644 --- a/.github/workflows/pylint_check.yml +++ b/.github/workflows/pylint_check.yml @@ -2,10 +2,11 @@ # # SPDX-License-Identifier: Apache-2.0 +name: Pylint Check + on: - - push + workflow_call: -name: Pylint Check jobs: Pylint: # Specify the operating system GitHub has to use to perform the checks (ubuntu seems to be default) @@ -15,9 +16,9 @@ jobs: # Specify all python versions you might want to perform the actions on python-version: ["3.11"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -30,7 +31,7 @@ jobs: run: | python -m pylint `find -regextype egrep -regex '(.*src/pyelq/.*.py)$'` --output-format=parseable:pylint_report.out - name: Upload pylint results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pylint_report path: pylint_report.out diff --git a/.github/workflows/release_tagging.yml b/.github/workflows/release_tagging.yml index aaa0358..7764ccc 100644 --- a/.github/workflows/release_tagging.yml +++ b/.github/workflows/release_tagging.yml @@ -4,16 +4,8 @@ name: ReleaseTag -# Trigger when a python file is changed on main branch either from pull request or push -# but not when only pyproject.toml is changed due to version bump on: - push: - branches: - - 'main' - paths: - - '**.py' - - '!pyproject.toml' - - 'requirements.txt' + workflow_call: jobs: # Releases new Python version when Pull Requests are merged into "main" @@ -26,16 +18,16 @@ jobs: steps: # Checkout - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: persist-credentials: false - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Bump version and commit bumped version back to branch env: - GITHUB_ACCESS_TOKEN: ${{ secrets.PYELQ_TOKEN + GITHUB_ACCESS_TOKEN: ${{ secrets.PYELQ_TOKEN }} id: version run: | version=$(python .github/bump_version.py) diff --git a/.github/workflows/reuse_compliance.yml b/.github/workflows/reuse_compliance.yml index dc08574..0e50374 100644 --- a/.github/workflows/reuse_compliance.yml +++ b/.github/workflows/reuse_compliance.yml @@ -5,13 +5,13 @@ name: REUSE Compliance Check on: - - push + workflow_call: jobs: test: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: REUSE Compliance Check uses: fsfe/reuse-action@v2 \ No newline at end of file diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index f641956..964ccf0 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -3,8 +3,10 @@ # SPDX-License-Identifier: Apache-2.0 name: Run Pytest + on: - - push + workflow_call: + jobs: Build: runs-on: ubuntu-latest @@ -13,15 +15,18 @@ jobs: python-version: [ "3.11" ] steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pytest + pip install pytest==7.4.4 pip install pytest-cov pip install . - name: Unit test with pytest @@ -36,13 +41,13 @@ jobs: # Use always() to always run this step to publish test results when there are test failures if: ${{ always() }} - name: Upload coverage xml results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage_xml path: coverage.xml if: ${{ always() }} - name: Upload coverage junitxml results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pytest_junitxml path: pytest_junit.xml diff --git a/.github/workflows/sonarcloud_analysis.yml b/.github/workflows/sonarcloud_analysis.yml new file mode 100644 index 0000000..14a2f57 --- /dev/null +++ b/.github/workflows/sonarcloud_analysis.yml @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: 2024 Shell Global Solutions International B.V. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +name: SonarCloudAnalysis + +on: + workflow_call: + +jobs: + SonarCloudAnalysis: + runs-on: ubuntu-latest + strategy: + matrix: + # Specify all python versions you might want to perform the actions on + python-version: [ "3.11" ] + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + with: + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.PYELQ_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: Upload SonarCloud Scan Report + uses: actions/upload-artifact@v4 + with: + name: sonar-scan-log + path: .scannerwork/report-task.txt diff --git a/LICENSE.txt b/LICENSE.md similarity index 100% rename from LICENSE.txt rename to LICENSE.md diff --git a/README.md b/README.md index e113b44..3ab2ac7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,23 @@ SPDX-FileCopyrightText: 2024 Shell Global Solutions International B.V. All Right SPDX-License-Identifier: Apache-2.0 --> +
+ +[![PyPI version](https://img.shields.io/pypi/v/pyelq-sdk.svg?logo=pypi&logoColor=FFE873)](https://pypi.org/project/pyelq-sdk/) +[![Supported Python versions](https://img.shields.io/pypi/pyversions/pyelq-sdk.svg?logo=python&logoColor=FFE873)](https://pypi.org/project/pyelq-sdk/) +[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +[![Code Style Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![Tests](https://github.com/sede-open/pyelq/actions/workflows/run_tests.yml/badge.svg?branch=main)](https://github.com/sede-open/pyelq/actions/workflows/run_tests.yml) + +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=pyelq_pyelq&metric=coverage)](https://sonarcloud.io/summary/new_code?id=pyelq_pyelq) +[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=pyelq_pyelq&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=pyelq_pyelq) +[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=pyelq_pyelq&metric=bugs)](https://sonarcloud.io/summary/new_code?id=pyelq_pyelq) +[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=pyelq_pyelq&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=pyelq_pyelq) +[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=pyelq_pyelq&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=pyelq_pyelq) +[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=pyelq_pyelq&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=pyelq_pyelq) +[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=pyelq_pyelq&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=pyelq_pyelq) +[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=pyelq_pyelq&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=pyelq_pyelq) +
# pyELQ This repository contains the Python Emission Localization and Quantification software we call pyELQ. It is code used @@ -58,4 +75,4 @@ For more details on contributing to this repository, see the [Contributing guide *** # Licensing -Distributed under the Apache License Version 2.0. See the [license file](https://github.com/sede-open/pyELQ/blob/main/LICENSE.txt) for more information. +Distributed under the Apache License Version 2.0. See the [license file](https://github.com/sede-open/pyELQ/blob/main/LICENSE.md) for more information. diff --git a/pyproject.toml b/pyproject.toml index 873e749..686f391 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,16 +7,17 @@ requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry] -name = "pyelq" +name = "pyelq-sdk" version = "1.0.0" description = "Package for detection, localization and quantification code." authors = ["Bas van de Kerkhof", "Matthew Jones", "David Randell"] -homepage = "https://github.com/sede-open/pyELQ" +homepage = "https://sede-open.github.io/pyELQ/" repository = "https://github.com/sede-open/pyELQ" -documentation = "https://github.com/sede-open/pyELQ" +documentation = "https://sede-open.github.io/pyELQ/" readme = "README.md" license = "Apache-2.0" keywords = ["gas dispersion", "emission", "detection", "localization", "quantification"] +packages = [{ include = "pyelq", from = "src" }] [tool.poetry.dependencies] python = "~3.11" @@ -38,7 +39,7 @@ black = ">=23.12.1" isort = ">=5.13.2" pydocstyle = ">=6.3.0" pylint = ">=3.0.3" -pytest = ">=7.4.4" +pytest = "<8.0.0" pytest-cov = ">=4.1.0" mkdocs-material = ">=9.5.7" mkdocstrings-python = ">=1.8.0" diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..19fc69b --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2024 Shell Global Solutions International B.V. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +sonar.organization=pyelq +sonar.projectKey=pyelq_pyelq +sonar.host.url=https://sonarcloud.io +sonar.projectName=pyELQ +sonar.sources=src/ +sonar.language=py +sonar.python.version=3 +sonar.python.coverage.reportPaths=coverage.xml +sonar.python.coveragePlugin=cobertura +sonar.python.xunit.reportPath=pytest_junit.xml +sonar.tests=tests +sonar.sourceEncoding=UTF-8 \ No newline at end of file