Skip to content

Commit

Permalink
Merge pull request #2 from piroinno/init
Browse files Browse the repository at this point in the history
Init
  • Loading branch information
piroinno authored Mar 26, 2023
2 parents a6aac53 + 58781bf commit b45471a
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 215 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
workflow_dispatch:
branches:
- '**'
push:
branches:
- '**'
pull_request:
branches:
- dev
Expand All @@ -26,10 +23,11 @@ env:
APP_AUTO_WORKING_FOLDER: "./"
APP_AUTO_WORKING_PATH: ${{ github.workspace }}
ENVIRONMENT: ${{ fromJSON('["dev", "prd"]')[github.ref == 'refs/heads/main'] }}
IS_TESTING: true

jobs:
prepare:
runs-on: self-hosted
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
Expand All @@ -45,7 +43,7 @@ jobs:
test:
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
runs-on: self-hosted
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
Expand All @@ -64,7 +62,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Test the application
uses: piroinno/stock-data-app-automation/test/poetry/@init
uses: piroinno/stock-data-app-automation/test/poetry/@v1.4.0
with:
packagefeed: ${{ secrets.AZURE_PYPI_FEED }}
packagefeedpassword: ${{ secrets.AZURE_PYPI_PASSWORD }}
Expand All @@ -73,16 +71,16 @@ jobs:
appfolder: ${{ matrix.app }}

build:
runs-on: self-hosted
runs-on: ubuntu-latest
needs: [prepare, test]
strategy:
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- name: Build application package
uses: piroinno/stock-data-app-automation/build/poetry/@init
uses: piroinno/stock-data-app-automation/build/poetry/@v1.4.0
with:
packagefeed: ${{ secrets.AZURE_PYPI_FEED }}
packagefeedpassword: ${{ secrets.AZURE_PYPI_PASSWORD }}
packagefeedmetadata: ${{ secrets.AZURE_PYPI_METADATA }}
appfolder: ${{ matrix.app }}
appfolder: ${{ matrix.app }}
22 changes: 22 additions & 0 deletions model/src/stock/data/model/BaltimoreCyberTrustRoot.crt.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ
RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD
VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX
DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y
ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy
VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr
mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr
IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK
mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu
XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy
dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye
jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1
BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3
DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92
9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx
jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0
Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz
ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS
R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
-----END CERTIFICATE-----

15 changes: 13 additions & 2 deletions model/src/stock/data/model/database.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
import os
from os import environ
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

SQLALCHEMY_DATABASE_URL = os.getenv("DATABASE_URL")

connect_args = {}
if environ.get('IS_TESTING') is None:
connect_args = {
'sslmode': 'require', 'sslrootcert': 'BaltimoreCyberTrustRoot.crt.pem'
}

engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={}
SQLALCHEMY_DATABASE_URL, connect_args=connect_args
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base = declarative_base()


def init_test_db(schema="test"):
Base.metadata.schema = schema
Base.metadata.create_all(bind=engine)


def drop_test_db(schema="test"):
Base.metadata.schema = schema
Base.metadata.drop_all(bind=engine)


def recreate_test_db():
drop_test_db()
init_test_db()


def get_test_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
db.close()
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ
RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD
VQQD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IFICATE-----

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""Core1
"""init
Revision ID: fc608628c9db
Revision ID: 7b4dd2fa79cd
Revises:
Create Date: 2023-03-12 20:54:57.410322
Create Date: 2023-03-26 03:26:52.074557
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'fc608628c9db'
revision = '7b4dd2fa79cd'
down_revision = None
branch_labels = None
depends_on = None
Expand Down Expand Up @@ -38,7 +38,7 @@ def upgrade() -> None:
op.create_index(op.f('ix_currencies_code'), 'currencies', ['code'], unique=False)
op.create_index(op.f('ix_currencies_id'), 'currencies', ['id'], unique=False)
op.create_index(op.f('ix_currencies_name'), 'currencies', ['name'], unique=False)
op.create_table('eod_data_stores',
op.create_table('eod_ingestor_data_stores',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('time_generated', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
Expand All @@ -48,12 +48,12 @@ def upgrade() -> None:
sa.Column('tenant_id', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_eod_data_stores_container'), 'eod_data_stores', ['container'], unique=False)
op.create_index(op.f('ix_eod_data_stores_id'), 'eod_data_stores', ['id'], unique=False)
op.create_index(op.f('ix_eod_data_stores_name'), 'eod_data_stores', ['name'], unique=False)
op.create_index(op.f('ix_eod_data_stores_subscription_id'), 'eod_data_stores', ['subscription_id'], unique=False)
op.create_index(op.f('ix_eod_data_stores_tenant_id'), 'eod_data_stores', ['tenant_id'], unique=False)
op.create_index(op.f('ix_eod_data_stores_url'), 'eod_data_stores', ['url'], unique=False)
op.create_index(op.f('ix_eod_ingestor_data_stores_container'), 'eod_ingestor_data_stores', ['container'], unique=False)
op.create_index(op.f('ix_eod_ingestor_data_stores_id'), 'eod_ingestor_data_stores', ['id'], unique=False)
op.create_index(op.f('ix_eod_ingestor_data_stores_name'), 'eod_ingestor_data_stores', ['name'], unique=False)
op.create_index(op.f('ix_eod_ingestor_data_stores_subscription_id'), 'eod_ingestor_data_stores', ['subscription_id'], unique=False)
op.create_index(op.f('ix_eod_ingestor_data_stores_tenant_id'), 'eod_ingestor_data_stores', ['tenant_id'], unique=False)
op.create_index(op.f('ix_eod_ingestor_data_stores_url'), 'eod_ingestor_data_stores', ['url'], unique=False)
op.create_table('timezones',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
Expand Down Expand Up @@ -91,11 +91,11 @@ def upgrade() -> None:
sa.ForeignKeyConstraint(['timezone_id'], ['timezones.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_exchanges_acronym'), 'exchanges', ['acronym'], unique=True)
op.create_index(op.f('ix_exchanges_acronym'), 'exchanges', ['acronym'], unique=False)
op.create_index(op.f('ix_exchanges_city_id'), 'exchanges', ['city_id'], unique=False)
op.create_index(op.f('ix_exchanges_country_id'), 'exchanges', ['country_id'], unique=False)
op.create_index(op.f('ix_exchanges_id'), 'exchanges', ['id'], unique=False)
op.create_index(op.f('ix_exchanges_mic'), 'exchanges', ['mic'], unique=True)
op.create_index(op.f('ix_exchanges_mic'), 'exchanges', ['mic'], unique=False)
op.create_index(op.f('ix_exchanges_name'), 'exchanges', ['name'], unique=True)
op.create_index(op.f('ix_exchanges_timezone_id'), 'exchanges', ['timezone_id'], unique=False)
op.create_table('tickers',
Expand All @@ -104,12 +104,9 @@ def upgrade() -> None:
sa.Column('time_generated', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
sa.Column('exchange_id', sa.Integer(), nullable=True),
sa.Column('ticker', sa.String(), nullable=True),
sa.Column('currency_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['currency_id'], ['currencies.id'], ),
sa.ForeignKeyConstraint(['exchange_id'], ['exchanges.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tickers_currency_id'), 'tickers', ['currency_id'], unique=False)
op.create_index(op.f('ix_tickers_exchange_id'), 'tickers', ['exchange_id'], unique=False)
op.create_index(op.f('ix_tickers_id'), 'tickers', ['id'], unique=False)
op.create_index(op.f('ix_tickers_name'), 'tickers', ['name'], unique=False)
Expand All @@ -125,7 +122,7 @@ def upgrade() -> None:
sa.Column('timezone_id', sa.Integer(), nullable=True),
sa.Column('start_date', sa.DateTime(), nullable=True),
sa.Column('end_date', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['data_store_id'], ['eod_data_stores.id'], ),
sa.ForeignKeyConstraint(['data_store_id'], ['eod_ingestor_data_stores.id'], ),
sa.ForeignKeyConstraint(['ticker_id'], ['tickers.id'], ),
sa.ForeignKeyConstraint(['timezone_id'], ['timezones.id'], ),
sa.PrimaryKeyConstraint('id')
Expand All @@ -144,7 +141,7 @@ def upgrade() -> None:
sa.Column('job_status_id', sa.Integer(), nullable=True),
sa.Column('data_store_id', sa.Integer(), nullable=True),
sa.Column('blob', sa.String(), nullable=True),
sa.ForeignKeyConstraint(['data_store_id'], ['eod_data_stores.id'], ),
sa.ForeignKeyConstraint(['data_store_id'], ['eod_ingestor_data_stores.id'], ),
sa.ForeignKeyConstraint(['job_status_id'], ['eod_ingestor_job_status.id'], ),
sa.PrimaryKeyConstraint('id')
)
Expand Down Expand Up @@ -176,7 +173,6 @@ def downgrade() -> None:
op.drop_index(op.f('ix_tickers_name'), table_name='tickers')
op.drop_index(op.f('ix_tickers_id'), table_name='tickers')
op.drop_index(op.f('ix_tickers_exchange_id'), table_name='tickers')
op.drop_index(op.f('ix_tickers_currency_id'), table_name='tickers')
op.drop_table('tickers')
op.drop_index(op.f('ix_exchanges_timezone_id'), table_name='exchanges')
op.drop_index(op.f('ix_exchanges_name'), table_name='exchanges')
Expand All @@ -195,13 +191,13 @@ def downgrade() -> None:
op.drop_index(op.f('ix_timezones_dst'), table_name='timezones')
op.drop_index(op.f('ix_timezones_abbr'), table_name='timezones')
op.drop_table('timezones')
op.drop_index(op.f('ix_eod_data_stores_url'), table_name='eod_data_stores')
op.drop_index(op.f('ix_eod_data_stores_tenant_id'), table_name='eod_data_stores')
op.drop_index(op.f('ix_eod_data_stores_subscription_id'), table_name='eod_data_stores')
op.drop_index(op.f('ix_eod_data_stores_name'), table_name='eod_data_stores')
op.drop_index(op.f('ix_eod_data_stores_id'), table_name='eod_data_stores')
op.drop_index(op.f('ix_eod_data_stores_container'), table_name='eod_data_stores')
op.drop_table('eod_data_stores')
op.drop_index(op.f('ix_eod_ingestor_data_stores_url'), table_name='eod_ingestor_data_stores')
op.drop_index(op.f('ix_eod_ingestor_data_stores_tenant_id'), table_name='eod_ingestor_data_stores')
op.drop_index(op.f('ix_eod_ingestor_data_stores_subscription_id'), table_name='eod_ingestor_data_stores')
op.drop_index(op.f('ix_eod_ingestor_data_stores_name'), table_name='eod_ingestor_data_stores')
op.drop_index(op.f('ix_eod_ingestor_data_stores_id'), table_name='eod_ingestor_data_stores')
op.drop_index(op.f('ix_eod_ingestor_data_stores_container'), table_name='eod_ingestor_data_stores')
op.drop_table('eod_ingestor_data_stores')
op.drop_index(op.f('ix_currencies_name'), table_name='currencies')
op.drop_index(op.f('ix_currencies_id'), table_name='currencies')
op.drop_index(op.f('ix_currencies_code'), table_name='currencies')
Expand Down
Loading

0 comments on commit b45471a

Please sign in to comment.