123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- name: migrations
- on:
- pull_request:
- paths:
- - 'src/sentry/migrations/*'
- jobs:
- sql:
- name: Generate SQL
- runs-on: ubuntu-16.04
- env:
- PIP_DISABLE_PIP_VERSION_CHECK: on
- SENTRY_LIGHT_BUILD: 1
- SENTRY_SKIP_BACKEND_VALIDATION: 1
- MIGRATIONS_TEST_MIGRATE: 0
- # The hostname used to communicate with the PostgreSQL from sentry
- DATABASE_URL: postgresql://postgres:postgres@localhost/sentry
- services:
- postgres:
- image: postgres:9.6
- env:
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: postgres
- ports:
- # Maps tcp port 5432 on service container to the host
- - 5432:5432
- # needed because the postgres container does not provide a healthcheck
- options: >-
- --health-cmd pg_isready
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
- steps:
- - name: Install System Dependencies
- run: |
- sudo apt-get update
- sudo apt-get install -y --no-install-recommends \
- libxmlsec1-dev \
- libmaxminddb-dev
- # Checkout codebase
- - uses: actions/checkout@v1
- - name: Get changed migration files
- id: file
- run: |
- echo $(git diff --diff-filter=AM --name-only origin/master HEAD)
- echo "::set-output name=modified::$(git diff --diff-filter=AM --name-only origin/master HEAD | grep 'src/sentry/migrations/')"
- # Python
- # Use `.python-version` to avoid duplication
- # XXX: can't actually read from .python-version because GitHub Actions
- # does not support our version (2.7.16)
- #
- # XXX: Using `2.7` as GHA image only seems to keep one minor version around and will break
- # CI if we pin it to a specific patch version.
- - name: Set up outputs
- id: config
- env:
- MATRIX_INSTANCE: ${{ matrix.instance }}
- run: |
- echo "::set-output name=python-version::2.7"
- # setup python
- - name: Set up Python ${{ steps.config.outputs.python-version }}
- uses: actions/setup-python@v1
- with:
- python-version: ${{ steps.config.outputs.python-version}}
- # setup pip
- - name: Install pip
- run: |
- pip install --no-cache-dir --upgrade "pip>=20.0.2"
- # pip cache
- - name: Get pip cache dir
- id: pip-cache
- run: |
- echo "::set-output name=dir::$(pip cache dir)"
- - name: pip cache
- uses: actions/cache@v1
- with:
- path: ${{ steps.pip-cache.outputs.dir }}
- key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- - name: Install Python Dependencies
- env:
- PGPASSWORD: postgres
- run: |
- python setup.py install_egg_info
- pip install wheel # GitHub Actions does not have this installed by default (unlike Travis)
- pip install -U -e ".[dev]"
- psql -c 'create database sentry;' -h localhost -U postgres
- sentry init
- - name: Generate SQL for migration
- uses: getsentry/action-migrations@v1.0.7
- env:
- SENTRY_LOG_LEVEL: ERROR
- PGPASSWORD: postgres
- with:
- githubToken: ${{ secrets.GITHUB_TOKEN }}
- migration: ${{ steps.file.outputs.modified }}
|