Skip to content

Commit 5e650bb

Browse files
authored
Merge pull request #135 from Sage-Bionetworks/staging
Staging to Prod
2 parents 448e0cc + 8161fb5 commit 5e650bb

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ self-service update.
1414
# Workflow
1515

1616
To deploy an updated data version to the Agora development database
17-
1. Increment `data-version` in `data-manifest.json` on the `develop` branch.
17+
1. Increment `data_version` in `data-manifest.json` on the `develop` branch.
1818
2. Commit the change
1919
3. The Github action CI system automatically updates the dev DB
2020

2121

2222
To deploy an updated data version to the Agora staging database:
23-
1. Merge the data-version update from the dev branch to the staging branch.
23+
1. Merge the data_version update from the dev branch to the staging branch.
2424
2. The Github action CI system automatically updates the dev DB
2525

2626
To deploy an updated data version to the Agora production database:
27-
1. Merge the data-version update from the staging branch to the production branch.
27+
1. Merge the data_version update from the staging branch to the production branch.
2828
2. The Github action CI system automatically updates the dev DB
2929

3030

@@ -54,21 +54,21 @@ Context specific secrets for each environment that corresponds to a git branch (
5454

5555
## Self hosted runners
5656

57-
[agora2-infra] repository deploys a bastian host in AWS for each environment which have access to
57+
[agora-infra-v3] repository deploys a bastian host in AWS for each environment which have access to
5858
the databases. We manually configure a [Github self-hosted runner](https://docs.github.com/en/actions/hosting-your-own-runners)
5959
for each bastian host, a label is applied to each runner to match the corresponding git branch name (develop/staging/prod).
6060

6161
Each runner corresponds to an environment which corresponds to a git branch. The update is
6262
executed from these runners. When a push happens on a branch (i.e. develop), the update
63-
is executed on the `agora-bastian-develop` runner which in turn updates the development database.
63+
is executed on the self-hosted runner with the `develop` label, which in turn updates the development database.
6464

6565

6666
![alt text][self_hosted_runners]
6767

6868

6969
### Setup self hosted runners
7070

71-
Github self hosted runners are deployed with a [Sceptre template config file])(https://github.com/Sage-Bionetworks/agora2-infra/blob/main/config/agoradev/develop/agora-bastian.yaml).
71+
Github self hosted runners are deployed with [Cloudformation](https://github.com/Sage-Bionetworks-IT/agora-infra-v3/blob/dev/src/bastion_stack.py).
7272

7373
Self Hosted Runner setup:
7474
* Deploy the template to the Agora AWS account.
@@ -121,5 +121,5 @@ Enter name of work folder: [press Enter for _work]
121121
[db_update]: agora-db-update.drawio.png "update diagram"
122122
[github_secrets]: github_secrets.png "github secrets screen"
123123
[self_hosted_runners]: self-hosted-runners.png "self hosted runners"
124-
[agora2-infra]: https://github.com/Sage-Bionetworks/agora2-infra "agora2-infra repository"
124+
[agora-infra-v3]: https://github.com/Sage-Bionetworks-IT/agora-infra-v3 "agora-infra-v3 repository"
125125
[Github self-hosted runners]: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#about-self-hosted-runners

data-manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"data-version": "71",
3-
"data-manifest-id": "syn13363290",
4-
"team-images-id": "syn12861877"
2+
"data_version": "72",
3+
"data_file": "syn13363290",
4+
"team_images_id": "syn12861877"
55
}

import-data.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ TEAM_IMAGES_DIR=$DATA_DIR/team_images
1919
mkdir -p $TEAM_IMAGES_DIR
2020

2121
# Version key/value should be on his own line
22-
DATA_VERSION=$(cat $WORKING_DIR/data-manifest.json | grep data-version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
23-
DATA_MANIFEST_ID=$(cat $WORKING_DIR/data-manifest.json | grep data-manifest-id | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
24-
TEAM_IMAGES_ID=$(cat $WORKING_DIR/data-manifest.json | grep team-images-id | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
25-
echo "$BRANCH branch, DATA_VERSION = $DATA_VERSION, manifest id = $DATA_MANIFEST_ID"
22+
DATA_VERSION=$(cat $WORKING_DIR/data-manifest.json | grep data_version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
23+
DATA_FILE=$(cat $WORKING_DIR/data-manifest.json | grep data_file | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
24+
TEAM_IMAGES_ID=$(cat $WORKING_DIR/data-manifest.json | grep team_images_id | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
25+
echo "$BRANCH branch, DATA_VERSION = $DATA_VERSION, manifest id = $DATA_FILE"
2626

2727
# Download the manifest file from synapse
28-
synapse -p $SYNAPSE_PASSWORD get --downloadLocation $DATA_DIR -v $DATA_VERSION $DATA_MANIFEST_ID
28+
synapse -p $SYNAPSE_PASSWORD get --downloadLocation $DATA_DIR -v $DATA_VERSION $DATA_FILE
2929

3030
# Ensure there's a newline at the end of the manifest file; otherwise the last listed file will not be downloaded
3131
# echo >> $DATA_DIR/data_manifest.csv
@@ -44,6 +44,14 @@ ls -al $WORKING_DIR
4444
ls -al $DATA_DIR
4545
ls -al $TEAM_IMAGES_DIR
4646

47+
# Check if dataversion exists and handle different data format
48+
DATAVERSION_PATH="${DATA_DIR}/dataversion.json"
49+
DATAVERSION_FLAG="--jsonArray"
50+
if [ ! -f "${DATAVERSION_PATH}" ]; then
51+
DATAVERSION_PATH="${WORKING_DIR}/data-manifest.json"
52+
DATAVERSION_FLAG=""
53+
fi
54+
4755
# Import synapse data to database
4856
# Not using --mode upsert for now because we don't have unique indexes properly set for the collections
4957

@@ -64,6 +72,9 @@ mongoimport -h $DB_HOST -d agora -u $DB_USER -p $DB_PASS --authenticationDatabas
6472
mongoimport -h $DB_HOST -d agora -u $DB_USER -p $DB_PASS --authenticationDatabase admin --collection genesbiodomains --jsonArray --drop --file $DATA_DIR/genes_biodomains.json
6573
mongoimport -h $DB_HOST -d agora -u $DB_USER -p $DB_PASS --authenticationDatabase admin --collection biodomaininfo --jsonArray --drop --file $DATA_DIR/biodomain_info.json
6674

75+
echo "Importing dataversion from ${DATAVERSION_PATH}"
76+
mongoimport -h $DB_HOST -d agora -u $DB_USER -p $DB_PASS --authenticationDatabase admin --collection dataversion $DATAVERSION_FLAG --drop --file $DATAVERSION_PATH
77+
6778
mongosh --host $DB_HOST -u $DB_USER -p $DB_PASS --authenticationDatabase admin $WORKING_DIR/create-indexes.js
6879

6980
pushd $TEAM_IMAGES_DIR

0 commit comments

Comments
 (0)