Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add action to check bucket name #499

Merged
merged 23 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1e668c5
feat: add action to check bucket name
arthurfg Apr 16, 2024
675caa2
feat: add action to check bucket name
arthurfg Apr 16, 2024
2dd6824
Merge branch 'main' into cgu-beneficios
arthurfg Apr 16, 2024
2cfb897
feat: add action to check bucket name
arthurfg Apr 16, 2024
165d65a
feat: add action to check bucket name
arthurfg Apr 16, 2024
fa4f260
feat: add action to check bucket name
arthurfg Apr 16, 2024
162fc83
feat: add action to check bucket name
arthurfg Apr 16, 2024
b5b16c9
feat: add action to check bucket name
arthurfg Apr 16, 2024
89f4ff6
feat: add action to check bucket name
arthurfg Apr 16, 2024
911057d
feat: add action to check bucket name
arthurfg Apr 16, 2024
3859802
feat: add action to check bucket name
arthurfg Apr 16, 2024
fdb6bef
feat: add action to check bucket name
arthurfg Apr 16, 2024
1dcb7a6
feat: add action to check bucket name
arthurfg Apr 16, 2024
763f7d7
feat: add action to check bucket name
arthurfg Apr 16, 2024
5ca70ab
feat: add action to check bucket name
arthurfg Apr 16, 2024
a118988
feat: add action to check bucket name
arthurfg Apr 16, 2024
37da60e
feat: add action to check bucket name
arthurfg Apr 16, 2024
17d29fd
feat: add action to check bucket name
arthurfg Apr 16, 2024
bab5420
feat: add action to check bucket name
arthurfg Apr 16, 2024
cdd4a97
feat: add action to check bucket name
arthurfg Apr 16, 2024
13588fa
feat: add action to check bucket name
arthurfg Apr 16, 2024
6804de1
feat: change action name
arthurfg Apr 17, 2024
d0f48b4
fix: project name
arthurfg Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/check-bucket-name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Check bucket name
on:
workflow_dispatch:
pull_request:
paths:
- '**/*.sql'

jobs:
check_bucket_name:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get changed files
id: get_files
uses: dorny/paths-filter@v2
with:
list-files: shell
filters: |
pr:
- added|deleted|modified: '**'

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Run Python script
run: |
for file in ${{ steps.get_files.outputs.pr_files }}; do
if [[ $file == *.sql ]]; then
echo "SQL file detected: $file"
python .github/workflows/scripts/check_sql_files.py $file
else
echo "Não é um arquivo SQL: $file"
fi
done
23 changes: 23 additions & 0 deletions .github/workflows/scripts/check_sql_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import argparse

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

if __name__ == "__main__":
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-staging' found in SQL files.")
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ select
safe_cast(numero as string) numero_beneficio,
safe_cast(concedido_judicialmente as string) concedido_judicialmente,
safe_cast(valor as float64) valor_parcela,
from `basedosdados-dev.br_cgu_beneficios_cidadao_staging.bpc` t1
from `basedosdados-staging.br_cgu_beneficios_cidadao_staging.bpc` t1
left join
`basedosdados.br_bd_diretorios_brasil.municipio` t2
on safe_cast(t1.id_municipio_siafi as int64)
Expand Down
Loading