Skip to content

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
redrobin4103 committed Oct 30, 2024
1 parent 6d1b96a commit 2678c79
Show file tree
Hide file tree
Showing 93 changed files with 11,739 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
extends: ["next/core-web-vitals", "prettier"],
plugins: ["simple-import-sort"],
rules: {
"react-hooks/exhaustive-deps": "error",
"import/newline-after-import": [
"error",
{
count: 1,
},
],
// increase the severity of rules so they are auto-fixable
"simple-import-sort/imports": [
"error",
{
groups: [
// Packages `react` related packages come first.
["^react", "^@?\\w"],
// Internal packages.
["^(@)(/.*|$)"],
// Side effect imports.
["^\\u0000"],
// Parent imports. Put `..` last.
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
// Other relative imports. Put same-folder imports and `.` last.
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
// Style imports.
["^.+\\.?(css)$"],
],
},
],
"simple-import-sort/exports": "error",
},
};
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @inkonchain/developers-secret
31 changes: 31 additions & 0 deletions .github/actions/base-setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Basic Setup'
description: 'Basic setup with pnpm and cache restore'
runs:
using: "composite"
steps:
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
run_install: false

- name: Setup Node 20
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "pnpm"

- name: Add pnpm store path to env var
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Restore Cache
uses: actions/cache@v4
with:
path: |
${{ steps.pnpm-cache.outputs.STORE_PATH }}
**/node_modules
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
6 changes: 6 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
110 changes: 110 additions & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: CI/CD Workflow
on:
pull_request:
push:
branches:
- main

jobs:
install_modules:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- uses: pnpm/action-setup@v2
with:
version: 9.12.3
run_install: false
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Add pnpm store path to env var
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Cache node modules
uses: actions/cache@v4
with:
path: |
${{ steps.pnpm-cache.outputs.STORE_PATH }}
**/node_modules
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
js-lint:
needs: install_modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
name: Base Setup
- name: JS linting
run: pnpm run lint:js

md-lint:
needs: install_modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
name: Base Setup
- name: MDX linting
run: pnpm run lint:mdx

format:
needs: install_modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
name: Base Setup
- name: Run formatting
run: pnpm run format:js

spell-check:
needs: install_modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
name: Base Setup
- name: Run Spellcheck
run: pnpm run spellcheck:lint

build:
needs: install_modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
name: Base Setup
- name: Building app
run: pnpm run build

docker-publish:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/inkonchain/docs:latest

- name: Log out from GitHub Container Registry
run: docker logout ghcr.io
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# packages
node_modules

# os specific files
.DS_Store

# build artifacts
.next
public/robots.txt
public/sitemap-0.xml
public/sitemap.xml

# log files
*.log

out
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.11.0
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false
}
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"editor.formatOnSave": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[typescriptreact, javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
},
"[plaintext]": {
"editor.formatOnSave": false
},
"editor.formatOnPaste": false,
"prettier.useEditorConfig": false,
"prettier.useTabs": false,
"prettier.configPath": ".prettierrc",
"prettier.prettierPath": "node_modules/prettier"
}
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:20.11.0
WORKDIR /app
RUN npm install -g pnpm
COPY package.json pnpm-lock.yaml ./
RUN pnpm install
COPY . .
RUN pnpm run build
RUN adduser --system --uid 1001 docs-user
USER docs-user
EXPOSE 3000
CMD ["pnpm", "start"]
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,55 @@
# docs
Inkchain Documentation
# InkChain Docs App

## Build

```bash
docker build -t docs .
docker run -p 3000:3000 docs
```

## Requirements

- NodeJs (v20.11.0)

## Overview

This is a Next.js Documentation application built using [Nextra](https://nextra.site/), a tool that simplifies the process of creating documentation sites with Next.js. As we are utilizing Nextra, the application currently relies on the [Pages Router]() provided by Next.js for navigation and routing. Currently, we are not able to upgrade to use the App Router, due to it not being yet supported by Nextra.

## Getting Started

Clone this repository, install the dependencies, and start the development server with the following commands:

```bash
pnpm install
pnpm run dev
```

## Tooling

We are using a bunch of tools to enhance our development experience and to prevent us from pushing code with errors.
Here are some of the tools we are using:

- **[cspell](https://cspell.org/)**: for real-time spell checking and maintaining documentation quality.
- **[remark](https://remark.js.org/)**: for processing and rendering Markdown content with additional plugins.
- **[ESLint](https://eslint.org/)**: for enforcing code quality standards and catching potential issues.
- **[Prettier](https://prettier.io/)**: for enforcing code quality standards and catching potential issues.
- **[Tailwind CSS](https://tailwindcss.com/)**: for utility-first CSS styling and rapid UI development.

## CI/CD

We leverage GitHub Actions to perform some automated checks on all of our PRs. In particular, we run the following checks:

- **js-lint**: Run Eslint to make sure JS code is formatted correctly.
- **md-lint**: Run Remark to make sure Markdown code is formatted correctly.
- **format**: Run Prettier to make sure code is formatted correctly.
- **spell-check**: Run CSpell to make sure the content of our MDX files has the right spelling. Sometimes this command may fail for legit words (e.g. "inkchain") if that is the case, then we can simply add any word that we'd like to whitelist to the [`./cspell/project-words.txt`](./cspell/project-words.txt) file

### Feature Branch Deployment

Each pull request (PR) submitted to this repository triggers an automated deployment process through AWS Amplify. When a PR is opened or updated, AWS Amplify Console automatically deploys the changes to a unique, temporary hosting environment. This allows for real-time testing and review of the feature branch's changes in a live setting. The deployment URL is provided within the PR checks, enabling team members and stakeholders to interact with the new features before they are merged into the main branch.

This continuous deployment pipeline ensures that code is tested in a production-like environment early in the development cycle, helping to catch issues early and streamline the overall development process.

### Production Deployment

The application is set up for continuous deployment using AWS Amplify. Upon every merge into the `main` branch, AWS Amplify automatically triggers a new build and deploys the updated version of the application. This ensures that the latest documentation is always available to end-users without any manual intervention in the deployment process.
17 changes: 17 additions & 0 deletions amplify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 1
frontend:
phases:
preBuild:
commands:
- npm install -g pnpm
- pnpm install --frozen-lockfile
build:
commands:
- pnpm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
18 changes: 18 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"dictionaryDefinitions": [
{
"name": "project-words",
"path": "./cspell/project-words.txt",
"addWords": true
}
],
"dictionaries": [
"project-words"
],
"ignorePaths": [
"node_modules",
"/project-words.txt"
]
}
Loading

0 comments on commit 2678c79

Please sign in to comment.