Skip to content

Commit

Permalink
test: changes to test_migration workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
raghuvar-vijay committed Jun 21, 2024
1 parent d2797b5 commit 6903a46
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: dtolnay/rust-toolchain@stable
with:
Expand Down Expand Up @@ -58,9 +60,10 @@ jobs:
# if: ${{ steps.cache_sqlx.outputs.cache-hit }}
run: cargo install sqlx-cli --version=${{ env.SQLX_VERSION }} --features=${{ env.SQLX_FEATURES }} --no-default-features --locked


- name: Checkout previous commit
run: git checkout HEAD~1
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main

- name: Migrate database
run: |
Expand Down
16 changes: 11 additions & 5 deletions scripts/test_migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,32 @@ function auditor_main() {
SKIP_DOCKER=true ./scripts/init_db.sh
./scripts/init_slurm_collector_sqlite.sh
./scripts/init_client_sqlite.sh
compile_auditor
start_auditor_main
fill_auditor
kill $AUDITOR_SERVER_PID
wait $AUDITOR_SERVER_PID
}

function auditor_new_migration() {
sqlx migrate run --source migrations --database-url=postgres://postgres:password@localhost:5432/auditor
start_auditor_main
fill_auditor_new
test_collector
kill $AUDITOR_SERVER_PID
}

git checkout main
function cleanup_exit() {
if [ -n "$AUDITOR_SERVER_PID" ]; then
echo >&2 "Stopping Auditor due to script exit"
kill $AUDITOR_SERVER_PID
wait $AUDITOR_SERVER_PID
fi
}

trap "cleanup_function" SIGINT SIGQUIT SIGTERM EXIT

auditor_main

git checkout -

auditor_new_migration

trap "cleanup_exit" SIGINT SIGQUIT SIGTERM EXIT

0 comments on commit 6903a46

Please sign in to comment.