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

docs: added a docusaurus tutorial #69

Merged
merged 29 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d28e832
docs: ran 'npx create-docusaurus@latest docs classic'
srdtrk May 21, 2024
0fa1212
deps: ran 'npm install -D tailwindcss'
srdtrk May 21, 2024
a1be26a
imp: ran 'npx tailwindcss init --ts'
srdtrk May 21, 2024
8747bc2
imp: added tailwindcss script
srdtrk May 21, 2024
ba0595b
lint: ran 'npm init @eslint/config@latest'
srdtrk May 21, 2024
13d95c5
docs: removed docusaurus
srdtrk May 21, 2024
879b63b
docs: cloned docs form cw-ica-controller
srdtrk May 21, 2024
35db5bd
imp: removed versioned docs
srdtrk May 21, 2024
50199b3
docs: adapted the landing page for go-codegen
srdtrk May 21, 2024
04b09c5
deps: ran 'npm i @docusaurus/core@latest @docusaurus/plugin-client-re…
srdtrk May 21, 2024
e5074c1
imp: tutorial page loads now
srdtrk May 22, 2024
bd740b6
imp: highlight box fixed
srdtrk May 22, 2024
e59a311
imp: more tags and info
srdtrk May 22, 2024
37caabf
docs: removed unneeded files
srdtrk May 22, 2024
f745986
imp: added setup env page
srdtrk May 22, 2024
30f6cd1
docs: imp
srdtrk May 22, 2024
f751ea8
imp: things are ready to go
srdtrk May 22, 2024
76803e0
docs: added more content
srdtrk May 23, 2024
9ee02a9
imp: improved
srdtrk May 23, 2024
18ece0f
docs: reorganized section 2
srdtrk May 23, 2024
08c2137
docs: added scaffold suite
srdtrk May 23, 2024
d0b6be2
imp: additional codeblock options
srdtrk May 23, 2024
4ba8a74
docs: added todo
srdtrk May 23, 2024
f18732b
docs: added 'add-contracts' section
srdtrk May 25, 2024
9912f21
imp: added ci info
srdtrk May 26, 2024
2bef04a
docs: closer to the final version
srdtrk May 26, 2024
c9414f0
docs: added ending remark
srdtrk May 27, 2024
e7b70a9
ci: added docs ci
srdtrk May 27, 2024
d79d55f
fix: remove broken redirects
srdtrk May 27, 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
29 changes: 29 additions & 0 deletions .github/workflows/check-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This check-docs workflow was created based on instructions from:
# https://docusaurus.io/docs/deployment
name: Check docs build
# This workflow runs when a PR is labeled with `docs`
# This will check if the docs build successfully by running `npm run build`
on:
pull_request:
branches:
- main
paths:
- 'docs/**'
- '.github/workflows/check-docs.yml'

jobs:
check-docs-build:
name: Check docs build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
cache-dependency-path: docs/package-lock.json

- name: Install dependencies
run: cd docs && npm ci
- name: Test build website
run: cd docs && npm run build
48 changes: 48 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This deploy-docs workflow was created based on instructions from:
# https://docusaurus.io/docs/deployment
name: Deploy to GitHub Pages

on:
push:
branches:
- main
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on

permissions:
contents: write

jobs:
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
cache-dependency-path: docs/package-lock.json

- name: Install dependencies
run: cd docs && npm ci
- name: Build website
run: cd docs && npm run build

# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Build output to publish to the `gh-pages` branch:
publish_dir: ./docs/build
# The following lines assign commit authorship to the official
# GH-Actions bot for deploys to `gh-pages` branch:
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
# The GH actions bot is used by default if you didn't specify the two fields.
# You can swap them out with your own user credentials.
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
36 changes: 36 additions & 0 deletions docs/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended"
],
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"react"
],
"rules": {
"react/prop-types": "off"
}
}
20 changes: 20 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
25 changes: 25 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Website

This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.

### Installation

```
$ npm i
```

### Local Development

```
$ npm start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ npm run build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.
3 changes: 3 additions & 0 deletions docs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
17 changes: 17 additions & 0 deletions docs/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/css/globals.css",
"baseColor": "slate",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
76 changes: 76 additions & 0 deletions docs/docs/00-intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: Introduction
sidebar_label: Introduction
sidebar_position: 0
slug: /
---

import HighlightTag from '@site/src/components/HighlightTag';
import HighlightBox from '@site/src/components/HighlightBox';

# `go-codegen` Interchaintest Tutorial

<HighlightTag type="tutorial"/><HighlightTag type="guided-coding"/><HighlightTag type="cosmwasm"/><HighlightTag type="developer"/><HighlightTag type="ibc-go"/><HighlightTag type="advanced"/>

This is a tutorial for writing end-to-end test suite for IBC enabled CosmWasm applications using go-codegen.
Powered by [interchaintest](https://github.com/strangelove-ventures/interchaintest).

<HighlightBox type="prerequisite" title="Prerequisites">

- Basic knowledge of [golang](https://go.dev/)
- Basic knowledge of [CosmWasm](https://cosmwasm.com/)
- Basic knowledge of [github actions](https://github.com/features/actions)

</HighlightBox>

## Context

### What is go-codegen?

go-codegen is a tool that generates go code for CosmWasm applications. It can currently generate the following:

- Message definitions for a contract.
- gRPC query client for a contract.
- An end-to-end test suite for a contract based on interchaintest.

<HighlightBox type="info" title="What is interchaintest?">

`interchaintest` is a framework for testing blockchain functionality and interoperability between chains, primarily with the Inter-Blockchain Communication (IBC) protocol.

It can quickly spin up custom testnets and dev environments to test IBC, Relayer setup, chain infrastructure, smart contracts, etc. Interchaintest orchestrates Go tests that utilize Docker containers for multiple IBC-compatible blockchains.

In order to ship production-grade software for the Interchain, we needed sophisticated developer tooling...but IBC and Web3 have a lot of moving parts, which can lead to a steep learning curve and all sorts of pain.

- repeatedly building repo-specific, Docker- and shell-based testing solutions,
- duplication of effort, and
- difficulty in repurposing existing testing harnesses for new problem domains.

Read more about interchaintest in its [README.md](https://github.com/strangelove-ventures/interchaintest/blob/main/README.md).

</HighlightBox>

### Why use this over other scripting solutions?

- **Go as a Scripting Language**
- **Local Testing Environment:** The testing framework operates entirely locally, mirroring a production environment closely. This ensures that tests are reliable and can be seamlessly integrated into continuous integration (CI) pipelines.
- **Industry Adoption:** Interchaintest, the underlying framework, is widely adopted by leading projects and core teams in the CosmWasm ecosystem, including Strangelove, the IBC team, Noble, DAODAO, and others.
- **Funding and Support:** The development of Interchaintest is supported by the Interchain Foundation (ICF), ensuring ongoing improvements and stability.

By using go-codegen, your CosmWasm application can benefit from a well-supported, reliable, widely-adopted testing framework.

## Scope

This tutorial will cover spinning up a local testing environment with interchaintest. We will be testing [cw-ica-controller](https://github.com/srdtrk/cw-ica-controller) to control a native interchain account in the host chain.

<HighlightBox type="learning" title="Learning Goals">

In this tutorial, you will:

- Compile a CosmWasm contract into wasm and generate its JSON schema
- Scaffold an end-to-end testsuite with github actions consisting of two chains using go-codegen.
- Add our contract to the testsuite using go-codegen.
- Create a transfer channel between the two chains.
- Create an IBC channel between the contract and the counterparty go module.
- Send an ICA transaction and verify it.

</HighlightBox>
103 changes: 103 additions & 0 deletions docs/docs/01-setup-env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
title: Set Up Your Work Environment
sidebar_label: Set Up Your Work Environment
sidebar_position: 1
slug: /setup-env
---

import HighlightBox from '@site/src/components/HighlightBox';

# Set Up Your Work Environment

On this page, you can find helpful links to set up your work environment.

<HighlightBox type="info" title="Dependencies">

In this section, you can find all you need to install:

- [Git](https://git-scm.com/)
- [Go v1.22.3](https://go.dev/)
- [go-codegen v0.2.2](https://github.com/srdtrk/go-codegen)
- [Docker](https://www.docker.com/)
- [Rust and Cargo](https://www.rust-lang.org/)
- [just](https://just.systems/) (optional)

</HighlightBox>

<HighlightBox type="note" title="Note">

On a general note, it is advisable to prepare a separate project folder to keep all your Cosmos exercises.

</HighlightBox>

## Git

Install Git following the instructions on the [Git website](https://git-scm.com/). Test if Git is installed by running the following command:

```bash
git --version
```

## Go

Install the latest version of Go following the instructions on the [Go website](https://go.dev/). Test if Go is installed by running the following command:

```bash
go version
```

## go-codegen

Install go-codegen by following the instructions on the [README.md](https://github.com/srdtrk/go-codegen/blob/main/README.md) or by using the command below.

```bash
go install github.com/srdtrk/[email protected]
```

Test if go-codegen is installed by running the following command:

```bash
go-codegen version
```

## Docker

Install Docker following the instructions on the [Docker documentation](https://docs.docker.com/get-docker/). Test if Docker is installed by running the following command:

```bash
docker --version
```

## Rust and Cargo

Install Rust and Cargo following the instructions on the [Rust book](https://doc.rust-lang.org/book/ch01-01-installation.html). Test if Rust is installed by running the following commands:

```bash
cargo --version
```

## just

<HighlightBox type="info" title="Just">

[Just](https://just.systems/) is a handy `make` alternative written in Rust. It is optional but recommended for this tutorial. Instead of writing a `Makefile`, you can write a `justfile` to automate your tasks.

</HighlightBox>

Install just following the instructions on the [just manual](https://just.systems/man/en/chapter_4.html) or by using the command below.

```bash
cargo install just
```

Test if just is installed by running the following command:

```bash
just --version
```

<HighlightBox type="tip" title="Just">

If you don't want to install `just`, you can simply run the commands in the `justfile` manually.

</HighlightBox>
Loading