diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml new file mode 100644 index 00000000..d0a30566 --- /dev/null +++ b/.github/workflows/sonar.yaml @@ -0,0 +1,35 @@ +name: Sonar Scan +on: [push, pull_request_target] + +jobs: + sonar: + name: Sonar Scan + runs-on: ubuntu-latest + # always run on push events + # only run on pull_request_target event when pull request pulls from fork repository + if: > + github.event_name == 'push' || + github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v2.1.4 + with: + python-version: 3.9 + + - run: pip install -r requirements.txt + + - run: pip install -e .[dev] + + - run: pytest --cov=yoti_python_sdk yoti_python_sdk/tests --cov-report=xml:coverage-reports/coverage-new.xml + + - run: sed -i 's+.*+/home/travis/build/getyoti/yoti-python-sdk/yoti_python_sdk+g' coverage-reports/coverage-new.xml + + - uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000..ff260478 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,53 @@ +name: Unit Tests +on: [push, pull_request_target] + +jobs: + test: + name: Test (Python ${{ matrix.python-version }}) + runs-on: ubuntu-latest + # always run on push events + # only run on pull_request_target event when pull request pulls from fork repository + if: > + github.event_name == 'push' || + github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository + strategy: + fail-fast: false + matrix: + python-version: [2.7, 3.6, 3.7, 3.8, 3.9, "3.10-dev"] + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2.1.4 + with: + python-version: ${{ matrix.python-version }} + + - run: pip install -U setuptools + + - run: pip install -r requirements.txt + + - run: pip install -e .[dev] + + - run: pytest -v + + examples: + name: Check Examples + runs-on: ubuntu-latest + if: > + github.event_name == 'push' || + github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2.1.4 + + - run: pip install -U setuptools==45 + + - run: pushd examples/aml && pip install -r requirements.txt && popd + + - run: pushd examples/yoti_example_django && pip install -r requirements.txt && popd + + - run: pushd examples/yoti_example_flask && pip install -r requirements.txt && popd + + - run: pushd examples/doc_scan && pip install -r requirements.txt && popd diff --git a/README.md b/README.md index 9c054599..428bdd56 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Yoti Python SDK # -[![Build Status](https://travis-ci.com/getyoti/yoti-python-sdk.svg?branch=master)](https://travis-ci.com/getyoti/yoti-python-sdk) +[![Build Status](https://github.com/getyoti/yoti-python-sdk/workflows/Unit%20Tests/badge.svg?branch=master)](https://github.com/getyoti/yoti-python-sdk/actions) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Apython&metric=coverage)](https://sonarcloud.io/dashboard?id=getyoti%3Apython) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Apython&metric=bugs)](https://sonarcloud.io/dashboard?id=getyoti%3Apython) [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Apython&metric=code_smells)](https://sonarcloud.io/dashboard?id=getyoti%3Apython)