Skip to content

Commit

Permalink
Merge pull request #1193 from AletheiaFact/stage
Browse files Browse the repository at this point in the history
Production Deployment v1.0.2
  • Loading branch information
thesocialdev authored May 26, 2024
2 parents c7d7d94 + a4a0b50 commit 073eeb6
Show file tree
Hide file tree
Showing 165 changed files with 3,271 additions and 851 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
AWS_ENDPOINT=http://localhost:4566

MONGO_MIGRATION_URL=
MONGO_MIGRATION_URL=

OPENAI_API_KEY=
3 changes: 3 additions & 0 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ env:
# Needed env variables for first build on next
NEXT_PUBLIC_UMAMI_SITE_ID: ${{ secrets.DEVELOPMENT_UMAMI_SITE_ID }}
NEXT_PUBLIC_RECAPTCHA_SITEKEY: ${{ secrets.RECAPTCHA_SITEKEY }}
AGENTS_API_URL: ${{ secrets.DEVELOPMENT_AGENTS_API_URL }}

jobs:
setup-build-publish:
Expand Down Expand Up @@ -67,6 +68,7 @@ jobs:
echo "NOVU_APPLICATION_IDENTIFIER=${{ secrets.PRODUCTION_NOVU_APPLICATION_IDENTIFIER }}" >> $GITHUB_ENV
echo "NEW_RELIC_APP_NAME=${{ secrets.PRODUCTION_NEW_RELIC_APP_NAME }}" >> $GITHUB_ENV
echo "NEXT_PUBLIC_ORY_SDK_URL=${{ secrets.ORY_SDK_URL }}" >> $GITHUB_ENV
echo "AGENTS_API_URL=${{ secrets.PRODUCTION_AGENTS_API_URL }}" >> $GITHUB_ENV
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
Expand Down Expand Up @@ -97,6 +99,7 @@ jobs:
sed -i "s%AWS_SECRET_ACCESS_KEY%$AWS_SECRET_ACCESS_KEY%g" config.$ENVIRONMENT.yaml
sed -i "s%NOVU_API_KEY%$NOVU_API_KEY%g" config.$ENVIRONMENT.yaml
sed -i "s%NOVU_APPLICATION_IDENTIFIER%$NOVU_APPLICATION_IDENTIFIER%g" config.$ENVIRONMENT.yaml
sed -i "s%AGENTS_API_URL%$AGENTS_API_URL%g" config.$ENVIRONMENT.yaml
- name: Set migrate-mongo-config.ts
run: |
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ COPY ./next-i18next.config.js /app/next-i18next.config.js
WORKDIR /app

RUN apk add --no-cache git python3 make g++
RUN yarn install
RUN yarn install --production
RUN NEXT_PUBLIC_UMAMI_SITE_ID=$NEXT_PUBLIC_UMAMI_SITE_ID \
NEXT_PUBLIC_RECAPTCHA_SITEKEY=$NEXT_PUBLIC_RECAPTCHA_SITEKEY \
NEXT_PUBLIC_ENVIRONMENT=$NEXT_PUBLIC_ENVIRONMENT \
Expand Down
1 change: 1 addition & 0 deletions config.development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
cors: '*'
debug: true
websocketUrl: wss://testws.aletheiafact.org
automatedFactCheckingAPIUrl: AGENTS_API_URL
override_public_routes: true
recaptcha_secret: RECAPTCHA_SECRET
recaptcha_sitekey: 6Lc2BtYUAAAAAOUBI-9r1sDJUIfG2nt6C43noOXh
Expand Down
2 changes: 1 addition & 1 deletion config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
cors: '*'
debug: true
websocketUrl: ws://localhost:5001
agentsUrl: http://localhost:8000
automatedFactCheckingAPIUrl: AGENTS_API_URL
#override_public_routes: true
recaptcha_secret: RECAPTCHA_SECRET
recaptcha_sitekey: 6Lc2BtYUAAAAAOUBI-9r1sDJUIfG2nt6C43noOXh
Expand Down
1 change: 1 addition & 0 deletions config.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
port: 3000
cors: '*'
websocketUrl: wss://ws.aletheiafact.org
automatedFactCheckingAPIUrl: AGENTS_API_URL
recaptcha_secret: RECAPTCHA_SECRET
recaptcha_sitekey: 6Lc2BtYUAAAAAOUBI-9r1sDJUIfG2nt6C43noOXh
db:
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/tests/review.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe("Test claim review", () => {
it("should be able to assign a user", () => {
cy.login();
goToClaimReviewPage();
cy.checkRecaptcha();
cy.get(locators.claimReview.BTN_START_CLAIM_REVIEW)
.should("exist")
.click();
Expand Down
152 changes: 76 additions & 76 deletions deployment/websocket.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
### INGRESS FRONTEND ###
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-aletheia-ws
namespace: ENVIRONMENT
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: testws.aletheiafact.org
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: aletheia-ws
port:
name: aletheia-ws
---
# ### INGRESS FRONTEND ###
# apiVersion: networking.k8s.io/v1
# kind: Ingress
# metadata:
# name: ingress-aletheia-ws
# namespace: ENVIRONMENT
# annotations:
# kubernetes.io/ingress.class: traefik
# spec:
# rules:
# - host: testws.aletheiafact.org
# http:
# paths:
# - path: /
# pathType: Prefix
# backend:
# service:
# name: aletheia-ws
# port:
# name: aletheia-ws
# ---
### SERVICE FRONTEND ###
apiVersion: v1
kind: Service
metadata:
name: aletheia-ws
namespace: ENVIRONMENT
spec:
type: NodePort
selector:
app: aletheia-ws
ports:
- name: aletheia-ws
targetPort: 5051
port: 80
---
### DEPLOYMENT FRONTEND ###
apiVersion: apps/v1
kind: Deployment
metadata:
name: aletheia-ws
namespace: ENVIRONMENT
spec:
replicas: 1
selector:
matchLabels:
app: aletheia-ws
template:
metadata:
labels:
app: aletheia-ws
spec:
containers:
- name: aletheia-ws
image: 134187360702.dkr.ecr.us-east-1.amazonaws.com/aletheiafact-production:TAG
args: ["-c", "config.websocket.yaml"]
imagePullPolicy: Always
readinessProbe:
httpGet:
path: /api/health
port: 5051
initialDelaySeconds: 50
timeoutSeconds: 5
livenessProbe:
httpGet:
path: /api/health
port: 5051
initialDelaySeconds: 50
timeoutSeconds: 10
failureThreshold: 10
resources:
limits:
cpu: 120m
memory: 256Mi
requests:
cpu: 80m
memory: 128Mi
# apiVersion: v1
# kind: Service
# metadata:
# name: aletheia-ws
# namespace: ENVIRONMENT
# spec:
# type: NodePort
# selector:
# app: aletheia-ws
# ports:
# - name: aletheia-ws
# targetPort: 5051
# port: 80
# ---
# ### DEPLOYMENT FRONTEND ###
# apiVersion: apps/v1
# kind: Deployment
# metadata:
# name: aletheia-ws
# namespace: ENVIRONMENT
# spec:
# replicas: 1
# selector:
# matchLabels:
# app: aletheia-ws
# template:
# metadata:
# labels:
# app: aletheia-ws
# spec:
# containers:
# - name: aletheia-ws
# image: 134187360702.dkr.ecr.us-east-1.amazonaws.com/aletheiafact-production:TAG
# args: ["-c", "config.websocket.yaml"]
# imagePullPolicy: Always
# readinessProbe:
# httpGet:
# path: /api/health
# port: 5051
# initialDelaySeconds: 50
# timeoutSeconds: 5
# livenessProbe:
# httpGet:
# path: /api/health
# port: 5051
# initialDelaySeconds: 50
# timeoutSeconds: 10
# failureThreshold: 10
# resources:
# limits:
# cpu: 120m
# memory: 256Mi
# requests:
# cpu: 80m
# memory: 128Mi
39 changes: 30 additions & 9 deletions lib/editor-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ReviewTaskMachineContextReviewData } from "../server/claim-review-task/

const EditorSchemaArray = ["summary", "report", "verification", "questions"];

const MarkupCleanerRegex = /{{[^|]+\|([^}]+)}}/;

const defaultDoc: RemirrorJSON = {
type: "doc",
content: [
Expand Down Expand Up @@ -54,8 +56,10 @@ export class EditorParser {
return fragmentText;
}

if (type === "source" && fragmentText === targetText) {
return `<a href='#${fragmentText}' rel='noopener noreferrer nofollow'>${fragmentText}<sup>${sup}</sup></a>`;
const parsedFragmentText = this.extractTextFromMarkUp(fragmentText);

if (type === "source" && parsedFragmentText === targetText) {
return `<a href='#${parsedFragmentText}' rel='noopener noreferrer nofollow'>${parsedFragmentText}<sup>${sup}</sup></a>`;
}
return fragmentText;
}
Expand Down Expand Up @@ -187,8 +191,15 @@ export class EditorParser {
schema.sources.push(
...this.getSourcesFromEditorMarks(text, type, marks)
);
const markId = marks.map(
({ attrs }: ObjectMark) => attrs.id
);

// Pushing the text into content with markup based on its source id
sourceContent.push(`{{${markId}|${text}}}`);
} else {
sourceContent.push(text);
}
sourceContent.push(text);
}
}
}
Expand Down Expand Up @@ -219,7 +230,8 @@ export class EditorParser {
field,
textRange: this.findTextRange(
schema[field],
textRange
textRange,
id
),
targetText: textRange,
sup: index + 1,
Expand All @@ -232,13 +244,15 @@ export class EditorParser {
return newSources.sort((a, b) => a.sup - b.sup);
}

findTextRange(content, textTarget) {
findTextRange(content, textTarget, sourceId) {
const contentArray = Array.isArray(content) ? content : [content];
const markUpText = `{{${sourceId}|${textTarget}}}`;

// Looks for the specific text with the right markup and returns the range of the marked-up text
return contentArray.flatMap((c) => {
const start = c.indexOf(textTarget);
const start = c.indexOf(markUpText);
if (start !== -1) {
const end = start + textTarget.length;
const end = start + markUpText.length;
return [start, end];
}
return [];
Expand Down Expand Up @@ -305,16 +319,18 @@ export class EditorParser {
const { textRange, targetText, id } = props;
const fragmentText = content.slice(...textRange);

const parsedFragmentText = this.extractTextFromMarkUp(fragmentText);

switch (type) {
case "text":
if (fragmentText) {
return this.getContentObject(fragmentText);
}
break;
case "source":
if (fragmentText === targetText) {
if (parsedFragmentText === targetText) {
return this.getContentObjectWithMarks(
fragmentText,
parsedFragmentText,
href,
id
);
Expand Down Expand Up @@ -465,4 +481,9 @@ export class EditorParser {
],
}));
}

extractTextFromMarkUp(fragmentText) {
const match = fragmentText.match(MarkupCleanerRegex);
return match ? match[1] : "";
}
}
Loading

0 comments on commit 073eeb6

Please sign in to comment.