-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from diksown/test_sql_ci
add sql test to ci
- Loading branch information
Showing
3 changed files
with
208 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
DATABASE_NAME="test_sql" | ||
USER="postgres" # Default user | ||
HOST="localhost" | ||
|
||
FILES=("esquema.sql" "triggers.sql" "dados.sql" "consultas.sql") | ||
|
||
for file in "${FILES[@]}" | ||
do | ||
echo "Running $file..." | ||
PGPASSWORD=postgres psql --set ON_ERROR_STOP=on -d "$DATABASE_NAME" -U "$USER" -h "$HOST" -f "sql/$file" | ||
if [ $? -ne 0 ]; then | ||
echo "Error encountered running $file" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "All files executed successfully" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: SQL Test | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
test-database: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: test_sql | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run SQL Files | ||
run: .github/run_sql_files.sh | ||
env: | ||
PGPASSWORD: postgres |
Oops, something went wrong.