Skip to content

Commit

Permalink
wip: backend
Browse files Browse the repository at this point in the history
  • Loading branch information
snaselj committed Oct 13, 2023
1 parent bdce494 commit fab76f8
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions .github/actions/unittests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,32 @@ runs:
if: |
steps.cache.outputs.cache-hit == 'true'
shell: "bash"
env:
IMPORT_MYSQL: "mysql --user=nautobot --password=$MYSQL_PASSWORD"
IMPORT_POSTGRES: "psql --username=nautobot postgres"
run: |
cd development
docker compose exec -- db sh -c \
'${{ inputs.db-backend == 'mysql' && env.IMPORT_MYSQL || env.IMPORT_POSTGRES }}' \
'${{ inputs.db-backend == 'mysql' &&
'mysql --user=nautobot --password=$MYSQL_PASSWORD' ||
'psql --username=nautobot postgres'
}}' \
< dump.sql
- name: "Build Database Dump"
if: |
steps.cache.outputs.cache-hit != 'true'
shell: "bash"
env:
BACKUP_MYSQL: "mysqldump --user=root --password=$MYSQL_ROOT_PASSWORD --databases test_nautobot"
BACKUP_POSTGRES: "pg_dump --clean --create --username=nautobot --dbname=test_nautobot"
CREATE_MYSQL: "mysql -u nautobot -e \"CREATE DATABASE test_nautobot;\""
CREATE_POSTGRES: "createdb --user=nautobot test_nautobot"
run: |
cd development
docker compose exec -- db sh -c \
'${{ inputs.db-backend == 'mysql' && env.CREATE_MYSQL || env.CREATE_POSTGRES }}'
'${{ inputs.db-backend == 'mysql' &&
'mysql -u nautobot -e "CREATE DATABASE test_nautobot;"' ||
'createdb --user=nautobot test_nautobot'
}}'
docker compose run --rm --entrypoint='' --env=NAUTOBOT_DB_NAME=test_nautobot -- nautobot \
nautobot-server migrate
docker compose exec -- db sh -c \
'${{ inputs.db-backend == 'mysql' && env.BACKUP_MYSQL || env.BACKUP_POSTGRES }}' \
'${{ inputs.db-backend == 'mysql' &&
'mysqldump --user=root --password=$MYSQL_ROOT_PASSWORD --databases test_nautobot' ||
'pg_dump --clean --create --username=nautobot --dbname=test_nautobot'
}}' \
> dump.sql
- name: "Unit Tests"
shell: "bash"
Expand Down

0 comments on commit fab76f8

Please sign in to comment.