Skip to content

Commit

Permalink
fix: check_sql_files action
Browse files Browse the repository at this point in the history
  • Loading branch information
folhesgabriel committed Apr 19, 2024
1 parent 2c77ae2 commit 5e9af5c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/scripts/check_sql_files.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import argparse
import os

def check_sql_files(file):
found_staging = False
if file.endswith(".sql"):
if os.path.exists(file) and file.endswith(".sql"):
with open(file, "r") as f:
lines = f.readlines()
for line in lines:
if "basedosdados-dev" in line:
if "basedosdados-staging" in line:
found_staging = True
print(f"Found 'basedosdados-dev' in {file}")
print(f"Found 'basedosdados-staging' in {file}")
break
return found_staging

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Check for 'basedosdados-dev' occurrences in SQL files.")
parser = argparse.ArgumentParser(description="Check for 'basedosdados-staging' occurrences in SQL files.")
parser.add_argument("file", help="Path to the SQL file to check")
args = parser.parse_args()

if check_sql_files(args.file):
exit(1)
else:
print("No occurrences of 'basedosdados-dev' found in SQL files.")
print("No occurrences of 'basedosdados-staging' found in SQL files.")

0 comments on commit 5e9af5c

Please sign in to comment.