migrations.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. name: migrations
  2. on:
  3. pull_request:
  4. paths:
  5. - 'src/sentry/migrations/*'
  6. jobs:
  7. sql:
  8. name: Generate SQL
  9. runs-on: ubuntu-16.04
  10. env:
  11. PIP_DISABLE_PIP_VERSION_CHECK: on
  12. SENTRY_LIGHT_BUILD: 1
  13. SENTRY_SKIP_BACKEND_VALIDATION: 1
  14. MIGRATIONS_TEST_MIGRATE: 0
  15. # The hostname used to communicate with the PostgreSQL from sentry
  16. DATABASE_URL: postgresql://postgres:postgres@localhost/sentry
  17. # Use this to override the django version in the requirements file.
  18. DJANGO_VERSION: ">=1.11,<1.12"
  19. services:
  20. postgres:
  21. image: postgres:9.6
  22. env:
  23. POSTGRES_USER: postgres
  24. POSTGRES_PASSWORD: postgres
  25. ports:
  26. # Maps tcp port 5432 on service container to the host
  27. - 5432:5432
  28. # needed because the postgres container does not provide a healthcheck
  29. options: >-
  30. --health-cmd pg_isready
  31. --health-interval 10s
  32. --health-timeout 5s
  33. --health-retries 5
  34. steps:
  35. # Checkout codebase
  36. - uses: actions/checkout@v1
  37. - name: Get changed migration files
  38. id: file
  39. run: |
  40. echo $(git diff --diff-filter=AM --name-only origin/master HEAD)
  41. echo "::set-output name=modified::$(git diff --diff-filter=AM --name-only origin/master HEAD | grep 'src/sentry/migrations/')"
  42. # Python
  43. # Use `.python-version` to avoid duplication
  44. # XXX: can't actually read from .python-version because GitHub Actions
  45. # does not support our version (2.7.16)
  46. #
  47. # XXX: Using `2.7` as GHA image only seems to keep one minor version around and will break
  48. # CI if we pin it to a specific patch version.
  49. - name: Set up outputs
  50. id: config
  51. env:
  52. MATRIX_INSTANCE: ${{ matrix.instance }}
  53. run: |
  54. echo "::set-output name=python-version::2.7"
  55. # setup python
  56. - name: Set up Python ${{ steps.config.outputs.python-version }}
  57. uses: actions/setup-python@v1
  58. with:
  59. python-version: ${{ steps.config.outputs.python-version}}
  60. # setup pip
  61. - name: Install pip
  62. run: |
  63. pip install --no-cache-dir --upgrade "pip>=20.0.2"
  64. # pip cache
  65. - name: Get pip cache dir
  66. id: pip-cache
  67. run: |
  68. echo "::set-output name=dir::$(pip cache dir)"
  69. - name: pip cache
  70. uses: actions/cache@v1
  71. with:
  72. path: ${{ steps.pip-cache.outputs.dir }}
  73. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  74. restore-keys: |
  75. ${{ runner.os }}-pip-
  76. - name: Install System Dependencies
  77. run: |
  78. sudo apt-get update
  79. sudo apt-get install libxmlsec1-dev libmaxminddb-dev
  80. - name: Install Python Dependencies
  81. env:
  82. PGPASSWORD: postgres
  83. run: |
  84. python setup.py install_egg_info
  85. pip install wheel # GitHub Actions does not have this installed by default (unlike Travis)
  86. pip install -U -e ".[dev]"
  87. psql -c 'create database sentry;' -h localhost -U postgres
  88. sentry init
  89. - name: Generate SQL for migration
  90. uses: getsentry/action-migrations@v1.0.7
  91. env:
  92. SENTRY_LOG_LEVEL: ERROR
  93. PGPASSWORD: postgres
  94. with:
  95. githubToken: ${{ secrets.GITHUB_TOKEN }}
  96. migration: ${{ steps.file.outputs.modified }}