|
| 1 | +name: Code Quality Checks |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - v1/main |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - v1/main |
| 9 | +jobs: |
| 10 | + check-linting: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + python-version: [3.8, 3.9, "3.10"] |
| 15 | + steps: |
| 16 | + #---------------------------------------------- |
| 17 | + # check-out repo and set-up python |
| 18 | + #---------------------------------------------- |
| 19 | + - name: Check out repository |
| 20 | + uses: actions/checkout@v2 |
| 21 | + - name: Set up python ${{ matrix.python-version }} |
| 22 | + id: setup-python |
| 23 | + uses: actions/setup-python@v2 |
| 24 | + with: |
| 25 | + python-version: ${{ matrix.python-version }} |
| 26 | + #---------------------------------------------- |
| 27 | + # ----- install & configure poetry ----- |
| 28 | + #---------------------------------------------- |
| 29 | + - name: Install Poetry |
| 30 | + uses: snok/install-poetry@v1 |
| 31 | + with: |
| 32 | + virtualenvs-create: true |
| 33 | + virtualenvs-in-project: true |
| 34 | + installer-parallel: true |
| 35 | + |
| 36 | + #---------------------------------------------- |
| 37 | + # load cached venv if cache exists |
| 38 | + #---------------------------------------------- |
| 39 | + - name: Load cached venv |
| 40 | + id: cached-poetry-dependencies |
| 41 | + uses: actions/cache@v2 |
| 42 | + with: |
| 43 | + path: .venv |
| 44 | + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }} |
| 45 | + #---------------------------------------------- |
| 46 | + # install dependencies if cache does not exist |
| 47 | + #---------------------------------------------- |
| 48 | + - name: Install dependencies |
| 49 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 50 | + run: poetry install --no-interaction --no-root |
| 51 | + #---------------------------------------------- |
| 52 | + # install your root project, if required |
| 53 | + #---------------------------------------------- |
| 54 | + - name: Install library |
| 55 | + run: poetry install --no-interaction |
| 56 | + #---------------------------------------------- |
| 57 | + # black the code |
| 58 | + #---------------------------------------------- |
| 59 | + - name: Black |
| 60 | + run: poetry run black --check src |
| 61 | + |
| 62 | + check-types: |
| 63 | + runs-on: ubuntu-latest |
| 64 | + strategy: |
| 65 | + matrix: |
| 66 | + python-version: [3.8, 3.9, "3.10"] |
| 67 | + steps: |
| 68 | + #---------------------------------------------- |
| 69 | + # check-out repo and set-up python |
| 70 | + #---------------------------------------------- |
| 71 | + - name: Check out repository |
| 72 | + uses: actions/checkout@v2 |
| 73 | + - name: Set up python ${{ matrix.python-version }} |
| 74 | + id: setup-python |
| 75 | + uses: actions/setup-python@v2 |
| 76 | + with: |
| 77 | + python-version: ${{ matrix.python-version }} |
| 78 | + #---------------------------------------------- |
| 79 | + # ----- install & configure poetry ----- |
| 80 | + #---------------------------------------------- |
| 81 | + - name: Install Poetry |
| 82 | + uses: snok/install-poetry@v1 |
| 83 | + with: |
| 84 | + virtualenvs-create: true |
| 85 | + virtualenvs-in-project: true |
| 86 | + installer-parallel: true |
| 87 | + |
| 88 | + #---------------------------------------------- |
| 89 | + # load cached venv if cache exists |
| 90 | + #---------------------------------------------- |
| 91 | + - name: Load cached venv |
| 92 | + id: cached-poetry-dependencies |
| 93 | + uses: actions/cache@v2 |
| 94 | + with: |
| 95 | + path: .venv |
| 96 | + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }} |
| 97 | + #---------------------------------------------- |
| 98 | + # install dependencies if cache does not exist |
| 99 | + #---------------------------------------------- |
| 100 | + - name: Install dependencies |
| 101 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 102 | + run: poetry install --no-interaction --no-root |
| 103 | + #---------------------------------------------- |
| 104 | + # install your root project, if required |
| 105 | + #---------------------------------------------- |
| 106 | + - name: Install library |
| 107 | + run: poetry install --no-interaction |
| 108 | + #---------------------------------------------- |
| 109 | + # mypy the code |
| 110 | + #---------------------------------------------- |
| 111 | + - name: Mypy |
| 112 | + run: | |
| 113 | + mkdir .mypy_cache # Workaround for bad error message "error: --install-types failed (no mypy cache directory)"; see https://github.com/python/mypy/issues/10768#issuecomment-2178450153 |
| 114 | + poetry run mypy --install-types --non-interactive src |
0 commit comments