migrations.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. services:
  18. postgres:
  19. image: postgres:9.6
  20. env:
  21. POSTGRES_USER: postgres
  22. POSTGRES_PASSWORD: postgres
  23. ports:
  24. # Maps tcp port 5432 on service container to the host
  25. - 5432:5432
  26. # needed because the postgres container does not provide a healthcheck
  27. options: >-
  28. --health-cmd pg_isready
  29. --health-interval 10s
  30. --health-timeout 5s
  31. --health-retries 5
  32. steps:
  33. - name: Install System Dependencies
  34. run: |
  35. sudo apt-get update
  36. sudo apt-get install -y --no-install-recommends \
  37. libxmlsec1-dev \
  38. libmaxminddb-dev
  39. # Checkout codebase
  40. - uses: actions/checkout@v1
  41. - name: Get changed migration files
  42. id: file
  43. run: |
  44. echo $(git diff --diff-filter=AM --name-only origin/master HEAD)
  45. echo "::set-output name=modified::$(git diff --diff-filter=AM --name-only origin/master HEAD | grep 'src/sentry/migrations/')"
  46. # Python
  47. # Use `.python-version` to avoid duplication
  48. # XXX: can't actually read from .python-version because GitHub Actions
  49. # does not support our version (2.7.16)
  50. #
  51. # XXX: Using `2.7` as GHA image only seems to keep one minor version around and will break
  52. # CI if we pin it to a specific patch version.
  53. - name: Set up outputs
  54. id: config
  55. env:
  56. MATRIX_INSTANCE: ${{ matrix.instance }}
  57. run: |
  58. echo "::set-output name=python-version::2.7"
  59. # setup python
  60. - name: Set up Python ${{ steps.config.outputs.python-version }}
  61. uses: actions/setup-python@v1
  62. with:
  63. python-version: ${{ steps.config.outputs.python-version}}
  64. # setup pip
  65. - name: Install pip
  66. run: |
  67. pip install --no-cache-dir --upgrade "pip>=20.0.2"
  68. # pip cache
  69. - name: Get pip cache dir
  70. id: pip-cache
  71. run: |
  72. echo "::set-output name=dir::$(pip cache dir)"
  73. - name: pip cache
  74. uses: actions/cache@v1
  75. with:
  76. path: ${{ steps.pip-cache.outputs.dir }}
  77. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  78. restore-keys: |
  79. ${{ runner.os }}-pip-
  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 }}