Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into scroll-2837
Browse files Browse the repository at this point in the history
  • Loading branch information
bhargavaparoksham committed Feb 16, 2024
2 parents c2b284b + 383e196 commit 70ea0f0
Show file tree
Hide file tree
Showing 87 changed files with 23,654 additions and 9,180 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ node_modules
dist/
coverage/
.eslintcache

bun.lockb
tmp
97 changes: 62 additions & 35 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,87 @@
version: '3.8'

# Ports
# Dev chain 1: 8545
# Dev chain 2: 8546
# Builder: 3000
# Explorer: 3001
# Manager: 3002
# Pinata: 3003
# Indexer: 3004
# Dev chain 1: 3005
# Subgraph dev chain 1: 3006
# Dev chain 2: 3007
# Subgraph dev chain 2: 3008

services:
pinata:
pina:
image: ghcr.io/gitcoinco/pina:main
networks:
- grants-stack

ports:
- '127.0.0.1:3003:8000'

localchain-1:
image: ghcr.io/gitcoinco/allo-contracts-v1:main
local-chain-1:
image: ghcr.io/foundry-rs/foundry:nightly-b174c3a4f80938636f18b3c9e49d45e6643f64a9
networks:
- grants-stack
ports:
- '127.0.0.1:3005:8545'
- '127.0.0.1:8545:8545'
environment:
- DEV_CHAIN_ID=313371
entrypoint: ["anvil", "--host", "0.0.0.0", "--chain-id", "313371"]

# initializes localchain deploying contracts and populates with test data
dev-setup-1:
image: ghcr.io/gitcoinco/allo-contracts-v1:main
depends_on:
- pinata
- localchain-1
local-chain-2:
image: ghcr.io/foundry-rs/foundry:nightly-b174c3a4f80938636f18b3c9e49d45e6643f64a9
networks:
- grants-stack
ports:
- '127.0.0.1:8546:8545'
environment:
- PINATA_HOST=pinata
- PINATA_PORT=8000
- DEV_CHAIN_HOST=localchain-1
- DEV_CHAIN_ID=313371
restart: "no"
entrypoint: [ "bash", "-c", "sleep 2 && corepack enable && exec ./docker/deploy-contracts.sh"]
- DEV_CHAIN_ID=313372
entrypoint: ["anvil", "--host", "0.0.0.0", "--chain-id", "313372"]

localchain-2:
image: ghcr.io/gitcoinco/allo-contracts-v1:pr-1
indexer-db:
image: postgres:13
networks:
- grants-stack
ports:
- '127.0.0.1:3007:8545'
- "127.0.0.1:5432:5432"
environment:
- DEV_CHAIN_ID=313372
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres

# initializes localchain deploying contracts and populates with test data
dev-setup-2:
image: ghcr.io/gitcoinco/allo-contracts-v1:pr-1
indexer:
image: ghcr.io/gravityblast/grants-stack-indexer:main
networks:
- grants-stack
ports:
- '127.0.0.1:3004:4000'
depends_on:
- pinata
- localchain-2
- indexer-db
- pina
- local-chain-1
- local-chain-2
volumes:
- ./tmp/indexer/passport_scores.leveldb:/var/indexer/passport_scores.leveldb
environment:
- PINATA_HOST=pinata
- PINATA_PORT=8000
- DEV_CHAIN_HOST=localchain-2
- DEV_CHAIN_ID=313372
restart: "no"
entrypoint: [ "bash", "-c", "sleep 2 && corepack enable && exec ./docker/deploy-contracts.sh"]
- STORAGE_DIR=/var/indexer
- DATABASE_URL=postgres://postgres:postgres@indexer-db:5432/postgres
- INDEXED_CHAINS=dev1,dev2
- DEV1_RPC_URL=http://local-chain-1:8545
- DEV2_RPC_URL=http://local-chain-2:8545
- IPFS_GATEWAY=http://pina:8000
- PASSPORT_SCORER_ID=335
- PASSPORT_API_KEY=xn9e7AFv.aEfS0ioNhaVtww1jdwnsWtxnrNHspVsS
- COINGECKO_API_KEY=CG-9B9jhrcgAbCdN1QX9bVa1o7v
- PORT=4000
- DEPLOYMENT_ENVIRONMENT=local
- LOG_LEVEL=debug
- ENABLE_RESOURCE_MONITOR=false
- BUILD_TAG=local

entrypoint: ["bash", "-c", "sleep 2 && node dist/src/index.js --http-wait-for-sync=false --drop-db | ./node_modules/.bin/pino-pretty"]

networks:
grants-stack:
name: grants-stack
driver: bridge

14 changes: 14 additions & 0 deletions docs/DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ component route

Find more information about routing [here](https://reactrouter.com/docs/en/v6).

## Running E2E tests using Synpress

Synpress is an E2E testing framework for testing dApps. It works by setting up metamask before every run.

### Running Synpress

1. Put `TEST_PRIVATE_KEY` in `.env.local` in the respective directory (e.g. `packages/round-manager`)
2. Start the dev server `pnpm start`
3. Download playwright with `pnpm exec playwright install`
4. Run tests with `pnpm synpress:test`

NOTE: some tests require you to be part of a testing program and have some gas in your wallet. Please use a private key that has some gas on Fantom Testnet and Optimism Mainnet, and is part of the "GS Optimism Program 10 Round" Program on Optimism Mainnet.


## Submitting a PR

Please always submit draft PRs at first, and make sure they pass the following conditions before you mark them as Ready for review.
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"turbo": "^1.11.0"
"turbo": "^1.12.2"
},
"dependencies": {
"prettier": "^3.0.3"
Expand All @@ -44,5 +44,6 @@
"overrides": {
"webpack": "^5"
}
}
},
"workspaces": ["packages/*"]
}
3 changes: 2 additions & 1 deletion packages/builder/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
env: {
browser: true,
es2021: true,
jest: true,
},
parser: "@typescript-eslint/parser",
extends: ["airbnb", "airbnb-typescript", "prettier"],
Expand Down Expand Up @@ -35,5 +36,5 @@ module.exports = {
"eol-last": ["error", "always"],
"react/require-default-props": "off",
},
ignorePatterns: ["node_modules/"],
ignorePatterns: ["node_modules/", "./fixtures.ts"],
};
2 changes: 2 additions & 0 deletions packages/builder/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ yarn-error.log*
.eslintcache
.vercel
.env*.local

/cache
1 change: 1 addition & 0 deletions packages/builder/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
require.resolve("jest-transform-stub"),
},
setupFilesAfterEnv: ["./src/setupTests.ts"],
testPathIgnorePatterns: ["/e2e/"],
}),
},
webpack: {
Expand Down
14 changes: 14 additions & 0 deletions packages/builder/e2e/homepage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as metamask from "@synthetixio/synpress/commands/metamask";
import { test } from "../fixtures";

test.beforeEach(async ({ page }) => {
// baseUrl is set in playwright.config.ts
await page.goto("/");
});

test("main page loads and wallet connects", async ({ page }) => {
await page.getByRole("navigation").getByTestId("rk-connect-button").click();
await page.getByText("Metamask").click();
await metamask.acceptAccess();
await page.getByText("My Projects").waitFor();
});
69 changes: 69 additions & 0 deletions packages/builder/fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { type BrowserContext, chromium, test as base } from "@playwright/test";
import { initialSetup } from "@synthetixio/synpress/commands/metamask";
import { setExpectInstance } from "@synthetixio/synpress/commands/playwright";
import { resetState } from "@synthetixio/synpress/commands/synpress";
import { prepareMetamask } from "@synthetixio/synpress/helpers";
import { config } from "dotenv";

export const test = base.extend<{
context: BrowserContext;
}>({
// eslint-disable-next-line no-empty-pattern
context: async ({}, use) => {
config({
path: ["./.env.local", "./.env", "./.env.test"],
});

// required for synpress as it shares same expect instance as playwright
// eslint-disable-next-line @typescript-eslint/no-use-before-define
await setExpectInstance(expect);

// download metamask
const metamaskPath = await prepareMetamask(
process.env.METAMASK_VERSION || "10.25.0"
);

// prepare browser args
const browserArgs = [
`--disable-extensions-except=${metamaskPath}`,
`--load-extension=${metamaskPath}`,
"--remote-debugging-port=9222",
];

if (process.env.CI) {
browserArgs.push("--disable-gpu");
}

if (process.env.HEADLESS_MODE) {
browserArgs.push("--headless=new");
}

// launch browser
const context = await chromium.launchPersistentContext("", {
headless: false,
args: browserArgs,
});

// wait for metamask
await context.pages()[0].waitForTimeout(3000);

// setup metamask
await initialSetup(chromium, {
secretWordsOrPrivateKey:
process.env.TEST_PRIVATE_KEY ??
"test test test test test test test test test test test junk",
network: "optimism",
password: "Tester@1234",
enableAdvancedSettings: true,
});

await use(context);

await context.close();

await resetState();
},
});

// eslint-disable-next-line prefer-destructuring
export const expect = test.expect;
14 changes: 12 additions & 2 deletions packages/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
"@heroicons/react": "^2.0.11",
"@lagunovsky/redux-react-router": "^2.2.0",
"@pinata/sdk": "^1.1.26",
"@playwright/test": "^1.41.1",
"@rainbow-me/rainbowkit": "^0.12.18",
"@redux-devtools/extension": "^3.2.3",
"@rsbuild/core": "^0.4.1",
"@rsbuild/plugin-react": "^0.3.11",
"@rsbuild/plugin-svgr": "^0.3.11",
"@rsdoctor/rspack-plugin": "^0.1.1",
"@synthetixio/synpress": "3.7.2-beta.10",
"@tailwindcss/line-clamp": "^0.4.2",
"@tailwindcss/typography": "^0.5.9",
"@tanstack/query-core": "4.22.0",
Expand Down Expand Up @@ -50,10 +56,12 @@
"dompurify": "^2.4.3",
"ethers": "^5.7.2",
"framer-motion": "^6",
"gitcoin-lit-js-sdk": "^1.3.0",
"gitcoin-lit-js-sdk": "^1.3.1",
"history": "^5.3.0",
"https-browserify": "^1.0.0",
"jest": "^27.0",
"jszip": "^3.10.1",
"localforage": "^1.10.0",
"os-browserify": "^0.3.0",
"pnpm": "7",
"postcss": "^8.4.14",
Expand Down Expand Up @@ -93,7 +101,8 @@
"lint": "eslint --ext .js,.jsx,.ts,.tsx ./src --cache",
"lint:ci": "CI=false pnpm lint",
"lint:fix": "eslint ./src --fix --cache",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"synpress:test": "playwright test --project=chromium"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -125,6 +134,7 @@
"@types/react-gtm-module": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"dotenv": "^16.4.1",
"eslint": "^8.2.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
Expand Down
36 changes: 36 additions & 0 deletions packages/builder/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
testDir: "./e2e",
timeout: 60 * 1000,
expect: {
timeout: 5000,
},
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: 1,
reporter: "html",
use: {
actionTimeout: 0,
baseURL: "http://localhost:3000",
trace: "on-first-retry",
headless: false,
},
// start local web server before tests
webServer: [
{
command: "pnpm start",
url: "http://localhost:3000",
timeout: 5000,
reuseExistingServer: true,
},
],
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
outputDir: "test-results",
});
Loading

0 comments on commit 70ea0f0

Please sign in to comment.