|
| 1 | +name: Static Checks (mypy, flake8, black, isort) |
| 2 | + |
| 3 | +on: push |
| 4 | + |
| 5 | +jobs: |
| 6 | + Linting: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + strategy: |
| 9 | + fail-fast: true |
| 10 | + matrix: |
| 11 | + python-version: [3.9] |
| 12 | + steps: |
| 13 | + #---------------------------------------------- |
| 14 | + # check-out repo and set-up python |
| 15 | + #---------------------------------------------- |
| 16 | + - name: Check out repository |
| 17 | + uses: actions/checkout@v3 |
| 18 | + - name: Set up python |
| 19 | + id: setup-python |
| 20 | + uses: actions/setup-python@v3 |
| 21 | + with: |
| 22 | + python-version: 3.9 |
| 23 | + #---------------------------------------------- |
| 24 | + # ----- install & configure poetry ----- |
| 25 | + #---------------------------------------------- |
| 26 | + - name: Load Cached Poetry Installation |
| 27 | + uses: actions/cache@v3 |
| 28 | + with: |
| 29 | + path: ~/.local # the path depends on the OS |
| 30 | + key: poetry-with-dev-0 # increment to reset cache |
| 31 | + - name: Install Poetry |
| 32 | + uses: snok/install-poetry@v1 |
| 33 | + with: |
| 34 | + virtualenvs-create: true |
| 35 | + virtualenvs-in-project: true |
| 36 | + installer-parallel: true |
| 37 | + |
| 38 | + #---------------------------------------------- |
| 39 | + # load cached venv if cache exists |
| 40 | + #---------------------------------------------- |
| 41 | + - name: Load cached venv |
| 42 | + id: cached-poetry-with-dev-dependencies |
| 43 | + uses: actions/cache@v3 |
| 44 | + with: |
| 45 | + path: .venv |
| 46 | + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 47 | + #---------------------------------------------- |
| 48 | + # install dependencies if cache does not exist |
| 49 | + #---------------------------------------------- |
| 50 | + - name: Install dependencies |
| 51 | + if: steps.cached-poetry-with-dev-dependencies.outputs.cache-hit != 'true' |
| 52 | + run: poetry install --no-interaction --no-root |
| 53 | + #---------------------------------------------- |
| 54 | + # Activate virtual environment |
| 55 | + #---------------------------------------------- |
| 56 | + - name: Activate Virtual Environment |
| 57 | + run: source .venv/bin/activate |
| 58 | + #---------------------------------------------- |
| 59 | + # Run MyPY check |
| 60 | + #---------------------------------------------- |
| 61 | + - name: mypy check |
| 62 | + run: poetry run mypy aws_sra_examples |
| 63 | + #---------------------------------------------- |
| 64 | + # Run Flake8 check |
| 65 | + #---------------------------------------------- |
| 66 | + - name: Flake8 Lint |
| 67 | + run: poetry run flake8 aws_sra_examples |
| 68 | + #---------------------------------------------- |
| 69 | + # Run Python Black check |
| 70 | + #---------------------------------------------- |
| 71 | + - name: Black style check |
| 72 | + run: poetry run black --check aws_sra_examples |
| 73 | + #---------------------------------------------- |
| 74 | + # Run isort check |
| 75 | + #---------------------------------------------- |
| 76 | + - name: Imports order check (isort) |
| 77 | + run: poetry run isort --check aws_sra_examples |
0 commit comments