Skip to content

Commit 39dc1a7

Browse files
committed
OPEN-4147: Added linting and pytest to client repo
1 parent a4979b3 commit 39dc1a7

File tree

16 files changed

+652
-18
lines changed

16 files changed

+652
-18
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Code Validations
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
check-for-python-changes:
7+
runs-on: ubuntu-latest
8+
outputs:
9+
run-python-validations: ${{ steps.changes.outputs.run-python-validations }}
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Get changed files
16+
id: changes
17+
run: |
18+
echo "::set-output name=run-python-validations::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep .py$ | xargs)"
19+
20+
run-checks:
21+
runs-on: ubuntu-latest
22+
needs: check-for-python-changes
23+
if: ${{needs.check-for-python-changes.outputs.run-python-validations}}
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
- name: Set up Python 3.8.12
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: 3.8.12
31+
32+
- uses: actions/cache@v3
33+
id: cache
34+
with:
35+
path: ${{ env.pythonLocation }}
36+
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.cfg') }}--${{ hashFiles('tests/requirements.txt') }}
37+
38+
- name: Install dependencies
39+
if: steps.cache.outputs.cache-hit != 'true'
40+
run: |
41+
python -m pip install --upgrade pip
42+
pip install -e .
43+
pip install -r tests/requirements.txt
44+
45+
- name: Make sure black formatter results in no diff
46+
run: |
47+
black $(git ls-files '*.py') --check
48+
- name: Make sure isort formatter results in no diff
49+
run: |
50+
isort $(git ls-files '*.py') --check
51+
- name: Analyzing the code with pylint
52+
run: |
53+
pylint openlayer tests
54+
- name: Analyzing the code with flake8
55+
run: |
56+
flake8 openlayer tests
57+
# Currently always succeeds because unit tests need to be fixed
58+
- name: Running Pytest
59+
run: |
60+
pytest

0 commit comments

Comments
 (0)