Skip to content

Commit

Permalink
Merge pull request #3138 from responsible-ai-collaborative/staging
Browse files Browse the repository at this point in the history
Deploy to Production
  • Loading branch information
kepae authored Oct 7, 2024
2 parents 9979e36 + 2bd64ab commit ed115cb
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/db-backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
inputs:
environment:
description: The Github environment to load secrets from
type: string
type: string
required: true

defaults:
Expand All @@ -25,26 +25,30 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
coreutils \
bash \
tzdata \
python3-pip \
curl \
npm
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb.gpg > /dev/null
echo "deb [ arch=amd64 signed-by=/usr/share/keyrings/mongodb.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt update
sudo apt install -y mongodb-database-tools
- name: Install boto3
run: pip install boto3
- name: Generate public backup
run: |
python3 -m venv venv
source venv/bin/activate
pip install boto3
./bin/backup.sh
./bin/prune.sh
./bin/list.sh
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ jobs:
E2E_ADMIN_USERNAME: ""
E2E_ADMIN_PASSWORD: ""
ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN: ${{ secrets.GATSBY_ROLLBAR_TOKEN }}
SENDGRID_API_KEY: something
SENDGRID_SENDER_NAME: Test Preview
SENDGRID_SENDER: [email protected]
PROCESS_NOTIFICATIONS_SECRET: sarasa

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-playwright-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ jobs:
SHARD_INDEX: ${{ matrix.shardIndex }}
SHARD_TOTAL: ${{ matrix.shardTotal }}
TEST_FOLDER: playwright/e2e-full/
SENDGRID_API_KEY: something
SENDGRID_SENDER_NAME: Test Preview
SENDGRID_SENDER: [email protected]
PROCESS_NOTIFICATIONS_SECRET: sarasa

- name: Upload Playwright traces
if: failure()
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ jobs:
SHARD_INDEX: ${{ matrix.shardIndex }}
SHARD_TOTAL: ${{ matrix.shardTotal }}
TEST_FOLDER: playwright/e2e/
SENDGRID_API_KEY: something
SENDGRID_SENDER_NAME: Test Preview
SENDGRID_SENDER: [email protected]
PROCESS_NOTIFICATIONS_SECRET: sarasa

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const config = require('../config');

/** @type {import('umzug').MigrationFn<any>} */
exports.up = async ({ context: { client } }) => {
// If the incident has "epoch_date_modified" field and it is null, unset it
const incidents_collection = client
.db(config.realm.production_db.db_name)
.collection('incidents');

const incidents_epoch_date_modified_results = await incidents_collection.updateMany(
{ epoch_date_modified: null },
{ $unset: { epoch_date_modified: '' } }
);

console.log(
`Updated ${incidents_epoch_date_modified_results.modifiedCount} incidents with null epoch_date_modified field`
);

// If the report has "epoch_date_modified" field and it is null, unset it
const reports_collection = client.db(config.realm.production_db.db_name).collection('reports');

const reports_epoch_date_modified_results = await reports_collection.updateMany(
{ epoch_date_modified: null },
{ $unset: { epoch_date_modified: '' } }
);

console.log(
`Updated ${reports_epoch_date_modified_results.modifiedCount} reports with null epoch_date_modified field`
);
};
9 changes: 7 additions & 2 deletions site/gatsby-site/server/fields/submissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export const mutationFields: GraphQLFieldConfigMap<any, Context> = {
reports: [],
editors,
date: submission.incident_date,
epoch_date_modified: submission.epoch_date_modified,
"Alleged deployer of AI system": submission.deployers || [],
"Alleged developer of AI system": submission.developers || [],
"Alleged harmed or nearly harmed parties": submission.harmed_parties || [],
Expand All @@ -113,6 +112,9 @@ export const mutationFields: GraphQLFieldConfigMap<any, Context> = {
from_reports: [report_number]
}
}
if(submission.epoch_date_modified) {
newIncident.epoch_date_modified = submission.epoch_date_modified;
}

await incidents.insertOne({ ...newIncident, incident_id: newIncident.incident_id });

Expand Down Expand Up @@ -214,7 +216,6 @@ export const mutationFields: GraphQLFieldConfigMap<any, Context> = {
date_published: new Date(submission.date_published),
date_submitted: new Date(submission.date_submitted),
epoch_date_downloaded: getUnixTime(submission.date_downloaded),
epoch_date_modified: submission.epoch_date_modified,
epoch_date_published: getUnixTime(submission.date_published),
epoch_date_submitted: getUnixTime(submission.date_submitted),
image_url: submission.image_url,
Expand All @@ -237,6 +238,10 @@ export const mutationFields: GraphQLFieldConfigMap<any, Context> = {
newReport.user = submission.user;
}

if(submission.epoch_date_modified) {
newReport.epoch_date_modified = submission.epoch_date_modified;
}

await reports.insertOne({ ...newReport, report_number: newReport.report_number });

const incident_ids: number[] = parentIncidents.map(incident => incident.incident_id!);
Expand Down

0 comments on commit ed115cb

Please sign in to comment.