Skip to content

Commit

Permalink
Merge pull request #277 from getyoti/sdk-1853-github-actions
Browse files Browse the repository at this point in the history
SDK-1853: Add github workflows for tests and sonar
  • Loading branch information
emmas-yoti authored Mar 16, 2021
2 parents ae40e85 + 0f18e6e commit 1873e9a
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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+<source>.*</source>+<source>/home/travis/build/getyoti/yoti-python-sdk/yoti_python_sdk</source>+g' coverage-reports/coverage-new.xml

- uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

53 changes: 53 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]

- 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 1873e9a

Please sign in to comment.