Skip to content

Commit

Permalink
Merge pull request #118 from VenusProtocol/cleanup-package.json-remov…
Browse files Browse the repository at this point in the history
…e-local-setup-commands

refactor: cleanup package.json for subgraphs
  • Loading branch information
coreyar authored Nov 1, 2023
2 parents 8cd3d7b + 6d5b960 commit e926fb7
Show file tree
Hide file tree
Showing 18 changed files with 229 additions and 1,208 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
# enabeling updating the lock file for a bug in yarn berry likely related to installing github
run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn

- name: Prepare local
run: yarn prepare:local
- name: Prepare
run: yarn prepare:docker

- name: Codegen
run: yarn codegen
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:

- name: Generate Governance graphql types
run: |
docker exec -i subgraph-hardhat-node yarn workspace venus-governance-subgraph run prepare:local
docker exec -i subgraph-hardhat-node yarn workspace venus-governance-subgraph run prepare:docker
docker exec -i subgraph-hardhat-node yarn workspace venus-governance-subgraph run codegen
docker exec -i subgraph-hardhat-node yarn workspace venus-governance-subgraph run create:docker
docker exec -i subgraph-hardhat-node yarn workspace venus-governance-subgraph run deploy:docker
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ Integration tests require running IPFS, a graph-node and a hardhat node. They ca
$ yarn workspace <WORKSPACE> run test:integration
```

If you'd like to run the integration tests locally include the env `LOCAL=true` and follow instructions run the services locally.

> Integration tests are temporarily disabled during CI, while the docker setup is debugged.
## Running servies locally
Expand Down Expand Up @@ -59,14 +57,6 @@ cargo run -p graph-node --release -- \

Replace `<NETWORK>` with the network indicated by your subgraph.yaml (usually bsc).

### Deploy your local subgraph
To build or deploy the subgraph you'll need to first compile the subgraph.yaml template and then run the build of deploy commands which can be run for all packages or individual packages.

```
$ yarn prepare:local
$ yarn deploy:local
```

## Testing
### Unit tests
Unit tests are run with `matchstick-as`. They can be run with the `test` command at the project or workspace level. Tests are organized by datasource with files for creating events and mocks. A test consists of setting up and creating an event, then passing it to the handler and asserting against changes to the document store.
Expand Down
20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
],
"scripts": {
"codegen": "yarn workspaces foreach run codegen",
"create:local": "yarn workspaces foreach run create:local",
"build:local": "yarn workspaces foreach run build:local",
"build:testnet": "yarn workspaces foreach run build:testnet",
"build:mainnet": "yarn workspaces foreach run build:mainnet",
"deploy:local": "yarn workspaces foreach run deploy:local",
"deploy:testnet": "yarn workspaces foreach run deploy:testnet",
"deploy:mainnet": "yarn workspaces foreach run deploy:mainnet",
"prepare:local": "yarn workspaces foreach run prepare:local",
"prepare:testnet": "yarn workspaces foreach run prepare:testnet",
"prepare:mainnet": "yarn workspaces foreach run prepare:mainnet",
"remove:local": "yarn workspaces foreach run remove:local",
"build:docker": "yarn workspaces foreach run build:docker",
"build:chapel": "yarn workspaces foreach run build:chapel",
"build:bsc": "yarn workspaces foreach run build:bsc",
"deploy:docker": "yarn workspaces foreach run deploy:docker",
"deploy:chapel": "yarn workspaces foreach run deploy:chapel",
"deploy:bsc": "yarn workspaces foreach run deploy:bsc",
"prepare:docker": "yarn workspaces foreach run prepare:docker",
"prepare:chapel": "yarn workspaces foreach run prepare:chapel",
"prepare:bsc": "yarn workspaces foreach run prepare:bsc",
"generate-subgraph-types": "yarn workspaces foreach run generate-subgraph-types",
"lint": "eslint '**/*.{ts,tsx}'",
"lint:fix": "yarn lint --fix",
Expand Down
28 changes: 13 additions & 15 deletions packages/isolated-pools-abis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
"version": "0.0.0",
"license": "MIT",
"scripts": {
"codegen:local": "true",
"codegen:testnet": "true",
"codegen:mainnet": "true",
"create:local": "true",
"create:testnet": "true",
"create:mainnet": "true",
"build:local": "true",
"build:testnet": "true",
"build:mainnet": "true",
"deploy:local": "true",
"deploy:testnet": "true",
"deploy:mainnet": "true",
"prepare:local": "true",
"prepare:testnet": "true",
"prepare:mainnet": "true",
"codegen": "true",
"create:docker": "true",
"create:chapel": "true",
"create:bsc": "true",
"build:docker": "true",
"build:chapel": "true",
"build:bsc": "true",
"deploy:docker": "true",
"deploy:chapel": "true",
"deploy:bsc": "true",
"prepare:docker": "true",
"prepare:chapel": "true",
"prepare:bsc": "true",
"pretty": "prettier —-write '**/*.json'",
"test": "true"
}
Expand Down
28 changes: 13 additions & 15 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@
"license": "MIT",
"main": "src",
"scripts": {
"codegen:local": "true",
"codegen:testnet": "true",
"codegen:mainnet": "true",
"create:local": "true",
"create:testnet": "true",
"create:mainnet": "true",
"build:local": "true",
"build:testnet": "true",
"build:mainnet": "true",
"deploy:local": "true",
"deploy:testnet": "true",
"deploy:mainnet": "true",
"prepare:local": "true",
"prepare:testnet": "true",
"prepare:mainnet": "true",
"codegen": "true",
"create:docker": "true",
"create:chapel": "true",
"create:bsc": "true",
"build:docker": "true",
"build:chapel": "true",
"build:bsc": "true",
"deploy:docker": "true",
"deploy:chapel": "true",
"deploy:bsc": "true",
"prepare:docker": "true",
"prepare:chapel": "true",
"prepare:bsc": "true",
"pretty": "prettier —-write '**/*.json'",
"test": "true"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const deploy = async ({

// Build and Deploy Subgraph
console.log('Build and deploy subgraph...');
exec(`yarn workspace ${packageName} run prepare:local`, root);
exec(`yarn workspace ${packageName} run prepare:docker`, root);
exec(`yarn workspace ${packageName} run codegen`, root);
exec(`yarn workspace ${packageName} run build:docker`, root);
exec(`yarn workspace ${packageName} run create:docker`, root);
Expand Down
28 changes: 13 additions & 15 deletions packages/venus-governance-abis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
"version": "0.0.0",
"license": "MIT",
"scripts": {
"codegen:local": "true",
"codegen:testnet": "true",
"codegen:mainnet": "true",
"create:local": "true",
"create:testnet": "true",
"create:mainnet": "true",
"build:local": "true",
"build:testnet": "true",
"build:mainnet": "true",
"deploy:local": "true",
"deploy:testnet": "true",
"deploy:mainnet": "true",
"prepare:local": "true",
"prepare:testnet": "true",
"prepare:mainnet": "true",
"codegen": "true",
"create:docker": "true",
"create:chapel": "true",
"create:bsc": "true",
"build:docker": "true",
"build:chapel": "true",
"build:bsc": "true",
"deploy:docker": "true",
"deploy:chapel": "true",
"deploy:bsc": "true",
"prepare:docker": "true",
"prepare:chapel": "true",
"prepare:bsc": "true",
"pretty": "prettier —-write '**/*.json'",
"test": "true"
}
Expand Down
6 changes: 0 additions & 6 deletions subgraphs/isolated-pools/babel.config.js

This file was deleted.

File renamed without changes.
32 changes: 9 additions & 23 deletions subgraphs/isolated-pools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,22 @@
],
"scripts": {
"codegen": "npx graph codegen",
"create:local": "LOCAL=true npx graph create venusprotocol/venus-isolated-pools --node http://127.0.0.1:8020/",
"build:local": "LOCAL=true npx graph build --ipfs http://127.0.0.1:5001",
"create:docker": "npx graph create venusprotocol/venus-isolated-pools --node http://graph-node:8020/",
"build:docker": "npx graph build --ipfs http://ipfs:5001",
"build:bsc": "npx graph build --ipfs https://api.thegraph.com/ipfs/ ",
"deploy:local": "LOCAL=true npx mustache config/local.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/",
"deploy:docker": "npx mustache config/local.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label ci",
"deploy:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools-chapel --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:sepolia": "npx prepare:sepolia && npx graph deploy --studio venus-isolated-pools-sepolia",
"prepare:local": "npx mustache config/local.json template.yaml > subgraph.yaml && npx mustache config/local.json src/constants/config-template > src/constants/config.ts",
"prepare:docker": "npx mustache config/local.json template.yaml > subgraph.yaml && npx mustache config/local.json src/constants/config-template > src/constants/config.ts",
"build:bsc": "graph build --ipfs https://api.thegraph.com/ipfs/ ",
"deploy:integration": "graph deploy venusprotocol/venus-isolated-pools --ipfs http://localhost:5001 --node http://127.0.0.1:8020/",
"deploy:docker": "npx mustache config/docker.json template.yaml > subgraph.yaml && npx mustache config/docker.json src/constants/config-template > src/constants/config.ts && npx graph deploy venusprotocol/venus-isolated-pools --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label ci",
"deploy:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx mustache config/chapel.json src/constants/config-template > src/constants/config.ts && graph deploy venusprotocol/venus-isolated-pools-chapel --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx mustache config/bsc.json src/constants/config-template > src/constants/config.ts && graph deploy venusprotocol/venus-isolated-pools --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"prepare:docker": "npx mustache config/docker.json template.yaml > subgraph.yaml && npx mustache config/docker.json src/constants/config-template > src/constants/config.ts",
"prepare:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx mustache config/chapel.json src/constants/config-template > src/constants/config.ts",
"prepare:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx mustache config/bsc.json src/constants/config-template > src/constants/config.ts",
"prepare:sepolia": "npx mustache config/sepolia.json template.yaml > subgraph.yaml && npx mustache config/sepolia.json src/constants/config-template > src/constants/config.ts",
"remove:local": "npx graph remove --node http://127.0.0.1:8020/ venusprotocol/venus-isolated-pools",
"remove:docker": "npx graph remove --node http://graph-node:8020/ venusprotocol/venus-isolated-pools",
"generate-subgraph-types": "rm -rf /subgraph-client/.graphclient && yarn graphclient build --dir ./subgraph-client",
"pretty": "prettier —-write '**/*.ts'",
"test": "yarn prepare:local && graph test",
"test:integration": "PACKAGE=isolated-pools hardhat test tests/integration/index.ts --network localhost"
"generate-subgraph-types": "rm -rf /subgraph-client/.graphclient && npx graphclient build --dir ./subgraph-client",
"test": "yarn prepare:docker && graph test",
"test:integration": "npx hardhat test tests/integration/index.ts --network localhost"
},
"devDependencies": {
"@babel/preset-env": "^7.19.3",
"@babel/preset-typescript": "^7.18.6",
"@graphprotocol/client-cli": "^3.0.0",
"@openzeppelin/contracts": "^4.7.3",
"@openzeppelin/contracts-upgradeable": "^4.7.3",
"apollo-fetch": "^0.7.0",
"hardhat": "^2.10.2",
"urql": "^3.0.3",
"venus-subgraph-utils": "0.0.0"
}
Expand Down
12 changes: 4 additions & 8 deletions subgraphs/isolated-pools/tests/integration/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@ import { SUBGRAPH_ACCOUNT, SUBGRAPH_NAME, SYNC_DELAY } from '../constants';

const deploy = async () => {
const root = __dirname;
const env = process.env.LOCAL ? ('local' as const) : ('docker' as const);

// Create Subgraph Connection
const subgraph = fetchSubgraph(SUBGRAPH_ACCOUNT, SUBGRAPH_NAME);

// Build and Deploy Subgraph
console.log('Build and deploy subgraph...');
exec(`yarn workspace isolated-pools-subgraph run prepare:${env}`, root);
exec(`yarn workspace isolated-pools-subgraph run prepare:docker`, root);
exec(`yarn workspace isolated-pools-subgraph run codegen`, root);
exec(`yarn workspace isolated-pools-subgraph run build:${env}`, root);
exec(`yarn workspace isolated-pools-subgraph run create:${env}`, root);
exec(`yarn workspace isolated-pools-subgraph run build:docker`, root);
exec(`yarn workspace isolated-pools-subgraph run create:docker`, root);

const deployCmd =
env === 'local'
? `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/ --version-label v${Date.now().toString()}`
: `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label v${Date.now().toString()}`;
const deployCmd = `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label v${Date.now().toString()}`;
exec(deployCmd, root);

await waitForSubgraphToBeSynced(SYNC_DELAY);
Expand Down
14 changes: 4 additions & 10 deletions subgraphs/venus-governance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,22 @@
],
"scripts": {
"codegen": "npx graph codegen",
"create:local": "graph create venusprotocol/venus-governance --node http://127.0.0.1:8020",
"create:docker": "npx graph create venusprotocol/venus-governance --node http://graph-node:8020/",
"build:docker": "npx graph build --ipfs http://ipfs:5001",
"build:local": "graph build --ipfs http://localhost:5001",
"build:bsc": "graph build --ipfs https://api.thegraph.com/ipfs/ ",
"deploy:integration": "graph deploy venusprotocol/venus-governance --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020/",
"deploy:local": "npx mustache config/local.json template.yaml > subgraph.yaml && npx mustache config/local.json src/constants/config-template > src/constants/config.ts && yarn deploy:integration",
"deploy:docker": "npx mustache config/local.json template.yaml > subgraph.yaml && npx mustache config/local.json src/constants/config-template > src/constants/config.ts && npx graph deploy venusprotocol/venus-governance --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label ci",
"deploy:docker": "npx mustache config/docker.json template.yaml > subgraph.yaml && npx mustache config/docker.json src/constants/config-template > src/constants/config.ts && npx graph deploy venusprotocol/venus-governance --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label ci",
"deploy:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx mustache config/chapel.json src/constants/config-template > src/constants/config.ts && graph deploy venusprotocol/venus-governance-chapel --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx mustache config/bsc.json src/constants/config-template > src/constants/config.ts && graph deploy venusprotocol/venus-governance --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"prepare:local": "npx mustache config/local.json template.yaml > subgraph.yaml && npx mustache config/local.json src/constants/config-template > src/constants/config.ts",
"prepare:docker": "npx mustache config/docker.json template.yaml > subgraph.yaml && npx mustache config/docker.json src/constants/config-template > src/constants/config.ts",
"prepare:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx mustache config/chapel.json src/constants/config-template > src/constants/config.ts",
"prepare:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx mustache config/bsc.json src/constants/config-template > src/constants/config.ts",
"remove:local": "graph remove --node http://localhost:8020/ venusprotocol/venus-governance",
"generate-subgraph-types": "yarn graphclient build --dir ./subgraph-client",
"generate-subgraph-types": "rm -rf /subgraph-client/.graphclient && npx graphclient build --dir ./subgraph-client",
"test": "graph test",
"test:integration": "hardhat test tests/integration/index.ts --network localhost"
"test:integration": "npx hardhat test tests/integration/index.ts --network localhost"
},
"devDependencies": {
"@graphprotocol/client-cli": "^3.0.0",
"apollo-fetch": "^0.7.0",
"hardhat": "^2.10.2",
"urql": "^3.0.3",
"venus-subgraph-utils": "0.0.0"
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 11 additions & 10 deletions subgraphs/venus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
"generated"
],
"scripts": {
"codegen": "graph codegen",
"create:local": "LOCAL=true npx graph create venusprotocol/venus-subgraph --node http://127.0.0.1:8020/",
"build:local": "LOCAL=true npx graph build --ipfs http://127.0.0.1:5001",
"build:mainnet": "npx graph build --ipfs https://api.thegraph.com/ipfs/ ",
"deploy:local": "LOCAL=true npx mustache config/local.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/",
"deploy:testnet": "npx mustache config/testnet.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools-chapel --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:mainnet": "npx mustache config/mainnet.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"prepare:local": "npx mustache config/local.json template.yaml > subgraph.yaml",
"prepare:testnet": "npx mustache config/testnet.json template.yaml > subgraph.yaml",
"prepare:mainnet": "npx mustache config/mainnet.json template.yaml > subgraph.yaml",
"codegen": "npx graph codegen",
"create:docker": "npx graph create venusprotocol/venus-subgraph --node http://graph-node:8020/",
"build:docker": "npx graph build --ipfs http://ipfs:5001",
"build:bsc": "graph build --ipfs https://api.thegraph.com/ipfs/ ",
"deploy:integration": "graph deploy venusprotocol/venus-subgraph --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020/",
"deploy:docker": "npx mustache config/docker.json template.yaml > subgraph.yaml && npx mustache config/docker.json src/constants/config-template > src/constants/config.ts && npx graph deploy venusprotocol/venus-subgraph --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label ci",
"deploy:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx mustache config/chapel.json src/constants/config-template > src/constants/config.ts && graph deploy venusprotocol/venus-subgraph -chapel --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx mustache config/bsc.json src/constants/config-template > src/constants/config.ts && graph deploy venusprotocol/venus-subgraph e --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"prepare:docker": "npx mustache config/docker.json template.yaml > subgraph.yaml",
"prepare:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml",
"prepare:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx mustache config/bsc.json src/constants/config-template > src/constants/config.ts",
"test": "graph test",
"test:integration": "true"
}
Expand Down
Loading

0 comments on commit e926fb7

Please sign in to comment.