Skip to content

Commit

Permalink
Merge tag 'v0.14.0-rc.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
evanp committed Sep 4, 2024
2 parents 81df8c0 + 337e90b commit 274f4c6
Show file tree
Hide file tree
Showing 141 changed files with 35,068 additions and 17,011 deletions.
Binary file modified .DS_Store
Binary file not shown.
23 changes: 20 additions & 3 deletions .github/workflows/web-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ jobs:
createdb -w -h localhost -p 5432 -U postgres citycatalyst -O citycatalyst
cp env.example .env
npm run db:migrate
npm run db:seed
- uses: actions/cache@v4
with:
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Run NextJS build
run: npm run build
Expand Down Expand Up @@ -129,16 +142,15 @@ jobs:
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 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}} \
SMTP_PASSWORD=${{secrets.SMTP_PASSWORD}} \
NEXTAUTH_SECRET=${{secrets.NEXTAUTH_SECRET}} \
RESET_TOKEN_SECRET=${{secrets.RESET_TOKEN_SECRET}} \
VERIFICATION_TOKEN_SECRET=${{secrets.VERIFICATION_TOKEN_SECRET}} \
OPENAI_API_KEY=${{secrets.OPENAI_API_KEY}} \
OPENAI_API_KEY=${{secrets.OPENAI_API_KEY_DEV}} \
"OPENAI_ASSISTANT_ID=asst_saoKNCVqCX7adTMoLqPxPHvB" \
HUGGINGFACE_API_KEY=${{secrets.HUGGINGFACE_API_KEY}} \
"ADMIN_EMAILS=${{secrets.ADMIN_EMAILS}}" \
"ADMIN_NAMES=${{secrets.ADMIN_NAMES}}" \
Expand All @@ -151,5 +163,10 @@ jobs:
"NEXT_PUBLIC_OPENCLIMATE_API_URL=https://openclimate.openearth.dev" \
"OPENCLIMATE_API_URL=https://openclimate.openearth.dev" \
CDP_API_KEY=${{secrets.CDP_API_KEY_TEST}}
kubectl apply -f k8s/cc-sync-catalogue.yml -n default # cronjob
kubectl create -f k8s/cc-sync-catalogue-manual.yml -n default # on deployment
# TODO this (running cronjob on deploy) doesn't work since it can't randomize names. Needs own randomness source
# once it works cc-sync-catalogue-manual.yml can be removed
# kubectl create job --from=cronjob/cc-sync-catalogue cc-sync-catalogue-manual -n default
kubectl create -f k8s/cc-create-admin.yml -n default
kubectl rollout restart deployment cc-web-deploy -n default
19 changes: 6 additions & 13 deletions .github/workflows/web-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,12 @@ jobs:
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}}" \
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}} \
OPENAI_API_KEY=${{secrets.OPENAI_API_KEY}} \
HUGGINGFACE_API_KEY=${{secrets.HUGGINGFACE_API_KEY}} \ "ADMIN_EMAILS=${{secrets.ADMIN_EMAILS}}" \
RESET_TOKEN_SECRET=${{secrets.RESET_TOKEN_SECRET}} \
VERIFICATION_TOKEN_SECRET=${{secrets.VERIFICATION_TOKEN_SECRET}} \
OPENAI_API_KEY=${{secrets.OPENAI_API_KEY_PROD}} \
"OPENAI_ASSISTANT_ID=asst_FCZ1wta3NElIFXCxDO1KME9I" \
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}}" \
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/web-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ jobs:
NEXTAUTH_SECRET=${{secrets.NEXTAUTH_SECRET}} \
RESET_TOKEN_SECRET=${{secrets.RESET_TOKEN_SECRET}} \
VERIFICATION_TOKEN_SECRET=${{secrets.VERIFICATION_TOKEN_SECRET}} \
OPENAI_API_KEY=${{secrets.OPENAI_API_KEY}} \
OPENAI_API_KEY=${{secrets.OPENAI_API_KEY_TEST}} \
"OPENAI_ASSISTANT_ID=asst_4if8qn6W8Vlxwbf2cuyH8OFU" \
HUGGINGFACE_API_KEY=${{secrets.HUGGINGFACE_API_KEY}} \
"ADMIN_EMAILS=${{secrets.ADMIN_EMAILS}}" \
"ADMIN_NAMES=${{secrets.ADMIN_NAMES}}" \
Expand Down
2 changes: 2 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ next-env.d.ts
/playwright-report/
/blob-report/
/playwright/.cache/

playwright/.auth
12 changes: 0 additions & 12 deletions app/cypress.config.ts

This file was deleted.

5 changes: 0 additions & 5 deletions app/cypress/fixtures/example.json

This file was deleted.

63 changes: 0 additions & 63 deletions app/cypress/support/commands.ts

This file was deleted.

20 changes: 0 additions & 20 deletions app/cypress/support/e2e.ts

This file was deleted.

8 changes: 0 additions & 8 deletions app/cypress/tsconfig.json

This file was deleted.

33 changes: 33 additions & 0 deletions app/e2e/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
test as setup,
expect,
test,
APIRequestContext,
} from "@playwright/test";
import { randomUUID } from "node:crypto";
import { expectText, signup } from "./helpers";

const authFile = "playwright/.auth/user.json";

test.beforeEach(async ({ page }) => {});

setup("authenticate", async ({ page, request }) => {
// log the user in
const email = `login-test+${randomUUID()}@openearth.org`;
const password = "Test123!";
await signup(request, email, password, password);

await page.goto("/en/auth/login");

await expectText(page, "Log In to City Catalyst");
await page.locator('input[name="email"]').fill(email);
await page.locator('input[name="password"]').fill(password);
await page.locator('button[type="submit"]').click();

// TODO how to ensure that session route was called?
await page.waitForResponse("/api/auth/session");

await expect(page).toHaveURL("/en/onboarding/");

await page.context().storageState({ path: authFile });
});
23 changes: 22 additions & 1 deletion app/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function signup(
inviteCode: string = "123456",
acceptTerms: boolean = true,
) {
const result = await request.post("/api/v0/auth/signup", {
const result = await request.post("/api/v0/auth/register", {
data: {
email,
password,
Expand All @@ -26,3 +26,24 @@ export async function signup(
expect(result.ok()).toBeTruthy();
return await result.json();
}

export async function createInventory(
request: APIRequestContext,
name: string,
description: string,
sector: string,
subsector: string,
methodology: string,
) {
const result = await request.post("/api/v0/inventory", {
data: {
name,
description,
sector,
subsector,
methodology,
},
});
expect(result.ok()).toBeTruthy();
return await result.json();
}
28 changes: 2 additions & 26 deletions app/e2e/login.spec.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
import { test, expect, APIRequestContext } from "@playwright/test";
import { expectText } from "./helpers";
import { expectText, signup } from "./helpers";
import { randomUUID } from "node:crypto";

async function signup(
request: APIRequestContext,
email: string,
password: string = "Test123!",
confirmPassword: string = "Test123!",
name: string = "Test Account",
inviteCode: string = "123456",
acceptTerms: boolean = true,
) {
const result = await request.post("/api/v0/auth/register", {
data: {
email,
password,
confirmPassword,
name,
inviteCode,
acceptTerms,
},
});
console.log("Signup res", await result.text());
expect(result.ok()).toBeTruthy();
return await result.json();
}

test.beforeEach(async ({ page }) => {
await page.goto("/en/auth/login");
});
Expand All @@ -50,7 +26,7 @@ test.describe("Login page", () => {
// TODO how to ensure that session route was called?
await page.waitForResponse("/api/auth/session");

await expect(page).toHaveURL("/en/onboarding/");
await expect(page).not.toHaveURL("/en/auth/login/");
});

test("shows errors when entering invalid data", async ({ page }) => {
Expand Down
Loading

0 comments on commit 274f4c6

Please sign in to comment.