Skip to content

Commit

Permalink
chore: apply linter
Browse files Browse the repository at this point in the history
  • Loading branch information
vncsna committed Feb 14, 2024
1 parent ca6be92 commit 7cf5072
Show file tree
Hide file tree
Showing 532 changed files with 41,282 additions and 35,238 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.sql linguist-detectable=true
*.sql linguist-detectable=true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/issue--novos-dados.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ assignees: ''
* Cobertura espacial: `<area.slug>`
* Cobertura temporal: `de YYYY-MM-DD a YYYY-MM-DD`
* Frequência de atualização: `<year> / <semester> / <quarter> / <month> / <day> / <hour> / <minute> / <second>`
* Nível de Observação (o que representa cada linha da tabela):
* Nível de Observação (o que representa cada linha da tabela):
* `<tabela> - <entidade> - <coluna>`

5. Raspagem
Expand Down
25 changes: 4 additions & 21 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
name: Deployment

on:
pull_request:
types: [closed]

env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
Expand All @@ -14,49 +13,42 @@ env:
BASEDOSDADOS_CREDENTIALS_PROD: ${{ secrets.BASEDOSDADOS_CREDENTIALS_PROD }}
BASEDOSDADOS_CREDENTIALS_STAGING: ${{ secrets.BASEDOSDADOS_CREDENTIALS_STAGING }}
IMAGE_NAME: ghcr.io/basedosdados/queries-basedosdados


jobs:
build-container:
if: (github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main')
if: (github.event.pull_request.merged == true && github.event.pull_request.base.ref
== 'main')
name: Deployment
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Google Cloud CLI
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
export_default_credentials: true

- name: Get GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_REGION }}
credentials: ${{ secrets.GCP_SA_KEY }}

- name: Build and publish image
run: |
docker build -t $IMAGE_NAME:$GITHUB_SHA .
echo $GH_PAT | docker login ghcr.io -u gabriel-milan --password-stdin
docker push $IMAGE_NAME:$GITHUB_SHA
- name: Set up Kustomize
run: |-
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./kustomize
- name: Deploy
run: |-
./kustomize edit set image gcr.io/PROJECT_ID/IMAGE_DBT:TAG=$IMAGE_NAME:$GITHUB_SHA
./kustomize build . | kubectl apply -n prefect-agent-basedosdados -f -
kubectl rollout status -w -n prefect-agent-basedosdados deployment/dbt-rpc-dev
kubectl rollout status -w -n prefect-agent-basedosdados deployment/dbt-rpc-prod
table-approve:
if: contains(github.event.pull_request.labels.*.name, 'table-approve')
needs: build-container
Expand All @@ -65,51 +57,42 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get all changed files using a comma separator
id: changed-files
uses: tj-actions/changed-files@v35
with:
separator: ','

- name: Setup Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run script for approving table
run: |
python .github/workflows/scripts/table_approve.py --modified-files ${{ steps.changed-files.outputs.all_modified_files }} --graphql-url ${{ secrets.BACKEND_GRAPHQL_URL }} --source-bucket-name ${{ secrets.SOURCE_BUCKET_NAME }} --destination-bucket-name ${{ secrets.DESTINATION_BUCKET_NAME }} --backup-bucket-name ${{ secrets.BACKUP_BUCKET_NAME }} --prefect-backend-token ${{ secrets.PREFECT_BACKEND_TOKEN }} --materialization-mode ${{ secrets.MATERIALIZATION_MODE }} --materialization-label ${{ secrets.MATERIALIZATION_LABEL }}
change-metadata-status:
needs: table-approve
name: Change metadata status to "production"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get all changed files using a comma separator
id: changed-files
uses: tj-actions/changed-files@v35
with:
separator: ','

- name: Setup Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run script for changing metadata status
run: |
run: |-
python .github/workflows/scripts/change_metadata_status.py --modified-files ${{ steps.changed-files.outputs.all_modified_files }} --graphql-url ${{ secrets.BACKEND_GRAPHQL_URL }} --status published --email ${{ secrets.BACKEND_EMAIL }} --password ${{ secrets.BACKEND_PASSWORD }}
18 changes: 5 additions & 13 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,41 @@
---
name: Deploy docs

on:
pull_request:
types: [closed]

env:
DBT_SA: ${{ secrets.DBT_SA }}

jobs:
docs:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref
== 'main'
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9.x"

python-version: 3.9.x
- name: Upgrade pip
run: |
pip install -U pip
- name: Install dependencies
run: |
pip3 install -r requirements-docs.txt -r requirements.txt
- name: Setup credentials
run: |
echo $DBT_SA | base64 --decode > dbt-sa.json
python3 .github/workflows/scripts/modify_profiles.py
- name: Generate docs
run: |
dbt docs generate --profiles-dir .
- name: Delete credentials
run: |
rm dbt-sa.json
- name: Deploy docs
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: target
folder: target
3 changes: 1 addition & 2 deletions .github/workflows/lint_docker.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
name: Lint Dockerfile

on:
pull_request:

jobs:
docker_lint:
name: Lint Dockerfile
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scripts/backend.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
Module for interacting with the backend.
"""
Expand Down Expand Up @@ -185,7 +186,7 @@ def get_dataset_config(self, gcp_dataset_id: str) -> Dict[str, Any]:
}
}
}
"""
variables = {
"dataset_id": self._get_dataset_id_from_name(gcp_dataset_id=gcp_dataset_id)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/scripts/change_metadata_status.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from argparse import ArgumentParser

from backend import Backend
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/scripts/modify_profiles.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
Change credentials path to current path
"""
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/scripts/sync_dbt_schema.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
from copy import deepcopy
import json
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/scripts/table_approve.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
from pathlib import Path
import sys
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/scripts/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from pathlib import Path
from typing import List, Tuple, Union

Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/sync-dbt-schema.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
---
name: Sync DBT schema

on:
pull_request:
types: [labeled, opened]
branches:
- main
paths:
- 'models/**'
- '.github/workflows/sync-dbt-schema.yaml'

branches: [main]
paths: [models/**, .github/workflows/sync-dbt-schema.yaml]
jobs:
sync-dbt-schema:
if: contains(github.event.pull_request.labels.*.name, 'sync-dbt-schema')
Expand All @@ -19,28 +15,23 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Get all changed files using a comma separator
id: changed-files
uses: tj-actions/changed-files@v35
with:
separator: ','

- name: Setup Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run script for syncing DBT schema
run: |
python .github/workflows/scripts/sync_dbt_schema.py --modified-files ${{ steps.changed-files.outputs.all_modified_files }} --graphql-url ${{ secrets.BACKEND_GRAPHQL_URL }}
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'Update metadata'
commit_message: Update metadata
Loading

0 comments on commit 7cf5072

Please sign in to comment.