Skip to content

Commit

Permalink
Merge pull request #1247 from AletheiaFact/stage
Browse files Browse the repository at this point in the history
Production Release
  • Loading branch information
thesocialdev authored Jul 18, 2024
2 parents 9376249 + afb5a1a commit 4f7a943
Show file tree
Hide file tree
Showing 335 changed files with 7,944 additions and 3,926 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ AWS_ENDPOINT=http://localhost:4566

MONGO_MIGRATION_URL=

OPENAI_API_KEY=
OPENAI_API_KEY=

ZENVIA_API_URL=
ZENVIA_API_TOKEN=
84 changes: 46 additions & 38 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ env:
NEXT_PUBLIC_RECAPTCHA_SITEKEY: ${{ secrets.RECAPTCHA_SITEKEY }}
AGENTS_API_URL: ${{ secrets.DEVELOPMENT_AGENTS_API_URL }}
OPENAI_API_KEY: ${{ secrets.DEVELOPMENT_OPENAI_API_KEY }}
ZENVIA_API_URL: ${{ secrets.DEVELOPMENT_ZENVIA_API_URL }}
ZENVIA_API_TOKEN: ${{ secrets.DEVELOPMENT_ZENVIA_API_URL }}

jobs:
setup-build-publish:
Expand Down Expand Up @@ -71,6 +73,8 @@ jobs:
echo "NEXT_PUBLIC_ORY_SDK_URL=${{ secrets.ORY_SDK_URL }}" >> $GITHUB_ENV
echo "AGENTS_API_URL=${{ secrets.PRODUCTION_AGENTS_API_URL }}" >> $GITHUB_ENV
echo "OPENAI_API_KEY=${{ secrets.PRODUCTION_OPENAI_API_KEY }}" >> $GITHUB_ENV
echo "ZENVIA_API_URL=${{ secrets.PRODUCTION_ZENVIA_API_URL }}" >> $GITHUB_ENV
echo "ZENVIA_API_TOKEN=${{ secrets.PRODUCTION_ZENVIA_API_TOKEN }}" >> $GITHUB_ENV
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -86,48 +90,50 @@ jobs:
# Setting up config.yaml based on environment
- name: Set config.yaml
env:
RECAPTCHA_SECRET: ${{ secrets.RECAPTCHA_SECRETKEY }}
RECAPTCHA_SECRET: ${{ secrets.RECAPTCHA_SECRETKEY }}
run: |
sed -i "s/ENV/$ENVIRONMENT/g" config.$ENVIRONMENT.yaml
sed -i "s%RECAPTCHA_SECRET%$RECAPTCHA_SECRET%g" config.$ENVIRONMENT.yaml
sed -i "s%MONGODB_URI%$MONGODB_URI%g" config.$ENVIRONMENT.yaml
sed -i "s%ORY_SDK_URL%$ORY_SDK_URL%g" config.$ENVIRONMENT.yaml
sed -i "s%GITLAB_FEATURE_FLAG_URL%$GITLAB_FEATURE_FLAG_URL%g" config.$ENVIRONMENT.yaml
sed -i "s%GITLAB_FEATURE_FLAG_INSTANCE_ID%$GITLAB_FEATURE_FLAG_INSTANCE_ID%g" config.$ENVIRONMENT.yaml
sed -i "s/ORY_ACCESS_TOKEN/$ORY_ACCESS_TOKEN/g" config.$ENVIRONMENT.yaml
sed -i "s/ALETHEIA_SCHEMA_ID/$ALETHEIA_SCHEMA_ID/g" config.$ENVIRONMENT.yaml
sed -i "s%AWS_SDK_BUCKET%$AWS_SDK_BUCKET%g" config.$ENVIRONMENT.yaml
sed -i "s%AWS_ACCESS_KEY_ID%$AWS_ACCESS_KEY_ID%g" config.$ENVIRONMENT.yaml
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
sed -i "s%OPENAI_API_KEY%$OPENAI_API_KEY%g" config.$ENVIRONMENT.yaml
sed -i "s/ENV/$ENVIRONMENT/g" config.$ENVIRONMENT.yaml
sed -i "s%RECAPTCHA_SECRET%$RECAPTCHA_SECRET%g" config.$ENVIRONMENT.yaml
sed -i "s%MONGODB_URI%$MONGODB_URI%g" config.$ENVIRONMENT.yaml
sed -i "s%ORY_SDK_URL%$ORY_SDK_URL%g" config.$ENVIRONMENT.yaml
sed -i "s%GITLAB_FEATURE_FLAG_URL%$GITLAB_FEATURE_FLAG_URL%g" config.$ENVIRONMENT.yaml
sed -i "s%GITLAB_FEATURE_FLAG_INSTANCE_ID%$GITLAB_FEATURE_FLAG_INSTANCE_ID%g" config.$ENVIRONMENT.yaml
sed -i "s/ORY_ACCESS_TOKEN/$ORY_ACCESS_TOKEN/g" config.$ENVIRONMENT.yaml
sed -i "s/ALETHEIA_SCHEMA_ID/$ALETHEIA_SCHEMA_ID/g" config.$ENVIRONMENT.yaml
sed -i "s%AWS_SDK_BUCKET%$AWS_SDK_BUCKET%g" config.$ENVIRONMENT.yaml
sed -i "s%AWS_ACCESS_KEY_ID%$AWS_ACCESS_KEY_ID%g" config.$ENVIRONMENT.yaml
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
sed -i "s%OPENAI_API_KEY%$OPENAI_API_KEY%g" config.$ENVIRONMENT.yaml
sed -i "s%ZENVIA_API_URL%$ZENVIA_API_URL%g" config.$ENVIRONMENT.yaml
sed -i "s%ZENVIA_API_TOKEN%$ZENVIA_API_TOKEN%g" config.$ENVIRONMENT.yaml
- name: Set migrate-mongo-config.ts
run: |
sed -i "s%MONGODB_URI%$MONGODB_URI%g" migrate-mongo-config-example.ts
sed -i "s%MONGODB_NAME%$MONGODB_NAME%g" migrate-mongo-config-example.ts
sed -i "s%MONGODB_URI%$MONGODB_URI%g" migrate-mongo-config-example.ts
sed -i "s%MONGODB_NAME%$MONGODB_NAME%g" migrate-mongo-config-example.ts
# Setting user seed config
- name: Set config.seed.example.yaml
env:
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_EMAIL_USER: ${{ secrets.SMTP_EMAIL_USER }}
SMTP_EMAIL_PASS: ${{ secrets.SMTP_EMAIL_PASS }}
TEST_USER_PASS: ${{ secrets.TEST_USER_PASS }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_EMAIL_USER: ${{ secrets.SMTP_EMAIL_USER }}
SMTP_EMAIL_PASS: ${{ secrets.SMTP_EMAIL_PASS }}
TEST_USER_PASS: ${{ secrets.TEST_USER_PASS }}

run: |
sed -i "s%SMTP_HOST%$SMTP_HOST%g" config.seed.example.yaml
sed -i "s%SMTP_PORT%$SMTP_PORT%g" config.seed.example.yaml
sed -i "s%SMTP_EMAIL_USER%$SMTP_EMAIL_USER%g" config.seed.example.yaml
sed -i "s%SMTP_EMAIL_PASS%$SMTP_EMAIL_PASS%g" config.seed.example.yaml
sed -i "s/TEST_USER_PASS/$TEST_USER_PASS/g" config.seed.example.yaml
sed -i "s%MONGODB_URI%$MONGODB_URI%g" config.seed.example.yaml
sed -i "s%ORY_SDK_URL%$ORY_SDK_URL%g" config.seed.example.yaml
sed -i "s/ORY_ACCESS_TOKEN/$ORY_ACCESS_TOKEN/g" config.seed.example.yaml
sed -i "s/ALETHEIA_SCHEMA_ID/$ALETHEIA_SCHEMA_ID/g" config.seed.example.yaml
sed -i "s%SMTP_HOST%$SMTP_HOST%g" config.seed.example.yaml
sed -i "s%SMTP_PORT%$SMTP_PORT%g" config.seed.example.yaml
sed -i "s%SMTP_EMAIL_USER%$SMTP_EMAIL_USER%g" config.seed.example.yaml
sed -i "s%SMTP_EMAIL_PASS%$SMTP_EMAIL_PASS%g" config.seed.example.yaml
sed -i "s/TEST_USER_PASS/$TEST_USER_PASS/g" config.seed.example.yaml
sed -i "s%MONGODB_URI%$MONGODB_URI%g" config.seed.example.yaml
sed -i "s%ORY_SDK_URL%$ORY_SDK_URL%g" config.seed.example.yaml
sed -i "s/ORY_ACCESS_TOKEN/$ORY_ACCESS_TOKEN/g" config.seed.example.yaml
sed -i "s/ALETHEIA_SCHEMA_ID/$ALETHEIA_SCHEMA_ID/g" config.seed.example.yaml
# Build the Docker image
- name: Build
Expand Down Expand Up @@ -174,6 +180,8 @@ jobs:
echo "NOVU_API_KEY=${{ secrets.PRODUCTION_NOVU_API_KEY }}" >> $GITHUB_ENV
echo "NOVU_APPLICATION_IDENTIFIER=${{ secrets.PRODUCTION_NOVU_APPLICATION_IDENTIFIER }}" >> $GITHUB_ENV
echo "OPENAI_API_KEY=${{ secrets.PRODUCTION_OPENAI_API_KEY }}" >> $GITHUB_ENV
echo "ZENVIA_API_URL=${{ secrets.PRODUCTION_ZENVIA_API_URL }}" >> $GITHUB_ENV
echo "ZENVIA_API_TOKEN=${{ secrets.PRODUCTION_ZENVIA_API_TOKEN }}" >> $GITHUB_ENV
- name: Set environment
run: |
Expand All @@ -199,17 +207,17 @@ jobs:
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'us-east-1'
cluster-name: 'production'
aws-region: "us-east-1"
cluster-name: "production"
command: kubectl apply -f ./deployment/

- name: Validation
uses: giovannirossini/[email protected]
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'us-east-1'
cluster-name: 'production'
aws-region: "us-east-1"
cluster-name: "production"
command: kubectl rollout status deployments/aletheia -n ${{ env.ENVIRONMENT }} --timeout=360s
if: success()

Expand All @@ -218,7 +226,7 @@ jobs:
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'us-east-1'
cluster-name: 'production'
aws-region: "us-east-1"
cluster-name: "production"
command: kubectl rollout undo deployments/aletheia -n ${{ env.ENVIRONMENT }}
if: failure()
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# dependencies
/node_modules

.yarn/install-state.gz

# testing
/coverage
/cypress.env.json
Expand Down Expand Up @@ -65,4 +67,4 @@ data

# Auto-generated documentation
docs/compodoc/**/*
docs/storybook/**/*
docs/storybook/**/*
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 removed .yarn/cache/ejs-npm-3.1.9-e201b2088c-af6f10eb81.zip
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 removed .yarn/cache/ws-npm-6.2.2-ca62a10fa0-aec3154ec5.zip
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/ws-npm-8.11.0-ab72116a01-316b33aba3.zip
Binary file not shown.
Binary file removed .yarn/cache/ws-npm-8.13.0-26ffa3016a-53e991bbf9.zip
Binary file not shown.
Binary file removed .yarn/cache/ws-npm-8.14.2-b339ac47a2-3ca0dad26e.zip
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/install-state.gz
Binary file not shown.
3 changes: 3 additions & 0 deletions config.development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ services:
application_identifier: NOVU_APPLICATION_IDENTIFIER
openai:
api_key: OPENAI_API_KEY
zenvia:
api_url: ZENVIA_API_URL
api_token: ZENVIA_API_TOKEN

3 changes: 3 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ services:
api_key: NOVU_API_KEY
openai:
api_key: OPENAI_API_KEY
zenvia:
api_url: ZENVIA_API_URL
api_token: ZENVIA_API_TOKEN

3 changes: 3 additions & 0 deletions config.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ services:
application_identifier: NOVU_APPLICATION_IDENTIFIER
openai:
api_key: OPENAI_API_KEY
zenvia:
api_url: ZENVIA_API_URL
api_token: ZENVIA_API_TOKEN
3 changes: 3 additions & 0 deletions config.seed.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ services:
api_key: NOVU_API_KEY
openai:
api_key: OPENAI_API_KEY
zenvia:
api_url: ZENVIA_API_URL
api_token: ZENVIA_API_TOKEN
3 changes: 3 additions & 0 deletions config.seed.test.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ services:
instanceId: {env(GITLAB_FEATURE_FLAG_INSTANCE_ID)}
openai:
api_key: {env(OPENAI_API_KEY)}
zenvia:
api_url: {env(ZENVIA_API_URL)}
api_token: {env(ZENVIA_API_TOKEN)}
3 changes: 3 additions & 0 deletions config.test.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ services:
secretAccessKey: {env(AWS_SECRET_ACCESS_KEY)}
openai:
api_key: {env(OPENAI_API_KEY)}
zenvia:
api_url: {env(ZENVIA_API_URL)}
api_token: {env(ZENVIA_API_TOKEN)}
12 changes: 9 additions & 3 deletions cypress/e2e/tests/header.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ describe("Test the header menus", () => {
cy.url().should("contains", "claim");
});

it("Open side bar and click sources", () => {
it("Open side bar and click source", () => {
cy.get(locators.menu.SIDE_MENU).click();
cy.get("[data-cy=testSourcestItem]").click();
cy.url().should("contains", "sources");
cy.get("[data-cy=testSourcetItem]").click();
cy.url().should("contains", "source");
});

it("Open side bar and click source", () => {
cy.get(locators.menu.SIDE_MENU).click();
cy.get("[data-cy=testVerificationRequestItem]").click();
cy.url().should("contains", "verification-request");
});

it("Open side bar and click about", () => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/tests/image.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe("Create image claim", () => {

cy.get(locators.claim.INPUT_SOURCE)
.should("be.visible")
.type(claim.source);
.type(claim.imageSource);
cy.get(locators.claim.BTN_UPLOAD_IMAGE).should("be.visible");
cy.get('input[type="file"]').selectFile(claim.imageSource, {
cy.get('input[type="file"]').selectFile(claim.imageSourceFile, {
force: true,
});
cy.get("[data-cy=testCheckboxAcceptTerms]").click();
Expand Down
54 changes: 28 additions & 26 deletions cypress/e2e/tests/review.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ const goToClaimReviewPage = () => {
cy.get(locators.claim.BTN_SEE_FULL_REVIEW).should("exist");
};

const assignUser = () => {
cy.get(locators.claimReview.BTN_START_CLAIM_REVIEW).should("exist").click();
cy.get(locators.claimReview.INPUT_USER)
.should("exist")
.type(review.username, { delay: 200 });
cy.get(".ant-select-item-option-active").click();
cy.get('[title="reCAPTCHA"]').should("exist");
cy.get(locators.claimReview.BTN_ASSIGN_USER).should("be.disabled");
cy.checkRecaptcha();
cy.get(locators.claimReview.BTN_ASSIGN_USER).should("be.enabled").click();
cy.get(locators.claimReview.INPUT_CLASSIFICATION).should("exist");
};

const blockAssignedUserReview = () => {
cy.checkRecaptcha();
cy.get(locators.claimReview.BTN_SELECTED_REVIEW).should("exist").click();
cy.get(locators.claimReview.INPUT_REVIEWER)
.should("exist")
.type(review.username, { delay: 200 });
cy.get(".ant-select-item-option-active").click();
cy.checkRecaptcha();
cy.get(locators.claimReview.BTN_SUBMIT).should("be.enabled").click();
cy.get(locators.claimReview.TEXT_REVIEWER_ERROR).should("exist");
};

describe("Test claim review", () => {
it("should not show start review when not logged in", () => {
cy.visit(
Expand All @@ -36,25 +61,12 @@ describe("Test claim review", () => {
it("should be able to assign a user", () => {
cy.login();
goToClaimReviewPage();
cy.get(locators.claimReview.BTN_START_CLAIM_REVIEW)
.should("exist")
.click();
cy.get(locators.claimReview.INPUT_USER)
.should("exist")
.type(review.username, { delay: 200 });
cy.get(".ant-select-item-option-active").click();
cy.get('[title="reCAPTCHA"]').should("exist");
cy.get(locators.claimReview.BTN_ASSIGN_USER).should("be.disabled");
cy.checkRecaptcha();
cy.get(locators.claimReview.BTN_ASSIGN_USER)
.should("be.enabled")
.click();
cy.get(locators.claimReview.INPUT_CLASSIFICATION).should("exist");
assignUser();
});

it("should be able to submit full review fields", () => {
cy.login();
cy.intercept("GET", "/api/claimreviewtask/editor-content/*", (req) => {
cy.intercept("GET", "/api/reviewtask/editor-content/*", (req) => {
req.reply({
statusCode: 200,
body: review.editorContent,
Expand Down Expand Up @@ -102,16 +114,6 @@ describe("Test claim review", () => {
it("should not be able submit after choosing assigned user as reviewer", () => {
cy.login();
goToClaimReviewPage();
cy.checkRecaptcha();
cy.get(locators.claimReview.BTN_SELECTED_REVIEW)
.should("exist")
.click();
cy.get(locators.claimReview.INPUT_REVIEWER)
.should("exist")
.type(review.username, { delay: 200 });
cy.get(".ant-select-item-option-active").click();
cy.checkRecaptcha();
cy.get(locators.claimReview.BTN_SUBMIT).should("be.enabled").click();
cy.get(locators.claimReview.TEXT_REVIEWER_ERROR).should("exist");
blockAssignedUserReview();
});
});
Loading

0 comments on commit 4f7a943

Please sign in to comment.