check-if-migration-is-required.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. name: check if migration is required
  2. on:
  3. pull_request:
  4. paths:
  5. # Matches all python files regardless of directory depth.
  6. - '**.py'
  7. - requirements*.txt
  8. jobs:
  9. main:
  10. name: is migration required
  11. runs-on: ubuntu-16.04
  12. steps:
  13. - uses: actions/checkout@v2
  14. - name: Set python version output
  15. id: python-version
  16. run: |
  17. echo "::set-output name=python-version::$(cat .python-version)"
  18. # Until GH composite actions can use `uses`, we need to setup python here
  19. - uses: actions/setup-python@v2
  20. with:
  21. python-version: ${{ steps.python-version.outputs.python-version }}
  22. - name: Setup pip
  23. uses: ./.github/actions/setup-pip
  24. id: pip
  25. - name: pip cache
  26. uses: actions/cache@v2
  27. with:
  28. path: ${{ steps.pip.outputs.pip-cache-dir }}
  29. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  30. restore-keys: |
  31. ${{ runner.os }}-pip-
  32. - name: Setup sentry env
  33. uses: ./.github/actions/setup-sentry
  34. id: setup
  35. - name: Check if a migration is required
  36. env:
  37. SENTRY_LOG_LEVEL: ERROR
  38. PGPASSWORD: postgres
  39. run: |
  40. # Below will exit with non-zero status if model changes are missing migrations
  41. sentry django makemigrations -n ci_test --check --dry-run --no-input || (echo '::error::Error: Migration required -- to generate a migration, run `sentry django makemigrations -n <some_name>`' && exit 1)