migrations.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. - name: Create placeholder comment
  36. uses: getsentry/action-migrations@v1.0.7
  37. with:
  38. run: placeholder
  39. githubToken: ${{ secrets.GITHUB_TOKEN }}
  40. # Checkout codebase
  41. - uses: actions/checkout@v1
  42. - name: Get changed migration files
  43. id: file
  44. run: |
  45. echo $(git diff --diff-filter=AM --name-only origin/master HEAD)
  46. echo "::set-output name=modified::$(git diff --diff-filter=AM --name-only origin/master HEAD | grep 'src/sentry/migrations/')"
  47. # Python
  48. # Use `.python-version` to avoid duplication
  49. # XXX: can't actually read from .python-version because GitHub Actions
  50. # does not support our version (2.7.16)
  51. #
  52. # XXX: Using `2.7` as GHA image only seems to keep one minor version around and will break
  53. # CI if we pin it to a specific patch version.
  54. - name: Set up outputs
  55. id: config
  56. env:
  57. MATRIX_INSTANCE: ${{ matrix.instance }}
  58. run: |
  59. echo "::set-output name=python-version::2.7"
  60. # setup python
  61. - name: Set up Python ${{ steps.config.outputs.python-version }}
  62. uses: actions/setup-python@v1
  63. with:
  64. python-version: ${{ steps.config.outputs.python-version}}
  65. # setup pip
  66. - name: Install pip
  67. run: |
  68. pip install --no-cache-dir --upgrade "pip>=20.0.2"
  69. # pip cache
  70. - name: Get pip cache dir
  71. id: pip-cache
  72. run: |
  73. echo "::set-output name=dir::$(pip cache dir)"
  74. - name: pip cache
  75. uses: actions/cache@v1
  76. with:
  77. path: ${{ steps.pip-cache.outputs.dir }}
  78. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  79. restore-keys: |
  80. ${{ runner.os }}-pip-
  81. - name: Install System Dependencies
  82. run: |
  83. sudo apt-get update
  84. sudo apt-get install libxmlsec1-dev libmaxminddb-dev
  85. - name: Install Python Dependencies
  86. env:
  87. PGPASSWORD: postgres
  88. run: |
  89. python setup.py install_egg_info
  90. pip install wheel # GitHub Actions does not have this installed by default (unlike Travis)
  91. pip install -U -e ".[dev]"
  92. psql -c 'create database sentry;' -h localhost -U postgres
  93. sentry init
  94. - name: Generate SQL for migration
  95. uses: getsentry/action-migrations@v1.0.7
  96. env:
  97. SENTRY_LOG_LEVEL: ERROR
  98. PGPASSWORD: postgres
  99. with:
  100. githubToken: ${{ secrets.GITHUB_TOKEN }}
  101. migration: ${{ steps.file.outputs.modified }}