|
| 1 | +--- |
| 2 | +name: Setup |
| 3 | +description: Setup Python and install dependencies. |
| 4 | + |
| 5 | +inputs: |
| 6 | + python_version: |
| 7 | + description: The Python version. |
| 8 | + required: false |
| 9 | + default: '3.11' |
| 10 | + poetry_version: |
| 11 | + description: The Poetry version. |
| 12 | + required: false |
| 13 | + default: '1.5.1' |
| 14 | + install_dependencies: |
| 15 | + description: Install dependencies. |
| 16 | + required: false |
| 17 | + default: 'true' |
| 18 | + |
| 19 | +runs: |
| 20 | + using: composite |
| 21 | + steps: |
| 22 | + - name: Setup Poetry cache on Linux |
| 23 | + uses: actions/cache@v3 |
| 24 | + if: runner.os == 'Linux' |
| 25 | + with: |
| 26 | + key: poetry-${{ inputs.poetry_version }}-${{ inputs.python_version }}-${{ runner.os }}-${{ runner.arch }} |
| 27 | + path: | |
| 28 | + ~/.local/bin |
| 29 | + ~/.local/share/pypoetry |
| 30 | + - name: Setup Poetry cache on macOS |
| 31 | + uses: actions/cache@v3 |
| 32 | + if: runner.os == 'macOS' |
| 33 | + with: |
| 34 | + key: poetry-${{ inputs.poetry_version }}-${{ inputs.python_version }}-${{ runner.os }}-${{ runner.arch }} |
| 35 | + path: | |
| 36 | + ~/.local/bin |
| 37 | + ~/.local/share/pypoetry |
| 38 | + ~/Library/Application Support/pypoetry |
| 39 | + - name: Setup Python |
| 40 | + uses: actions/setup-python@v4 |
| 41 | + with: |
| 42 | + python-version: ${{ inputs.python_version }} |
| 43 | + - name: Setup Poetry |
| 44 | + uses: Gr1N/setup-poetry@v8 |
| 45 | + with: |
| 46 | + poetry-version: ${{ inputs.poetry_version }} |
| 47 | + - name: Setup Python with cache |
| 48 | + uses: actions/setup-python@v4 |
| 49 | + if: inputs.install_dependencies == 'true' |
| 50 | + with: |
| 51 | + cache: poetry |
| 52 | + python-version: ${{ inputs.python_version }} |
| 53 | + - name: Check lockfile |
| 54 | + if: inputs.install_dependencies == 'true' |
| 55 | + shell: bash |
| 56 | + run: poetry lock --check |
| 57 | + - name: Install dependencies |
| 58 | + if: inputs.install_dependencies == 'true' |
| 59 | + shell: bash |
| 60 | + run: poetry install --sync |
0 commit comments