Skip to content

Commit

Permalink
Merge branch 'develop' into on-1849
Browse files Browse the repository at this point in the history
  • Loading branch information
lemilonkh authored Jul 17, 2024
2 parents e0ceb08 + 5fbe4c8 commit e363dc8
Show file tree
Hide file tree
Showing 83 changed files with 119,719 additions and 43,463 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/web-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
# run: npm run cy:test

- name: Run tests and generate coverage file
run: npm run ci:test
run: npm run api:test

- name: Install Playwright Browsers
run: npx playwright install --with-deps
Expand Down Expand Up @@ -132,17 +132,24 @@ jobs:
kubectl apply -f k8s/cc-sync-catalogue.yml -n default
# kubectl create job --from=cronjob/cc-sync-catalogue cc-sync-catalogue-manual -n default
kubectl apply -f k8s/cc-web-deploy.yml -n default
kubectl set env deployment/cc-web-deploy SMTP_USER=${{secrets.SMTP_USER}}
kubectl set env deployment/cc-web-deploy SMTP_PASSWORD=${{secrets.SMTP_PASSWORD}}
kubectl set env deployment/cc-web-deploy NEXTAUTH_SECRET=${{secrets.NEXTAUTH_SECRET}}
kubectl set env deployment/cc-web-deploy RESET_TOKEN_SECRET=${{secrets.RESET_TOKEN_SECRET}}
kubectl set env deployment/cc-web-deploy VERIFICATION_TOKEN_SECRET=${{secrets.VERIFICATION_TOKEN_SECRET}}
kubectl set env deployment/cc-web-deploy CHAT_PROVIDER=openai
kubectl set env deployment/cc-web-deploy OPENAI_API_KEY=${{secrets.OPENAI_API_KEY}}
kubectl set env deployment/cc-web-deploy HUGGINGFACE_API_KEY=${{secrets.HUGGINGFACE_API_KEY}}
kubectl set env deployment/cc-web-deploy "ADMIN_EMAILS=${{secrets.ADMIN_EMAILS}}"
kubectl set env deployment/cc-web-deploy "ADMIN_NAMES=${{secrets.ADMIN_NAMES}}"
kubectl set env deployment/cc-web-deploy "DEFAULT_ADMIN_EMAIL=${{secrets.DEFAULT_ADMIN_EMAIL}}"
kubectl set env deployment/cc-web-deploy "DEFAULT_ADMIN_PASSWORD=${{secrets.DEFAULT_ADMIN_PASSWORD}}"
kubectl set env deployment/cc-web-deploy \
SMTP_USER=${{secrets.SMTP_USER}} \
SMTP_PASSWORD=${{secrets.SMTP_PASSWORD}} \
NEXTAUTH_SECRET=${{secrets.NEXTAUTH_SECRET}} \
RESET_TOKEN_SECRET=${{secrets.RESET_TOKEN_SECRET}} \
VERIFICATION_TOKEN_SECRET=${{secrets.VERIFICATION_TOKEN_SECRET}} \
CHAT_PROVIDER=openai \
OPENAI_API_KEY=${{secrets.OPENAI_API_KEY}} \
HUGGINGFACE_API_KEY=${{secrets.HUGGINGFACE_API_KEY}} \
"ADMIN_EMAILS=${{secrets.ADMIN_EMAILS}}" \
"ADMIN_NAMES=${{secrets.ADMIN_NAMES}}" \
"DEFAULT_ADMIN_EMAIL=${{secrets.DEFAULT_ADMIN_EMAIL}}" \
"DEFAULT_ADMIN_PASSWORD=${{secrets.DEFAULT_ADMIN_PASSWORD}}" \
"HOST=https://citycatalyst.openearth.dev" \
"NEXTAUTH_URL=https://citycatalyst.openearth.dev" \
"NEXT_PUBLIC_API_URL=https://citycatalyst.openearth.dev" \
"GLOBAL_API_URL=https://ccglobal.openearth.dev" \
"NEXT_PUBLIC_OPENCLIMATE_API_URL=https://openclimate.openearth.dev" \
"OPENCLIMATE_API_URL=https://openclimate.openearth.dev"
kubectl create -f k8s/cc-create-admin.yml -n default
kubectl rollout restart deployment cc-web-deploy -n default
40 changes: 22 additions & 18 deletions .github/workflows/web-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ on:
push:
paths:
- app/**
- k8s/cc-migrate.yml
- k8s/cc-web-deploy.yml
- k8s/prod/cc-prod-migrate.yml
- k8s/prod/cc-prod-seed.yml
- k8s/prod/cc-prod-sync-catalogue.yml
- k8s/prod/cc-prod-create-admin.yml
- k8s/cc-web.yml
- k8s/cc-web-deploy.yml
- .github/workflows/web-tag.yml
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
Expand Down Expand Up @@ -121,28 +124,29 @@ jobs:

- name: Deploying service
run: |
kubectl create -f k8s/cc-migrate.yml -n default
kubectl create -f k8s/cc-seed.yml -n default
kubectl apply -f k8s/cc-sync-catalogue.yml -n default
kubectl create -f k8s/prod/cc-prod-migrate.yml -n default
kubectl create -f k8s/prod/cc-prod-seed.yml -n default
kubectl apply -f k8s/prod/cc-prod-sync-catalogue.yml -n default
kubectl apply -f k8s/cc-web-deploy.yml -n default
kubectl set env deployment/cc-web-deploy SMTP_USER=${{secrets.SMTP_USER}}
kubectl set env deployment/cc-web-deploy SMTP_PASSWORD=${{secrets.SMTP_PASSWORD}}
kubectl set env deployment/cc-web-deploy NEXTAUTH_SECRET=${{secrets.NEXTAUTH_SECRET}}
kubectl set env deployment/cc-web-deploy RESET_TOKEN_SECRET=${{secrets.RESET_TOKEN_SECRET}}
kubectl set env deployment/cc-web-deploy VERIFICATION_TOKEN_SECRET=${{secrets.VERIFICATION_TOKEN_SECRET}}
kubectl set env deployment/cc-web-deploy CHAT_PROVIDER=openai
kubectl set env deployment/cc-web-deploy OPENAI_API_KEY=${{secrets.OPENAI_API_KEY}}
kubectl set env deployment/cc-web-deploy HUGGINGFACE_API_KEY=${{secrets.HUGGINGFACE_API_KEY}}
kubectl set env deployment/cc-web-deploy "ADMIN_EMAILS=${{secrets.ADMIN_EMAILS}}"
kubectl set env deployment/cc-web-deploy "ADMIN_NAMES=${{secrets.ADMIN_NAMES}}"
kubectl set env deployment/cc-web-deploy "DEFAULT_ADMIN_EMAIL=${{secrets.DEFAULT_ADMIN_EMAIL}}"
kubectl set env deployment/cc-web-deploy "DEFAULT_ADMIN_PASSWORD=${{secrets.DEFAULT_ADMIN_PASSWORD}}"
kubectl set image deployment/cc-web-deploy \
cc-web=ghcr.io/open-earth-foundation/citycatalyst:stable \
-n default
kubectl set env deployment/cc-web-deploy \
SMTP_USER=${{secrets.SMTP_USER}} \
SMTP_PASSWORD=${{secrets.SMTP_PASSWORD}} \
NEXTAUTH_SECRET=${{secrets.NEXTAUTH_SECRET}} \
RESET_TOKEN_SECRET=${{secrets.RESET_TOKEN_SECRET}} \ VERIFICATION_TOKEN_SECRET=${{secrets.VERIFICATION_TOKEN_SECRET}} \
CHAT_PROVIDER=openai \
OPENAI_API_KEY=${{secrets.OPENAI_API_KEY}} \
HUGGINGFACE_API_KEY=${{secrets.HUGGINGFACE_API_KEY}} \ "ADMIN_EMAILS=${{secrets.ADMIN_EMAILS}}" \
"ADMIN_NAMES=${{secrets.ADMIN_NAMES}}" \
"DEFAULT_ADMIN_EMAIL=${{secrets.DEFAULT_ADMIN_EMAIL}}" \
"DEFAULT_ADMIN_PASSWORD=${{secrets.DEFAULT_ADMIN_PASSWORD}}" \
"HOST=https://citycatalyst.io" \
"NEXTAUTH_URL=https://citycatalyst.io" \
"NEXT_PUBLIC_API_URL=https://api.citycatalyst.io" \
"GLOBAL_API_URL=https://api.citycatalyst.io" \
"NEXT_PUBLIC_OPENCLIMATE_API_URL=https://app.openclimate.network" \
"OPENCLIMATE_API_URL=https://app.openclimate.network"
kubectl create -f k8s/cc-create-admin.yml -n default
kubectl create -f k8s/prod/cc-prod-create-admin.yml -n default
kubectl rollout restart deployment cc-web-deploy -n default
33 changes: 20 additions & 13 deletions .github/workflows/web-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: npm run build

- name: Run tests and generate coverage file
run: npm run ci:test
run: npm run api:test

- name: Install Playwright Browsers
run: npx playwright install --with-deps
Expand Down Expand Up @@ -119,17 +119,24 @@ jobs:
kubectl create -f k8s/test/cc-test-seed.yml -n default
kubectl apply -f k8s/test/cc-test-sync-catalogue.yml -n default
kubectl apply -f k8s/test/cc-test-web-deploy.yml -n default
kubectl set env deployment/cc-test-web-deploy SMTP_USER=${{secrets.SMTP_USER}}
kubectl set env deployment/cc-test-web-deploy SMTP_PASSWORD=${{secrets.SMTP_PASSWORD}}
kubectl set env deployment/cc-test-web-deploy NEXTAUTH_SECRET=${{secrets.NEXTAUTH_SECRET}}
kubectl set env deployment/cc-test-web-deploy RESET_TOKEN_SECRET=${{secrets.RESET_TOKEN_SECRET}}
kubectl set env deployment/cc-test-web-deploy VERIFICATION_TOKEN_SECRET=${{secrets.VERIFICATION_TOKEN_SECRET}}
kubectl set env deployment/cc-test-web-deploy CHAT_PROVIDER=openai
kubectl set env deployment/cc-test-web-deploy OPENAI_API_KEY=${{secrets.OPENAI_API_KEY}}
kubectl set env deployment/cc-test-web-deploy HUGGINGFACE_API_KEY=${{secrets.HUGGINGFACE_API_KEY}}
kubectl set env deployment/cc-web-deploy "ADMIN_EMAILS=${{secrets.ADMIN_EMAILS}}"
kubectl set env deployment/cc-web-deploy "ADMIN_NAMES=${{secrets.ADMIN_NAMES}}"
kubectl set env deployment/cc-test-web-deploy "DEFAULT_ADMIN_EMAIL=${{secrets.DEFAULT_ADMIN_EMAIL}}"
kubectl set env deployment/cc-test-web-deploy "DEFAULT_ADMIN_PASSWORD=${{secrets.DEFAULT_ADMIN_PASSWORD}}"
kubectl set env deployment/cc-test-web-deploy \
SMTP_USER=${{secrets.SMTP_USER}} \
SMTP_PASSWORD=${{secrets.SMTP_PASSWORD}} \
NEXTAUTH_SECRET=${{secrets.NEXTAUTH_SECRET}} \
RESET_TOKEN_SECRET=${{secrets.RESET_TOKEN_SECRET}} \
VERIFICATION_TOKEN_SECRET=${{secrets.VERIFICATION_TOKEN_SECRET}} \
CHAT_PROVIDER=openai \
OPENAI_API_KEY=${{secrets.OPENAI_API_KEY}} \
HUGGINGFACE_API_KEY=${{secrets.HUGGINGFACE_API_KEY}} \
"ADMIN_EMAILS=${{secrets.ADMIN_EMAILS}}" \
"ADMIN_NAMES=${{secrets.ADMIN_NAMES}}" \
"DEFAULT_ADMIN_EMAIL=${{secrets.DEFAULT_ADMIN_EMAIL}}" \
"DEFAULT_ADMIN_PASSWORD=${{secrets.DEFAULT_ADMIN_PASSWORD}}" \
"HOST=https://citycatalyst-test.openearth.dev" \
"NEXTAUTH_URL=https://citycatalyst-test.openearth.dev" \
"NEXT_PUBLIC_API_URL=https://citycatalyst-test.openearth.dev" \
"GLOBAL_API_URL=https://ccglobal-test.openearth.dev" \
"NEXT_PUBLIC_OPENCLIMATE_API_URL=https://openclimate.openearth.dev" \
"OPENCLIMATE_API_URL=https://openclimate.openearth.dev"
kubectl create -f k8s/test/cc-test-create-admin.yml -n default
kubectl rollout restart deployment cc-test-web-deploy -n default
35 changes: 33 additions & 2 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
This is the main CityCatalyst Web app. This directory includes both the
frontend and backend code for the app, as well as database management scripts.

## Prerequisites

This guide assumes you have installed and access to the following tools:

1. git command line interface. Please follow [this link](https://git-scm.com/downloads) for installation instructions.
2. Node.js and the node package manager npm. Please follow [this link](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) for installation instructions.
3. (optional) docker engine. Docker is not strictly necessary but recommended. It makes the setup of the database service much easier. Please follow [this link](https://docs.docker.com/engine/install/) for installation instructions.
4. (optional, Windows OS only) Windows Subsystem for Linux WSL2. This step is only needed for running the convenience shell scripts below e.g. for setting up the Postgres database via docker. Different Linux subsystems can be installed. The following link is for Ubuntu. Please follow [this link](https://ubuntu.com/desktop/wsl) for installation instructions.

## Installation

### Code
Expand All @@ -22,7 +31,22 @@ npm install

### Database

For a quick setup, run `scripts/start-db.sh`, which will launch a PostgreSQL Docker image with the right configuration. Otherwise continue below ⬇️
#### Automated setup via Docker

For a quick setup, run `scripts/start-db.sh`, which will launch a PostgreSQL Docker image with the right configuration.

Note for Windows users only: Make sure you run this script in the WSL2 environment. Since WSL2 does not share the same resources as the Windows host system, you have to configure the integration of docker with the WSL2 system. For this, open Docker Desktop, go to `Settings > Resources > WSL integration` and activate `Enable integration with my default WSL distro` and make sure your Linux distribution is listed and enabled.

Run the following command.

```bash
cd app/scripts/
bash start-db.sh
```

If you use this script, continue at [Environment](#environment). Otherwise continue below ⬇️ with the manual setup of the database service.

#### Manual setup

You'll need to run a [PostgreSQL](https://www.postgresql.org/) database, locally or remotely.

Expand Down Expand Up @@ -82,7 +106,10 @@ To run the app in development mode, run:

```bash
cd CityCatalyst/app
cp env.example .env

## if you have copied and renamed the env.example file in the step under 'Environment',
## skip the next line otherwise remove the comment in the next line
#cp env.example .env

## set up your database credentials in .env file

Expand All @@ -96,6 +123,10 @@ npm run create-admin
npm run dev
```

The standard port is 3000 and the application can be opend at http://localhost:3000. Please check the log outputs, if a different port has been used.

Use `[email protected]` and `password` to login.

### Docker

You can also run the app in a Docker container. To do so, you'll need to build the Docker image:
Expand Down
2 changes: 1 addition & 1 deletion app/env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ CHAT_PROVIDER=huggingface
ADMIN_EMAILS="[email protected]"
ADMIN_NAMES="John doe"
NEXT_PUBLIC_OPENCLIMATE_API_URL="https://openclimate.openearth.dev"
DEFAULT_ADMIN_EMAIL=johndeo@example.com
DEFAULT_ADMIN_EMAIL=johndoe@example.com
DEFAULT_ADMIN_PASSWORD=password
22 changes: 22 additions & 0 deletions app/migrations/20240627123051-EmissionsFactor-add-columns.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const columns = ["actor_id", "methodology_name"];

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
return queryInterface.sequelize.transaction(async (transaction) => {
for (const column of columns) {
await queryInterface.addColumn("EmissionsFactor", column, Sequelize.TEXT, { transaction });
}
});
},

async down(queryInterface) {
return queryInterface.sequelize.transaction(async (transaction) => {
for (const column of columns) {
await queryInterface.removeColumn("EmissionsFactor", column, { transaction });
}
});
}
};
Loading

0 comments on commit e363dc8

Please sign in to comment.