|
| 1 | +name: Python Dependency Vulnerability Check with Safety |
| 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-no-dev-2 # 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 | + # load cached venv if cache exists |
| 39 | + #---------------------------------------------- |
| 40 | + - name: Load cached venv |
| 41 | + id: cached-poetry-no-dev-dependencies |
| 42 | + uses: actions/cache@v3 |
| 43 | + with: |
| 44 | + path: .venv |
| 45 | + key: venv-no-dev-dependencies-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 46 | + #---------------------------------------------- |
| 47 | + # install dependencies if cache does not exist |
| 48 | + #---------------------------------------------- |
| 49 | + - name: Install dependencies |
| 50 | + if: steps.cached-poetry-no-dev-dependencies.outputs.cache-hit != 'true' |
| 51 | + run: poetry install --no-dev --no-root |
| 52 | + #---------------------------------------------- |
| 53 | + # Run Safety check |
| 54 | + #---------------------------------------------- |
| 55 | + - name: Safety check |
| 56 | + run: | |
| 57 | + poetry run pip install safety |
| 58 | + poetry run safety check |
0 commit comments