action.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # NOTE: Do not rely on `make` commands here as this action is used across different repos
  2. # where the Makefile will not be available
  3. name: 'python setup'
  4. description: 'Configures python, pip, and configures pip cache dir as output.'
  5. inputs:
  6. workdir:
  7. description: 'Directory where the sentry source is located'
  8. required: false
  9. default: '.'
  10. cache-files-hash:
  11. description: 'A single hash for a set of files. Used for caching.'
  12. required: false
  13. default: ${{ hashFiles('requirements-*.txt') }}
  14. pip-cache-version:
  15. description: 'pip cache version in order to bust cache'
  16. required: false
  17. python-version:
  18. description: 'python version to install'
  19. required: false
  20. outputs:
  21. python-version:
  22. description: 'The version of python we are using'
  23. value: ${{ steps.python-version.outputs.python-version }}
  24. pip-cache-dir:
  25. description: 'Path to pip cache'
  26. value: ${{ steps.pip-info.outputs.pip-cache-dir }}
  27. pip-version:
  28. description: 'Pip version'
  29. value: ${{ steps.pip-info.outputs.pip-version }}
  30. runs:
  31. using: 'composite'
  32. steps:
  33. - name: Set python version output
  34. id: python-version
  35. shell: bash
  36. run: |
  37. if [ "${{ inputs.python-version }}" == "" ]; then
  38. echo "::set-output name=python-version::$(cat .python-version)"
  39. else
  40. echo "::set-output name=python-version::${{ inputs.python-version }}"
  41. fi
  42. - name: Setup default environment variables
  43. shell: bash
  44. run: |
  45. echo "PIP_DISABLE_PIP_VERSION_CHECK=on" >> $GITHUB_ENV
  46. - uses: actions/setup-python@v2
  47. env:
  48. PIP_DISABLE_PIP_VERSION_CHECK: on
  49. with:
  50. python-version: ${{ steps.python-version.outputs.python-version }}
  51. - name: Get pip cache dir & version
  52. id: pip-info
  53. shell: bash
  54. env:
  55. WORKDIR: ${{ inputs.workdir }}
  56. # pip versions before 20.1 do not have `pip cache`, `make upgrade-pip` ensures that version as a minimum
  57. run: |
  58. source "$WORKDIR/scripts/lib.sh" && upgrade-pip
  59. echo "::set-output name=pip-cache-dir::$(pip cache dir)"
  60. echo "::set-output name=pip-version::$(pip -V | awk -F ' ' '{print $2}')"
  61. - name: pip cache
  62. uses: actions/cache@v3
  63. with:
  64. path: ${{ steps.pip-info.outputs.pip-cache-dir }}
  65. key: |
  66. ${{ runner.os }}-py${{ steps.python-version.outputs.python-version }}-pip${{ steps.pip-info.outputs.pip-version }}-${{ inputs.pip-cache-version }}-${{ inputs.cache-files-hash }}