Skip to content

Commit

Permalink
fix: add subgraph versioning (#61)
Browse files Browse the repository at this point in the history
Co-authored-by: Neil Duffy <[email protected]>
  • Loading branch information
MantisClone and skiv71 authored Sep 13, 2023
1 parent 8e82d52 commit 59a5254
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 10 deletions.
13 changes: 13 additions & 0 deletions .github/actions/short-sha/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: short-sha
description: Compute release version
runs:
using: composite
steps:
- id: short-sha
shell: sh
run: echo "SHORT_SHA=`echo ${{ github.sha }} | cut -c 1-7`" >> $GITHUB_OUTPUT
outputs:
hash:
description: The short Git HEAD hash
value: ${{ steps.short-sha.outputs.SHORT_SHA }}

3 changes: 3 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn
- uses: ./.github/actions/short-sha
id: short-sha
- run: yarn subgraph deploy ${{ matrix.chain }}
env:
TOKEN: ${{ secrets.THEGRAPH_TOKEN }}
VERSION: ${{ steps.short-sha.outputs.hash }}
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@
This repo contains the code and configuration for Request Payment subgraphs:

Mainnets:
- [Mainnet](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-mainnet)
- [Mainnet on the Hosted Service](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-mainnet)
- [Mainnet on the Decentralized Network](https://thegraph.com/explorer/subgraphs/4cuRFnNSqAme2pVuBckSVQogQPXR8Wqw72AEC6TShLkc?view=Overview&chain=mainnet)
- [Polygon (Matic)](https://thegraph.com/explorer/subgraph/requestnetwork/request-payments-matic)
- [Celo](https://thegraph.com/explorer/subgraph/requestnetwork/request-payments-celo)
- [BSC](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-bsc)
- [Gnosis Chain (xDai)](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-xdai)
- [Gnosis Chain (xDai) on the Hosted Service](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-xdai)
- [Gnosis Chain (xDai) on the Decentralized Network](https://thegraph.com/explorer/subgraphs/KYY6Q6KTcqVpTXMgTyEQJEyYk7wex8BM6twbLzhCXjT?view=Overview&chain=mainnet)
- [Fuse](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-fuse)
- [Fantom](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-fantom)
- [Near](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-near)
- [Avalanche](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-avalanche)
- [Optimism](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-optimism)
- [Moonbeam](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-moonbeam)
- [Arbitrum One](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-arbitrum-one)
- [Mantle](https://graph.fusionx.finance/subgraphs/name/request-payments-mantle/graphql)
- [Mantle](https://graph.fusionx.finance/subgraphs/name/request-payments-mantle)

Testnets:
- [Goerli](https://thegraph.com/explorer/subgraph/requestnetwork/request-payments-goerli)
- [Near Testnet](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-near-testnet)
- [Arbitrum Rinkeby](https://thegraph.com/hosted-service/subgraph/requestnetwork/request-payments-arbitrum-rinkeby)
- [Mantle Testnet](https://graph.testnet.mantle.xyz/subgraphs/name/request-payments-mantle-testnet/graphql)
- [Mantle Testnet](https://graph.testnet.mantle.xyz/subgraphs/name/request-payments-mantle-testnet)

It indexes Request's proxy smart-contracts for easy querying of payment data.

Expand Down Expand Up @@ -97,12 +99,21 @@ yarn deploy-local

### Networks

The live deployment is automated for EVM chains on the hosted service.
For test chains (goerli), it will be automatically deployed when pushed to `main`
Some of the deployments are automated, others are manual
#### Automated Deployment
Deployment on EVM chains is semi-automated, when a Github release is published

For production chains (all others), it is semi automatic, and requires a manual approval in [github actions](https://github.com/RequestNetwork/payments-subgraph/actions).
* mantle-testnet uses the [graph node hosted by Mantle](https://docs.mantle.xyz/network/for-devs/resources-and-tooling/graph-endpoints).
* mantle uses the [graph node hosted by FusionX](https://graph.fusionx.finance)
* all other EVM chains use the hosted service.

For non-EVM deployments, use:
Test chains like Goerli and Mantle Testnet will be deployed immediately when a release is published.

Mainnets (all others) require manual approval in [github actions](https://github.com/RequestNetwork/payments-subgraph/actions).

#### Manual Deployment

For non-EVM deployments like NEAR, use:

```
yarn graph deploy --product hosted-service --deploy-key <GRAPH_KEY> requestnetwork/request-payments-<network> ./subgraph.<network>.yaml
Expand Down
13 changes: 13 additions & 0 deletions cli/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const builder = (y: yargs.Argv) =>
y
.middleware(argv => {
if (process.env.TOKEN) argv.token = process.env.TOKEN;
if (process.env.VERSION) argv.version = process.env.VERSION;
}, true)
.positional("network", {
desc: "The network to deploy to",
Expand All @@ -24,6 +25,11 @@ export const builder = (y: yargs.Argv) =>
type: "string",
demandOption: true,
})
.option("version", {
desc: "The subgraph version label, used by non-hosted service graph nodes",
type: "string",
demandOption: true,
})
.check(({ all, network }) => {
if (all && network)
throw new Error("Cannot specify both -all and positional `network`");
Expand All @@ -35,6 +41,7 @@ export const handler = ({
network,
token,
all,
version,
}: Awaited<ReturnType<typeof builder>["argv"]>) => {
const networkList = all ? networks : network || [];
for (const net of networkList) {
Expand All @@ -48,6 +55,9 @@ export const handler = ({
ipfs: "https://ipfs.testnet.mantle.xyz/",
node: "https://graph.testnet.mantle.xyz/deploy/",
},
{
"version-label": version,
},
)
} else if (net === "mantle") {
deploySubgraph(
Expand All @@ -58,6 +68,9 @@ export const handler = ({
ipfs: "https://api.thegraph.com/ipfs/",
node: "https://deploy.graph.fusionx.finance/",
},
{
"version-label": version,
}
)
} else {
deploySubgraph(
Expand Down
5 changes: 3 additions & 2 deletions cli/lib/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ export const deploySubgraph = (
ipfs: string;
},
options?: {
"access-token": string;
"access-token"?: string;
"version-label"?: string;
}
) => {
const argsString = Object.entries({...args, ...options})
.map(([name, value]) => `--${name} ${value}`)
.join(" ");

return execSync(
`npx graph deploy ${subgraphName} ${argsString} ${manifestPath}`,
`npx graph deploy ${subgraphName} ${argsString} ${manifestPath}`,
{
stdio: "inherit",
},
Expand Down

0 comments on commit 59a5254

Please sign in to comment.