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

Added github workflows on release branches and fix migration workflow issues #860

Merged
merged 7 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
branches:
- main
- v2m*

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cdk-nag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- "deploy/**"
branches:
- main
- v2m*

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- main
- release/*
- main-v2
- v2m*

jobs:
run-tests:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- main
- release/*
- main-v2
- v2m*

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- main
- release/*
- main-v2
- v2m*

jobs:
lint:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/npm-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- main
- release/*
- main-v2
- v2m*

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- main
- release/*
- main-v2
- v2m*

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/static-checking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- main
- release/*
- main-v2
- v2m*

jobs:
Check:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-db-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ on:
- main
- release/*
- main-v2
- v2m*

env:
envname: local
schema_name: validation

jobs:
run-tests:
Expand Down
5 changes: 2 additions & 3 deletions backend/dataall/base/db/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def drop_schema_if_exists(engine, envname):


def get_engine(envname=ENVNAME):
schema = os.getenv('schema_name', envname)
if envname not in ['local', 'pytest', 'dkrcompose']:
param_store = Parameter()
credential_arn = param_store.get_parameter(env=envname, path='aurora/dbcreds')
Expand All @@ -120,7 +119,7 @@ def get_engine(envname=ENVNAME):
'db': database,
'user': user,
'pwd': pwd,
'schema': schema,
'schema': envname,
}
else:
hostname = 'db' if envname == 'dkrcompose' else 'localhost'
Expand All @@ -129,7 +128,7 @@ def get_engine(envname=ENVNAME):
'db': 'dataall',
'user': 'postgres',
'pwd': 'docker',
'schema': schema,
'schema': envname,
}
return Engine(DbConfig(**db_params))

Expand Down
9 changes: 4 additions & 5 deletions backend/migrations/drop_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

if __name__ == '__main__':
engine = get_engine(envname=ENVNAME).engine
schema = os.getenv('schema_name', ENVNAME)
print(f'Dropping schema {schema}...')
drop_schema_if_exists(get_engine(envname=ENVNAME).engine, envname=schema)
create_schema_if_not_exists(get_engine(envname=ENVNAME).engine, envname=schema)
print(f'Clean schema {schema} recreated')
print(f'Dropping schema {ENVNAME}...')
drop_schema_if_exists(get_engine(envname=ENVNAME).engine, envname=ENVNAME)
create_schema_if_not_exists(get_engine(envname=ENVNAME).engine, envname=ENVNAME)
print(f'Clean schema {ENVNAME} recreated')
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ def upgrade():
Rename column " " to " " both of type String
"""
envname = os.getenv('envname', 'local')
op.execute(f'ALTER TABLE {envname}.notification ALTER COLUMN "type" TYPE VARCHAR(100);')
op.execute(f'ALTER TABLE {envname}.notification ALTER COLUMN "type" TYPE VARCHAR(100);') # nosemgrep
# semgrep finding ignored as no upstream user input is passed to the statement function
# Only code admins will have access to the envname parameter of the f-string

op.alter_column(
'notification',
'username',
new_column_name='recipient',
nullable=False,
existing_type=sa.String()
)
print("Notification columns updated")


def downgrade():
Expand Down
1 change: 0 additions & 1 deletion deploy/stacks/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ def set_quality_gate_stage(self):
commands=[
f'aws codeartifact login --tool pip --repository {self.codeartifact.codeartifact_pip_repo_name} --domain {self.codeartifact.codeartifact_domain_name} --domain-owner {self.codeartifact.domain.attr_owner}',
f'export envname={self.git_branch}',
f'export schema_name=validation',
'python -m venv env',
'. env/bin/activate',
'make drop-tables',
Expand Down
Loading