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

1545 compose db #2045

Merged
merged 53 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4e69603
feat(app): writing to ComposeDB
lucianHymer Sep 27, 2023
689c828
feat(database-client): updating dependencies
nutrina Jan 12, 2024
e801aee
feat[schrmeas]: adding graphql model, composite & definition
nutrina Jan 12, 2024
b5d1f4a
fix[schema, database-client]: remove ceramic client, fix faiilng tests
nutrina Jan 12, 2024
f9da478
chore(schemas, database-client): setup compose db
tim-schultz Jan 12, 2024
18edb12
feat(app, database-client, iam, indetitiy, platforms): remove metaPoi…
tim-schultz Jan 13, 2024
7dd72e2
feat(database-client): read and write to compose
tim-schultz Jan 16, 2024
8975ca3
chore: sudo code patch request
tim-schultz Jan 16, 2024
faf5516
feat(database-client): match existing scorer interface
tim-schultz Jan 17, 2024
1f35d05
chore(database-client): testing compose interactions
tim-schultz Jan 17, 2024
7655f30
feat[identidy]: adjusting credentials
nutrina Jan 17, 2024
e94b45e
Revert "feat[identidy]: adjusting credentials"
nutrina Jan 17, 2024
df5914c
feat[schemas]: adjusting the graphql schemas
nutrina Jan 17, 2024
d16d2d4
fix[schemas]: fix type in command in package.json
nutrina Jan 17, 2024
a438aa7
feat[schemas]: adding new compiled composites
nutrina Jan 18, 2024
159ae52
feat[schemas]: adding passport-schemas workspace to the build command…
nutrina Jan 18, 2024
dd97773
feat[database-client]: WIP - correct import for schemas
nutrina Jan 18, 2024
0d18999
feat[database-client]: adding back integration tests for patch
nutrina Jan 18, 2024
7ddef71
chore(database-client): wip test client
tim-schultz Jan 17, 2024
c226e47
chore(database-client): integration crud tests
tim-schultz Jan 18, 2024
5552171
chore(schemas): schema update
tim-schultz Jan 18, 2024
d122f93
chore(databasae-client): integration tests
tim-schultz Jan 19, 2024
73cacb6
feat[database-client]: reading all fields + transforming back the VC …
nutrina Jan 19, 2024
cd441de
feat[app]: accept multiple valid issuers & set ceramic URL from env v…
nutrina Jan 19, 2024
d0b2954
feat[app,database-client]: pass in the logger to the ComposeDatabase
nutrina Jan 19, 2024
208d41a
chore(database-client): chore wip unit testing and error handling
tim-schultz Jan 19, 2024
0e08d8f
chore(database-client): unit test compose db
tim-schultz Jan 19, 2024
855a7fd
fix(app): update ceramic context tests to match updated interface
tim-schultz Jan 19, 2024
df9fd2e
chore(ci): use node 20 in CI
tim-schultz Jan 19, 2024
1239a38
chore(ci): use node 20 in all cis
tim-schultz Jan 19, 2024
ac6fd1b
fix(database-client): pull definition from package
tim-schultz Jan 19, 2024
3b3805d
fix(app, database-client): allow usage of node 20 and fix ceramic bui…
tim-schultz Jan 19, 2024
35e39de
fix[app]: fixing build errors, upgrading dependencies
nutrina Jan 22, 2024
598a9dc
fix[app]: fix build issues
nutrina Jan 22, 2024
6d572cf
fix: fixing build errors
nutrina Jan 22, 2024
d25d9a1
feat(app): wip compose upgrade
tim-schultz Jan 22, 2024
ce9e00b
fix: remove *.tsbuildinfo files
nutrina Jan 22, 2024
97e8c77
fix[iam]: set the skipLibCheck flag in tsconfig.json
nutrina Jan 22, 2024
330d366
feat(app): replace self.id
tim-schultz Jan 22, 2024
309bf24
fix[database-client]: enabling back the integration tests
nutrina Jan 22, 2024
dc2528d
fix[schemas,database-client]: fix chemas build and integration tests …
nutrina Jan 22, 2024
9093c97
fix[passport]: fixing pre* commands
nutrina Jan 22, 2024
5acef92
fix(app, identity, platforms): linting
tim-schultz Jan 22, 2024
84a98c8
chore: resolve conflicts
tim-schultz Jan 23, 2024
8d1e33b
chore(ci): add compose client url to ci
tim-schultz Jan 23, 2024
9163fd7
debug[ci]: debugging ci ...
nutrina Jan 23, 2024
37214e4
fix[ci]: add ceramic config for integration tests
nutrina Jan 23, 2024
80ada10
fix[ci]: add ceramic config for integration tests
nutrina Jan 23, 2024
0b0be9e
fix[ci]: add ceramic config for integration tests
nutrina Jan 23, 2024
edb6765
fix[ci]: add ceramic config for integration tests
nutrina Jan 23, 2024
73735d2
fix[ci]: add ceramic config for integration tests
nutrina Jan 23, 2024
a5309dd
fix[ci]: add ceramic config for integration tests
nutrina Jan 23, 2024
5736c81
fix[ci]: add ceramic config for integration tests
nutrina Jan 23, 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
42 changes: 37 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,52 @@ on:
branches: [main]

jobs:
# ceramic-config:
# runs-on: ubuntu-latest

# steps:
# - name: Ceramic Config
# run: |
# echo ${GITHUB_WORKSPACE}
# echo "List files in GITHUB_WORKSPACE"
# ls ${GITHUB_WORKSPACE}
# echo "Pwd"
# pwd
# echo '{"anchor": {"auth-method": "did"}, "http-api": {"cors-allowed-origins": [".*"], "admin-dids": ["did:key:z6MkgUzNYV8J1yw43wj9K2CbhTZoN25uZ6TJ3Gi4cYVpZyDb"]}, "ipfs": {"mode": "bundled", "disable-peer-data-sync": false}, "logger": {"log-level": 2, "log-to-files": false}, "metrics": {"metrics-exporter-enabled": false}, "network": {"name": "testnet-clay"}, "node": {}, "state-store": {"mode": "fs", "local-directory": "/home/root/.ceramic/statestore/"}, "indexing": {"db": "sqlite:///home/root/.ceramic/indexing.sqlite", "allow-queries-before-historical-sync": true, "disable-composedb": false, "enable-historical-sync": false}}' > ${GITHUB_WORKSPACE}/daemon.config.json

# debug:
# runs-on: ubuntu-latest

# steps:
# - name: Debug
# run: |
# echo ${GITHUB_WORKSPACE}
# echo "List files in GITHUB_WORKSPACE"
# ls ${GITHUB_WORKSPACE}
# echo "Pwd"
# cat ${GITHUB_WORKSPACE}/daemon.config.json

build:
# needs: [ceramic-config]
runs-on: ubuntu-latest

# Run a local ceramic nod to test against
services:
ceramic:
image: ceramicnetwork/js-ceramic:2.20.0
image: ceramicnetwork/js-ceramic:3.2.0
ports:
- 7007:7007

# volumes:
# # TODO: use GITHUB_WORKSPACE var here ..
# - /home/runner/work/passport/passport/daemon.config.json:/root/.ceramic/daemon.config.json

steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 18.18
node-version: 20.8.1
cache: "yarn"
- name: Install Packages
run: yarn install
Expand All @@ -36,15 +66,17 @@ jobs:
run: yarn build
- name: Run Ceramic Integration Tests
run: yarn test:ceramic-integration
env:
CERAMIC_CLIENT_URL: ${{secrets.CERAMIC_CLIENT_URL}}

check-provider-bitmap:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 18.18
node-version: 20.8
cache: "yarn"
- name: Install Packages
run: yarn install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/iam-cd-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
steps:
- uses: actions/checkout@v3
# run tests
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20.8
cache: "yarn"
- name: Install Packages
run: yarn install
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/iam-promote-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
with:
ref: ${{ github.event.inputs.commit }}
# run tests
- name: Use Node.js 16
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20.8
cache: "yarn"
- name: Install Packages
run: yarn install
Expand Down Expand Up @@ -67,10 +67,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 18.18
node-version: 20.8
cache: "yarn"
- name: Install Packages
run: yarn install
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/iam-promote-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
with:
ref: ${{ github.event.inputs.commit }}
# run tests
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20.8
cache: "yarn"
- name: Install Packages
run: yarn install
Expand Down Expand Up @@ -67,10 +67,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 18.18
node-version: 20.8
cache: "yarn"
- name: Install Packages
run: yarn install
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ lerna-debug.log*
*.ntvs*
*.njsproj
*.sln
*.sw?
*.sw?

schemas/.env.yarn
4 changes: 2 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.exports = {
overrides: [
{
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
files: ["**/*.js", "**/*.ts", "**/*.tsx"],
options: {
bracketSpacing: true,
trailingComma: 'es5',
trailingComma: "es5",
tabWidth: 2,
printWidth: 120,
singleQuote: false,
Expand Down
68 changes: 29 additions & 39 deletions app/__tests__/context/ceramicContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,21 @@ import {
CeramicContextState,
cleanPassport,
} from "../../context/ceramicContext";
import { CeramicDatabase, PassportDatabase } from "@gitcoin/passport-database-client";
import { ComposeDatabase, PassportDatabase } from "@gitcoin/passport-database-client";
import {
googleStampFixture,
discordStampFixture,
brightidStampFixture,
} from "../../__test-fixtures__/databaseStorageFixtures";
import { Passport } from "@gitcoin/passport-types";
import {
DatastoreConnectionContext,
DatastoreConnectionContextProvider,
} from "../../context/datastoreConnectionContext";
import { DatastoreConnectionContext } from "../../context/datastoreConnectionContext";
import { DID } from "dids";

const viewerConnection = {
status: "connected",
selfID: "did:3:abc",
};

jest.mock("@self.id/framework", () => {
return {
useViewerConnection: () => [viewerConnection],
};
});

jest.mock("@didtools/cacao", () => ({
Cacao: {
fromBlockBytes: jest.fn(),
Expand Down Expand Up @@ -93,14 +85,26 @@ const ceramicDbMocks = {
addStamps: dbAddStampsMock,
deleteStamp: dbDeleteStampMock,
deleteStamps: dbDeleteStampsMock,
patchStamps: jest.fn(),
did: "test-user-did",
};

jest.mock("@gitcoin/passport-database-client", () => {
return {
ComposeDatabase: jest.fn().mockImplementation(() => ceramicDbMocks),
PassportDatabase: jest.fn().mockImplementation(() => passportDbMocks),
};
});

const mockComponent = () => (
<DatastoreConnectionContext.Provider
value={{
dbAccessToken: "token",
dbAccessTokenStatus: "idle",
did: {
id: "did:3:abc",
parent: "did:3:abc",
} as unknown as DID,
connect: async () => {},
disconnect: async () => {},
}}
Expand All @@ -124,7 +128,7 @@ const mockComponent = () => (

describe("CeramicContextProvider syncs stamp state with ceramic", () => {
beforeEach(() => {
(CeramicDatabase as jest.Mock).mockImplementation(() => ceramicDbMocks);
(ComposeDatabase as jest.Mock).mockImplementation(() => ceramicDbMocks);
});

it("should return passport and stamps after successful fetch", async () => {
Expand Down Expand Up @@ -210,7 +214,7 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {
}),
};
});
(CeramicDatabase as jest.Mock).mockImplementationOnce(() => {
(ComposeDatabase as jest.Mock).mockImplementationOnce(() => {
return {
...ceramicDbMocks,
getPassport: jest.fn().mockImplementation(async () => {
Expand All @@ -235,7 +239,7 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {
console.log = jest.fn();

const addStampsMock = jest.fn();
const setStampMock = jest.fn().mockRejectedValue(new Error("Error"));
const addStampMock = jest.fn().mockRejectedValue(new Error("Error"));
(PassportDatabase as jest.Mock).mockImplementationOnce(() => {
return {
...passportDbMocks,
Expand All @@ -257,10 +261,9 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {
status: "Success",
};
}),
setStamps: setStampMock,
};
});
(CeramicDatabase as jest.Mock).mockImplementationOnce(() => {
(ComposeDatabase as jest.Mock).mockImplementationOnce(() => {
return {
...ceramicDbMocks,
getPassport: jest.fn().mockImplementation(async () => {
Expand All @@ -272,15 +275,15 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {
status: "Success",
};
}),
setStamps: setStampMock,
addStamps: addStampMock,
};
});
render(mockComponent());

await waitFor(() => fireEvent.click(screen.getByText("handleAddStamps")));
await waitFor(() => {
expect(addStampsMock).toHaveBeenCalled();
expect(setStampMock).toHaveBeenCalledWith(stamps);
expect(addStampMock).toHaveBeenCalledWith(stamps);
expect(console.log).toHaveBeenCalledWith("error setting ceramic stamps", new Error("Error"));
});
} finally {
Expand All @@ -291,8 +294,7 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {
const oldConsoleLog = console.log;
try {
console.log = jest.fn();
const deleteStampsMock = jest.fn();
const setStampMock = jest.fn().mockRejectedValue(new Error("Error"));
const deleteStampsMock = jest.fn().mockRejectedValue("Error");
(PassportDatabase as jest.Mock).mockImplementationOnce(() => {
return {
...passportDbMocks,
Expand All @@ -316,27 +318,18 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {
}),
};
});
(CeramicDatabase as jest.Mock).mockImplementationOnce(() => {
(ComposeDatabase as jest.Mock).mockImplementationOnce(() => {
return {
...ceramicDbMocks,
getPassport: jest.fn().mockImplementation(async () => {
return {
passport: {
stamps: [],
},
errorDetails: {},
status: "Success",
};
}),
setStamps: setStampMock,
deleteStamps: deleteStampsMock,
};
});
render(mockComponent());

await waitFor(() => fireEvent.click(screen.getByText("handleDeleteStamps")));
await waitFor(() => {
expect(deleteStampsMock).toHaveBeenCalled();
expect(setStampMock).toHaveBeenCalledWith([]);
expect(deleteStampsMock).toHaveBeenCalledWith(stamps.map((stamp) => stamp.provider));
});
} finally {
console.log = oldConsoleLog;
Expand All @@ -345,7 +338,6 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {

it("should patch stamps in database and delete + add stamps in ceramic", async () => {
const added = stampPatches.filter(({ credential }) => credential);
const deletedProviders = stampPatches.filter(({ credential }) => !credential).map(({ provider }) => provider);

const patchStampsMock = jest.fn();
(PassportDatabase as jest.Mock).mockImplementationOnce(() => {
Expand Down Expand Up @@ -375,10 +367,9 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {
const setStampMock = jest.fn();
const deleteStampsMock = jest.fn();

(CeramicDatabase as jest.Mock).mockImplementationOnce(() => {
(ComposeDatabase as jest.Mock).mockImplementationOnce(() => {
return {
...ceramicDbMocks,
setStamps: setStampMock,
deleteStampIDs: deleteStampsMock,
};
});
Expand All @@ -388,8 +379,6 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {
await waitFor(() => fireEvent.click(screen.getByText("handlePatchStamps")));
await waitFor(() => {
expect(patchStampsMock).toHaveBeenCalledWith(stampPatches);
expect(deleteStampsMock).toHaveBeenCalledWith(deletedProviders);
expect(setStampMock).toHaveBeenCalledWith(added);
});
});

Expand All @@ -398,7 +387,7 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {
try {
console.log = jest.fn();

const patchStampsMock = jest.fn();
const patchStampsMock = jest.fn().mockRejectedValue(new Error("Error"));
(PassportDatabase as jest.Mock).mockImplementationOnce(() => {
return {
...passportDbMocks,
Expand Down Expand Up @@ -426,11 +415,12 @@ describe("CeramicContextProvider syncs stamp state with ceramic", () => {
const setStampMock = jest.fn().mockRejectedValue(new Error("Error"));
const deleteStampsMock = jest.fn();

(CeramicDatabase as jest.Mock).mockImplementationOnce(() => {
(ComposeDatabase as jest.Mock).mockImplementationOnce(() => {
return {
...ceramicDbMocks,
setStamps: setStampMock,
deleteStampIDs: deleteStampsMock,
patchStamps: patchStampsMock,
};
});

Expand Down
Loading
Loading