From f27b4e50f665ab32737d79294e5ca7c7ce48c476 Mon Sep 17 00:00:00 2001 From: Sergey Golitsynskiy Date: Fri, 2 Oct 2020 22:41:42 -0400 Subject: [PATCH] Add github workflow; env var to override db uri --- .github/workflows/db_indexes.yaml | 45 +++++++++++++++++++++++++++++++ scripts/check_model.py | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/db_indexes.yaml diff --git a/.github/workflows/db_indexes.yaml b/.github/workflows/db_indexes.yaml new file mode 100644 index 00000000000..846f2cc5956 --- /dev/null +++ b/.github/workflows/db_indexes.yaml @@ -0,0 +1,45 @@ +name: Database indexes +on: [push, pull_request] +defaults: + run: + working-directory: 'galaxy root' +jobs: + check: + name: Check database indexes + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7] + db: ['postgresql', 'sqlite'] + services: + postgres: + image: postgres:11 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432:5432 + steps: + - uses: actions/checkout@v2 + with: + path: 'galaxy root' + - uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Cache pip dir + uses: actions/cache@v1 + id: pip-cache + with: + path: ~/.cache/pip + key: pip-cache-${{ matrix.python-version }}-${{ hashFiles('galaxy root/requirements.txt') }} + - name: Install tox + run: pip install tox + - name: Check indexes on postgresql + if: matrix.db == 'postgresql' + env: + GALAXY_CONFIG_OVERRIDE_DATABASE_CONNECTION: 'postgres://postgres:postgres@localhost:5432/galaxy?client_encoding=utf8' + run: tox -e check_indexes + - name: Check indexes on sqlite + if: matrix.db == 'sqlite' + run: tox -e check_indexes diff --git a/scripts/check_model.py b/scripts/check_model.py index 65e6d7cb4f4..b8ef7dfbe01 100644 --- a/scripts/check_model.py +++ b/scripts/check_model.py @@ -40,7 +40,7 @@ def find_missing_indexes(): mapping_indexes = load_indexes(metadata) # create EMPTY metadata, then load from database - db_url = get_config(sys.argv)['db_url'] + db_url = os.environ.get("GALAXY_CONFIG_OVERRIDE_DATABASE_CONNECTION") or get_config(sys.argv)['db_url'] metadata = MetaData(bind=create_engine(db_url)) metadata.reflect() indexes_in_db = load_indexes(metadata)