Skip to content

Commit e66ed46

Browse files
committed
fix: restore code
1 parent a8a06e1 commit e66ed46

File tree

3 files changed

+59
-61
lines changed

3 files changed

+59
-61
lines changed

.github/workflows/db-update.yml

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -72,68 +72,68 @@ env:
7272
python_version: '3.11'
7373

7474
jobs:
75-
# db-schema-update:
76-
# name: 'Database Schema Update'
77-
# permissions: write-all
78-
# runs-on: ubuntu-latest
79-
# steps:
80-
# - name: Checkout code
81-
# uses: actions/checkout@v4
82-
#
83-
# - name: Authenticate to Google Cloud QA/PROD
84-
# uses: google-github-actions/auth@v2
85-
# with:
86-
# credentials_json: ${{ secrets.DB_GCP_MOBILITY_FEEDS_SA_KEY }}
87-
#
88-
# - name: Google Cloud Setup
89-
# uses: google-github-actions/setup-gcloud@v2
90-
#
91-
# - name: Load secrets from 1Password
92-
# uses: 1password/[email protected]
93-
# with:
94-
# export-env: true # Export loaded secrets as environment variables
95-
# env:
96-
# OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
97-
# GCP_FEED_SSH_USER: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_SSH_USER/username"
98-
# GCP_FEED_BASTION_NAME: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_BASTION_NAME/username"
99-
# GCP_FEED_BASTION_SSH_KEY: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_BASTION_SSH_KEY/private key"
100-
#
101-
# - name: Tunnel
102-
# run: |
103-
# mkdir -p ~/.ssh
104-
# echo "${{ env.GCP_FEED_BASTION_SSH_KEY }}" > ~/.ssh/id_rsa
105-
# chmod 600 ~/.ssh/id_rsa
106-
# ./scripts/tunnel-create.sh -project_id ${{ inputs.PROJECT_ID }} -zone ${{ inputs.REGION }}-a -instance ${{ env.GCP_FEED_BASTION_NAME }}-${{ inputs.DB_ENVIRONMENT}} -target_account ${{ env.GCP_FEED_SSH_USER }} -db_instance ${{ secrets.POSTGRE_SQL_INSTANCE_NAME }}
107-
# sleep 10 # Wait for the tunnel to establish
108-
#
109-
# - name: Test Database Connection Through Tunnel
110-
# run: |
111-
# sudo apt-get update && sudo apt-get install -y postgresql-client
112-
# PGPASSWORD=${{ secrets.DB_USER_PASSWORD }} psql -h localhost -p 5432 -U ${{ secrets.DB_USER_NAME }} -d ${{ inputs.DB_NAME }} -c "SELECT version();"
113-
#
114-
# - name: Run Liquibase
115-
# run: |
116-
# wget -O- https://repo.liquibase.com/liquibase.asc | gpg --dearmor > liquibase-keyring.gpg && \
117-
# cat liquibase-keyring.gpg | sudo tee /usr/share/keyrings/liquibase-keyring.gpg > /dev/null && \
118-
# echo 'deb [trusted=yes arch=amd64 signed-by=/usr/share/keyrings/liquibase-keyring.gpg] https://repo.liquibase.com stable main' | sudo tee /etc/apt/sources.list.d/liquibase.list
119-
#
120-
# sudo apt-get update
121-
# sudo apt-get install liquibase=4.25.1
122-
#
123-
# export LIQUIBASE_CLASSPATH="liquibase"
124-
# export LIQUIBASE_COMMAND_CHANGELOG_FILE="changelog.xml"
125-
# export LIQUIBASE_COMMAND_URL=jdbc:postgresql://localhost:5432/${{ inputs.DB_NAME }}
126-
# export LIQUIBASE_COMMAND_USERNAME=${{ secrets.DB_USER_NAME }}
127-
# export LIQUIBASE_COMMAND_PASSWORD=${{ secrets.DB_USER_PASSWORD }}
128-
# export LIQUIBASE_LOG_LEVEL=FINE
129-
#
130-
# liquibase update
75+
db-schema-update:
76+
name: 'Database Schema Update'
77+
permissions: write-all
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Checkout code
81+
uses: actions/checkout@v4
82+
83+
- name: Authenticate to Google Cloud QA/PROD
84+
uses: google-github-actions/auth@v2
85+
with:
86+
credentials_json: ${{ secrets.DB_GCP_MOBILITY_FEEDS_SA_KEY }}
87+
88+
- name: Google Cloud Setup
89+
uses: google-github-actions/setup-gcloud@v2
90+
91+
- name: Load secrets from 1Password
92+
uses: 1password/[email protected]
93+
with:
94+
export-env: true # Export loaded secrets as environment variables
95+
env:
96+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
97+
GCP_FEED_SSH_USER: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_SSH_USER/username"
98+
GCP_FEED_BASTION_NAME: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_BASTION_NAME/username"
99+
GCP_FEED_BASTION_SSH_KEY: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_BASTION_SSH_KEY/private key"
100+
101+
- name: Tunnel
102+
run: |
103+
mkdir -p ~/.ssh
104+
echo "${{ env.GCP_FEED_BASTION_SSH_KEY }}" > ~/.ssh/id_rsa
105+
chmod 600 ~/.ssh/id_rsa
106+
./scripts/tunnel-create.sh -project_id ${{ inputs.PROJECT_ID }} -zone ${{ inputs.REGION }}-a -instance ${{ env.GCP_FEED_BASTION_NAME }}-${{ inputs.DB_ENVIRONMENT}} -target_account ${{ env.GCP_FEED_SSH_USER }} -db_instance ${{ secrets.POSTGRE_SQL_INSTANCE_NAME }}
107+
sleep 10 # Wait for the tunnel to establish
108+
109+
- name: Test Database Connection Through Tunnel
110+
run: |
111+
sudo apt-get update && sudo apt-get install -y postgresql-client
112+
PGPASSWORD=${{ secrets.DB_USER_PASSWORD }} psql -h localhost -p 5432 -U ${{ secrets.DB_USER_NAME }} -d ${{ inputs.DB_NAME }} -c "SELECT version();"
113+
114+
- name: Run Liquibase
115+
run: |
116+
wget -O- https://repo.liquibase.com/liquibase.asc | gpg --dearmor > liquibase-keyring.gpg && \
117+
cat liquibase-keyring.gpg | sudo tee /usr/share/keyrings/liquibase-keyring.gpg > /dev/null && \
118+
echo 'deb [trusted=yes arch=amd64 signed-by=/usr/share/keyrings/liquibase-keyring.gpg] https://repo.liquibase.com stable main' | sudo tee /etc/apt/sources.list.d/liquibase.list
119+
120+
sudo apt-get update
121+
sudo apt-get install liquibase=4.25.1
122+
123+
export LIQUIBASE_CLASSPATH="liquibase"
124+
export LIQUIBASE_COMMAND_CHANGELOG_FILE="changelog.xml"
125+
export LIQUIBASE_COMMAND_URL=jdbc:postgresql://localhost:5432/${{ inputs.DB_NAME }}
126+
export LIQUIBASE_COMMAND_USERNAME=${{ secrets.DB_USER_NAME }}
127+
export LIQUIBASE_COMMAND_PASSWORD=${{ secrets.DB_USER_PASSWORD }}
128+
export LIQUIBASE_LOG_LEVEL=FINE
129+
130+
liquibase update
131131
132132
db-content-update:
133133
name: 'Database Content Update'
134134
permissions: write-all
135135
runs-on: ubuntu-latest
136-
# needs: db-schema-update
136+
needs: db-schema-update
137137
if: ${{ github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch' }}
138138
steps:
139139
- name: Checkout code

api/src/scripts/load_dataset_on_create.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
def get_pubsub_client():
2323
credentials, project = default()
24-
logging.error(f"Authenticated project: {project}")
25-
logging.error(f"Service Account Email: {credentials.service_account_email}")
24+
logging.info(f"Authenticated project: {project}")
25+
logging.info(f"Service Account Email: {credentials.service_account_email}")
2626
with lock:
2727
global pubsub_client
2828
if pubsub_client is None:

api/src/scripts/populate_db_gtfs.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ def populate_db(self):
177177
for index, row in self.df.iterrows():
178178
self.logger.debug(f"Populating Database with Feed [stable_id = {row['mdb_source_id']}]")
179179
# Create or update the GTFS feed
180-
if str(int(float(row["mdb_source_id"]))) != '2155': # TODO: remove before merging
181-
continue
182180
data_type = self.get_data_type(row)
183181
stable_id = self.get_stable_id(row)
184182
feed = self.query_feed_by_stable_id(stable_id, data_type)

0 commit comments

Comments
 (0)