|
| 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