Skip to content

Commit

Permalink
Add docs build or publish to workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejearley committed Aug 15, 2023
1 parent fba1848 commit a9cd80f
Show file tree
Hide file tree
Showing 26 changed files with 496 additions and 331 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install mdBook KaTeX and Mermaid plugins
uses: actions-rs/cargo@v1
with:
command: install
args: mdbook-katex mdbook-mermaid

- name: Install and build all package dependencies
run: npm ci
env:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ jobs:

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install mdBook KaTeX and Mermaid plugins
uses: actions-rs/cargo@v1
with:
command: install
args: mdbook-katex mdbook-mermaid

- name: Install and build all package dependencies
run: npm ci
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install mdBook KaTeX and Mermaid plugins
uses: actions-rs/cargo@v1
with:
command: install
args: mdbook-katex mdbook-mermaid

- name: Install and build all package dependencies
run: npm ci
env:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install mdBook KaTeX and Mermaid plugins
uses: actions-rs/cargo@v1
with:
command: install
args: mdbook-katex mdbook-mermaid

- name: Install and build all package dependencies
run: npm ci
env:
Expand Down
63 changes: 63 additions & 0 deletions common/data/notebooks/dkg.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Check DKG "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Casimir Goerli DKG messenger is up and healthy\n"
]
}
],
"source": [
"import requests\n",
"\n",
"url = f\"https://nodes.casimir.co/eth/goerli/dkg/messenger/ping\"\n",
"\n",
"response = requests.get(url)\n",
"\n",
"if response.status_code != 200:\n",
" print(f\"Casimir Goerli DKG messenger server is not responding\")\n",
"else: \n",
" data = response.json()\n",
" if data['message'] == \"pong\":\n",
" print(f\"Casimir Goerli DKG messenger is responding and healthy\")\n",
" else:\n",
" print(f\"Casimir Goerli DKG messenger is responding and not healthy\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "casimir-data",
"language": "python",
"name": "casimir-data"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
66 changes: 39 additions & 27 deletions common/data/notebooks/ethereum.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Check Casimir RPC nodes\n",
"\n",
"Edit `NETWORK` to select the network to check. "
"# Check Ethereum"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Casimir mainnet node is fully synced\n",
"Casimir goerli node is fully synced\n",
"Casimir hardhat node is fully synced\n"
]
}
Expand All @@ -28,35 +28,47 @@
"import requests\n",
"from requests.auth import HTTPBasicAuth\n",
"\n",
"NETWORK = \"hardhat\"\n",
"networks = {\n",
" \"mainnet\": {\n",
" \"requires_auth\": True\n",
" },\n",
" \"goerli\": {\n",
" \"requires_auth\": True\n",
" },\n",
" \"hardhat\": {\n",
" \"requires_auth\": False\n",
" }\n",
"}\n",
"\n",
"if NETWORK not in [\"mainnet\", \"goerli\", \"hardhat\"]:\n",
" raise ValueError(f\"Invalid network: {NETWORK}\")\n",
"for network, requires_auth in networks.items():\n",
"\n",
"url = f\"https://nodes.casimir.co/eth/{NETWORK}\"\n",
" url = f\"https://nodes.casimir.co/eth/{network}\"\n",
"\n",
"headers = {'content-type': 'application/json'}\n",
"payload = {\n",
" \"method\": \"eth_syncing\",\n",
" \"params\": [],\n",
" \"jsonrpc\": \"2.0\",\n",
" \"id\": 0,\n",
"}\n",
"auth = None\n",
" headers = {'content-type': 'application/json'}\n",
" payload = {\n",
" \"method\": \"eth_syncing\",\n",
" \"params\": [],\n",
" \"jsonrpc\": \"2.0\",\n",
" \"id\": 0,\n",
" }\n",
"\n",
"if NETWORK in [\"mainnet\", \"goerli\"]:\n",
" client = boto3.client('secretsmanager')\n",
" response = client.get_secret_value(SecretId='casimir-rpc-credentials')\n",
" secret = json.loads(response['SecretString'])\n",
" auth = HTTPBasicAuth(secret['username'], secret['password'])\n",
" auth = None\n",
" if requires_auth:\n",
" client = boto3.client('secretsmanager')\n",
" response = client.get_secret_value(SecretId='casimir-rpc-credentials')\n",
" secret = json.loads(response['SecretString'])\n",
" auth = HTTPBasicAuth(secret['username'], secret['password'])\n",
"\n",
"response = requests.post(url, data=json.dumps(payload), headers=headers, auth=auth)\n",
"data = response.json()\n",
" response = requests.post(url, data=json.dumps(payload), headers=headers, auth=auth)\n",
"\n",
"if data['result'] == False:\n",
" print(f\"Casimir {NETWORK} node is fully synced\")\n",
"else:\n",
" print(f\"Casimir {NETWORK} node is syncing. Current block: {data['result']['currentBlock']}, Highest block: {data['result']['highestBlock']}\")\n",
" if response.status_code != 200:\n",
" print(f\"Casimir {network} node is not responding\")\n",
" else: \n",
" data = response.json()\n",
" if data['result'] == False:\n",
" print(f\"Casimir {network} node is fully synced\")\n",
" else:\n",
" print(f\"Casimir {network} node is syncing. Current block: {data['result']['currentBlock']}, Highest block: {data['result']['highestBlock']}\")\n",
"\n"
]
}
Expand Down
1 change: 1 addition & 0 deletions contracts/ethereum/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ test = 'test'
cache_path = 'build/foundry/cache'

[doc]
title = 'Casimir Ethereum Docs'
out = 'build/foundry/docs'
4 changes: 2 additions & 2 deletions contracts/ethereum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "@casimir/ethereum",
"scripts": {
"build": "npx hardhat compile",
"build:docs": "npx esno scripts/docs.ts",
"clean": "npx rimraf ./build",
"deploy": "npx hardhat run scripts/deploy.ts",
"dev": "npx hardhat run scripts/dev.ts",
"doc": "npx esno scripts/doc.ts",
"doc:serve": "SERVE=true npx esno scripts/doc.ts",
"dev:docs": "DEV=true npx esno scripts/docs.ts",
"node": "npx hardhat node",
"postinstall": "npx esno scripts/foundryup.ts",
"test": "npx esno scripts/test.ts"
Expand Down
19 changes: 0 additions & 19 deletions contracts/ethereum/scripts/doc.ts

This file was deleted.

40 changes: 40 additions & 0 deletions contracts/ethereum/scripts/docs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import fs from 'fs'
import { run } from '@casimir/helpers'

void async function () {
const cargo = await run('which cargo') as string
if (!cargo || cargo.includes('not found')) {
throw new Error('🚩 Please install rust (see https://www.rust-lang.org/tools/install)')
}

const mdbookKatex = await run('cargo install --list | grep mdbook-katex') as string
if (!mdbookKatex) {
await run('cargo install mdbook-katex')
}

const mdbookMermaid = await run('cargo install --list | grep mdbook-mermaid') as string
if (!mdbookMermaid) {
await run('cargo install mdbook-mermaid')
}

const config = await run('forge config') as string

const outDir = config.match(/\[doc\]\nout = "(.*)"/)?.[1] as string
if (!fs.existsSync(outDir)) {
fs.mkdirSync(outDir, { recursive: true })
}

const publicDir = fs.readdirSync('public')
for (const file of publicDir) {
fs.copyFileSync(`public/${file}`, `${outDir}/${file}`)
}

let command = 'forge doc'
if (process.env.DEV === 'true') {
command += ' --serve --port=5458'
} else {
command += ' --build'
}

await run(command)
}()
9 changes: 5 additions & 4 deletions infrastructure/cdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ import { LandingStack } from './providers/landing'
import { NodesStack } from './providers/nodes'
import { DnsStack } from './providers/dns'
import { WebStack } from './providers/web'
import { DocsStack } from './providers/docs'

/** Create CDK app and stacks */
const config = new Config()
const { env, stage } = config
const app = new cdk.App()

const { hostedZone, certificate } = new DnsStack(app, config.getFullStackName('dns'), { env })
const { vpc } = new NetworkStack(app, config.getFullStackName('network'), { env })

if (stage !== 'prod') {
/** Create development-only stacks */
new AnalyticsStack(app, config.getFullStackName('analytics'), { env })
new UsersStack(app, config.getFullStackName('users'), { env, certificate, hostedZone, vpc })
new WebStack(app, config.getFullStackName('web'), { env, certificate, hostedZone })
} else {
/** Create production-only stacks */
new DocsStack(app, config.getFullStackName('docs'), { env, certificate, hostedZone })
new NodesStack(app, config.getFullStackName('nodes'), { env, hostedZone })
}
/** Create remaining stacks */

new LandingStack(app, config.getFullStackName('landing'), { env, certificate, hostedZone })
8 changes: 1 addition & 7 deletions infrastructure/cdk/src/interfaces/ProjectConfig.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
export interface ProjectConfig {
/** Deployment AWS env */
env: {
/** AWS account number */
account: string
/** AWS region */
region: string
}
/** Project name */
project: string
/** Stage name */
stage: string
/** Stage-specific root domain (i.e., casimir.co for prod, dev.casimir.co for dev) */
rootDomain: string
/** Stage-specific subdomains (i.e., api.casimir.co for prod, api.dev.casimir.co for dev) */
subdomains: {
docsEthereum: string
landing: string
nodes: string
users: string
Expand Down
20 changes: 8 additions & 12 deletions infrastructure/cdk/src/interfaces/StackProps.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
import * as cdk from 'aws-cdk-lib'
import * as certmgr from 'aws-cdk-lib/aws-certificatemanager'
import * as ec2 from 'aws-cdk-lib/aws-ec2'
import * as ecs from 'aws-cdk-lib/aws-ecs'
import * as route53 from 'aws-cdk-lib/aws-route53'

export type DnsStackProps = cdk.StackProps
export type AnalyticsStackProps = cdk.StackProps
export type NetworkStackProps = cdk.StackProps

export interface DocsStackProps extends cdk.StackProps {
certificate: certmgr.Certificate
hostedZone: route53.HostedZone
}

export interface LandingStackProps extends cdk.StackProps {
/** Stage-specific certificate */
certificate?: certmgr.Certificate
/** Project-wide route53 hosted zone */
certificate: certmgr.Certificate
hostedZone: route53.HostedZone
}

export interface WebStackProps extends cdk.StackProps {
/** Stage-specific certificate */
certificate?: certmgr.Certificate
/** Project-wide route53 hosted zone */
certificate: certmgr.Certificate
hostedZone: route53.HostedZone
}

export interface NodesStackProps extends cdk.StackProps {
/** Project-wide route53 hosted zone */
hostedZone: route53.HostedZone
}

export interface UsersStackProps extends cdk.StackProps {
/** Stage-specific certificate */
certificate?: certmgr.Certificate
/** Project-wide route53 hosted zone */
certificate: certmgr.Certificate
hostedZone: route53.HostedZone
/** Stage-specific VPC */
vpc: ec2.Vpc
}
Loading

0 comments on commit a9cd80f

Please sign in to comment.