Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing #1040

Closed
wants to merge 27 commits into from
Closed

Testing #1040

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5b528f9
fix nginx envsubst
malteish Jun 20, 2024
3bb98a9
Merge pull request #1038 from dm3-org/develop
malteish Jun 21, 2024
e194dcd
Merge branch 'feature/unifyCI' into testing
malteish Jun 21, 2024
a7efcf9
Merge branch '1032-Add-Backend-Pagination-/-Refine-API' into testing
AlexNi245 Jun 24, 2024
1696aff
Merge branch '1032-Add-Backend-Pagination-/-Refine-API' into testing
AlexNi245 Jun 24, 2024
a0d7eef
fix wrong path
malteish Jun 24, 2024
7923ebf
Merge pull request #1044 from dm3-org/fix/wrongPath
malteish Jun 24, 2024
085e151
Merge remote-tracking branch 'origin/testing' into feature/unifyCI
malteish Jun 25, 2024
02fc4bd
Merge pull request #1047 from dm3-org/feature/unifyCI
malteish Jun 25, 2024
8082d86
remove stateful directories
malteish Jun 26, 2024
c26d2a3
fix RESOLVER_ADDRESS env variable name
malteish Jun 26, 2024
baff095
Merge pull request #1048 from dm3-org/feature/reset-state-on-deploy
malteish Jun 26, 2024
25581d7
minor fixes
malteish Jun 26, 2024
4bfad1a
fix reset of state
malteish Jun 26, 2024
8111acd
Merge pull request #1049 from dm3-org/feature/reset-state-on-deploy
malteish Jun 26, 2024
79727b1
Merge pull request #1050 from dm3-org/feature/unifyCIforProd
malteish Jun 26, 2024
c522480
fix RESOLVER_ADDRESS env variable name
malteish Jun 26, 2024
4744bff
Merge pull request #1052 from dm3-org/fix/resolverAddress
AlexNi245 Jun 26, 2024
4ac3022
Merge pull request #1053 from dm3-org/main
malteish Jun 26, 2024
f55e134
use paginated conversations
AlexNi245 Jun 26, 2024
5b41646
add action that resets the state of staging
malteish Jun 26, 2024
1296fe1
Merge remote-tracking branch 'dm3-org/develop' into FE-Pagination
AlexNi245 Jun 26, 2024
b403f89
usr constant for default conversation size
AlexNi245 Jun 26, 2024
05f5186
use pageSize param in BackendConnector
AlexNi245 Jun 26, 2024
baa5fed
Merge pull request #1058 from dm3-org/feature/resetStagingState
malteish Jun 26, 2024
d5eecf6
Merge branch 'FE-Pagination' into testing
AlexNi245 Jun 26, 2024
70d6fa2
add loggin for conversations
AlexNi245 Jun 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
chmod 600 ./ssh-key
- name: Create .env file
env:
TARGET_HOST: ${{ vars.HOST_DOMAIN }}
TARGET_HOST: ${{ vars.HOST_DOMAIN}}
TARGET_IP: ${{ vars.HOST_IP }}
run: |
echo "REACT_APP_ADDR_ENS_SUBDOMAIN=${{ vars.ADDR_ENS_SUBDOMAIN }}" >> ./.env.react
Expand All @@ -57,7 +57,7 @@ jobs:
echo "REACT_APP_CHAIN_ID=${{ vars.CHAIN_ID }}" >> ./.env.react
echo "REACT_APP_GENOME_REGISTRY_ADDRESS=${{ vars.GENOME_REGISTRY_ADDRESS }}" >> ./.env.react
cat ./.env.react >> ./.env
echo "RESOLVER_ADDR=${{ vars.ERC3668_RESOLVER_ADDRESS }}" >> ./.env
echo "RESOLVER_ADDRESS=${{ vars.ERC3668_RESOLVER_ADDRESS }}" >> ./.env
echo "SIGNING_PUBLIC_KEY=${{ secrets.SIGNING_PUBLIC_KEY }}" >> ./.env
echo "SIGNING_PRIVATE_KEY=${{ secrets.SIGNING_PRIVATE_KEY }}" >> ./.env
echo "SIGNER_PRIVATE_KEY=${{ secrets.SIGNER_PRIVATE_KEY }}" >> ./.env
Expand Down Expand Up @@ -106,10 +106,10 @@ jobs:
--tag dm3org/$image_name:$version${{ env.docker_suffix }}.${{ env.unix_now }}.${{ env.sha_short }} .
docker save -o ./$image_name.tar $image_name:latest
docker push --all-tags dm3org/$image_name
- name: Build offchain-resolver docker image
- name: Build and publish offchain-resolver docker image
shell: bash
run: |
version=$(NODE_PATH=packages/delivery-service node -p "require('package.json').version")
version=$(NODE_PATH=packages/offchain-resolver node -p "require('package.json').version")
image_name=dm3-offchain-resolver
docker build --progress=plain -f ./docker/DockerfilePackages --build-arg="PACKAGE=offchain-resolver" \
--tag $image_name:latest \
Expand Down Expand Up @@ -142,11 +142,17 @@ jobs:
ssh -i ./ssh-key app@${{ vars.HOST_DOMAIN }} "\
cd dm3 && ls |grep -E 'dm3-.*tar' | xargs --no-run-if-empty -L 1 docker load -i; \
rm dm3-*.tar || true"
- name: Reset state of testing environment
run: |
if [ $environment_name == "testing" ]; then
ssh -i ./ssh-key root@${{ vars.HOST_DOMAIN }} "\
cd /mnt/dm3_prod_volume/db && rm -r * || true"
fi
- name: Configure Firewall
run: |
ssh -i ./ssh-key root@${{ vars.HOST_DOMAIN }} "\
ufw allow from 172.18.0.1/16 proto tcp to ${{ vars.HOST_IP}} port 80;
ufw allow from 172.18.0.1/16 proto tcp to ${{ secrets.IP_ADDRESS }} port 443;
ufw allow from 172.18.0.1/16 proto tcp to ${{ vars.HOST_IP }} port 80;
ufw allow from 172.18.0.1/16 proto tcp to ${{ vars.HOST_IP }} port 443;
ufw enable"
- name: Start docker on server
run: |
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/resetStagingState.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: deploy
on: workflow_dispatch

jobs:
reset-staging-state:
environment: 'staging'
runs-on: ubuntu-latest
steps:
- name: Stop docker on server
run: |
ssh -i ./ssh-key app@${{ vars.HOST_DOMAIN }} "\
cd dm3 && docker compose down"
ssh -i ./ssh-key root@${{ vars.HOST_DOMAIN }} "\
systemctl restart docker.service"
- name: Reset state of staging environment
run: |
ssh -i ./ssh-key root@${{ vars.HOST_DOMAIN }} "\
cd /mnt/dm3_prod_volume/db && rm -r * || true"
- name: Start docker on server
run: |
ssh -i ./ssh-key app@${{ vars.HOST_DOMAIN }} "\
cd dm3 && docker compose --env-file .env up -d && docker system prune -af"
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ services:
REACT_APP_USER_ENS_SUBDOMAIN: ${REACT_APP_USER_ENS_SUBDOMAIN}
REACT_APP_WALLET_CONNECT_PROJECT_ID: ${REACT_APP_WALLET_CONNECT_PROJECT_ID}
REACT_APP_GENOME_REGISTRY_ADDRESS: ${REACT_APP_GENOME_REGISTRY_ADDRESS}
RESOLVER_ADDR: ${RESOLVER_ADDR}
RESOLVER_ADDRESS: ${RESOLVER_ADDRESS}

certbot:
image: certbot/certbot
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ export default (
try {
const ensName = normalizeEnsName(req.params.ensName);

console.log('getConversations query', req.query);

const pageSize =
parseInt(req.query.pageSize as string) ||
DEFAULT_CONVERSATION_PAGE_SIZE;
Expand All @@ -231,6 +233,8 @@ export default (
return;
}

console.log('fetch conversations', pageSize, offset);

const conversations = await db.getConversationList(
ensName,
pageSize,
Expand Down
6 changes: 5 additions & 1 deletion packages/lib/shared/src/IBackendConnector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export interface IBackendConnector {
addConversation(ensName: string, encryptedContactName: string): void;
getConversations(ensName: string): Promise<string[]>;
getConversations(
ensName: string,
size: number,
offset: number,
): Promise<string[]>;
toggleHideConversation(
ensName: string,
encryptedContactName: string,
Expand Down
6 changes: 4 additions & 2 deletions packages/lib/storage/src/new/cloudStorage/getCloudStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ export const getCloudStorage = (
);
};

const getConversationList = async (page: number) => {
const getConversations = async (size: number, offset: number) => {
const encryptedConversations = await backendConnector.getConversations(
ensName,
size,
offset,
);

return await Promise.all(
Expand Down Expand Up @@ -174,7 +176,7 @@ export const getCloudStorage = (

return {
addConversation: _addConversation,
getConversationList,
getConversations,
getMessages,
addMessage: _addMessage,
addMessageBatch: _addMessageBatch,
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/storage/src/new/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Envelop, MessageState } from '@dm3-org/dm3-lib-messaging';

export interface StorageAPI {
getConversationList: (page: number) => Promise<Conversation[]>;
getConversations: (size: number, offset: number) => Promise<Conversation[]>;
getMessages: (
contactEnsName: string,
page: number,
Expand Down
6 changes: 5 additions & 1 deletion packages/messenger-widget/src/context/BackendContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { useBackend } from '../hooks/server-side/useBackend';
export type BackendContextType = {
isInitialized: boolean;
addConversation: (ensName: string, encryptedContactName: string) => void;
getConversations: (ensName: string) => Promise<string[]>;
getConversations: (
ensName: string,
size: number,
offset: number,
) => Promise<string[]>;
toggleHideConversation: (
ensName: string,
encryptedContactName: string,
Expand Down
8 changes: 3 additions & 5 deletions packages/messenger-widget/src/context/StorageContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import {
useStorage,
} from '../hooks/storage/useStorage';
import { AuthContext } from './AuthContext';
import { DeliveryServiceContext } from './DeliveryServiceContext';
import { BackendConnector } from '../hooks/server-side/BackendConnector';
import { BackendContext, BackendContextProvider } from './BackendContext';
import { IBackendConnector } from '@dm3-org/dm3-lib-shared';
import { BackendContext } from './BackendContext';

export type StorageContextType = {
storeMessage: StoreMessageAsync;
Expand All @@ -42,7 +39,8 @@ export const StorageContext = React.createContext<StorageContextType>({
contact: string,
batch: StorageEnvelopContainer[],
) => {},
getConversations: async (page: number) => Promise.resolve([]),
getConversations: async (size: number, offset: number) =>
Promise.resolve([]),
addConversationAsync: (contact: string) => {},
getMessages: async (contact: string, page: number) => Promise.resolve([]),
getNumberOfMessages: async (contact: string) => Promise.resolve(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { StorageContextType } from '../StorageContext';
export const getMockedStorageContext = (
override?: Partial<StorageContextType>,
) => {
const defaultValues = {
const defaultValues: StorageContextType = {
initialized: false,
storeMessage: function (
contact: string,
Expand All @@ -29,7 +29,10 @@ export const getMockedStorageContext = (
): void {
throw new Error('Function not implemented.');
},
getConversations: function (page: number): Promise<Conversation[]> {
getConversations: function (
size: number,
offset: number,
): Promise<Conversation[]> {
return Promise.resolve([
{
contactEnsName: 'max.eth',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ describe('useConversation hook test cases', () => {
const storageContext: StorageContextType = getMockedStorageContext({
getConversations: function (
page: number,
offset: number,
): Promise<Conversation[]> {
return Promise.resolve([
{
Expand All @@ -409,6 +410,7 @@ describe('useConversation hook test cases', () => {
},
]);
},
addConversationAsync: jest.fn(),
initialized: true,
});
const deliveryServiceContext: DeliveryServiceContextType =
Expand Down Expand Up @@ -480,6 +482,7 @@ describe('useConversation hook test cases', () => {
},
]);
},
addConversationAsync: jest.fn(),
initialized: true,
});
const deliveryServiceContext: DeliveryServiceContextType =
Expand Down Expand Up @@ -568,6 +571,7 @@ describe('useConversation hook test cases', () => {
},
]);
},
addConversationAsync: jest.fn(),
initialized: true,
});
const deliveryServiceContext: DeliveryServiceContextType =
Expand Down Expand Up @@ -619,7 +623,7 @@ describe('useConversation hook test cases', () => {
'mydefaultcontract.eth',
);
});
it('hidden contact should not appears as hidden in the conversation list', async () => {
it('hidden contact should appear as hidden in the conversation list', async () => {
const configurationContext = getMockedDm3Configuration({
dm3Configuration: {
...DEFAULT_DM3_CONFIGURATION,
Expand Down Expand Up @@ -661,6 +665,7 @@ describe('useConversation hook test cases', () => {
},
]);
},
addConversationAsync: jest.fn(),
initialized: true,
});
const deliveryServiceContext: DeliveryServiceContextType =
Expand Down
Loading
Loading