Skip to content

Commit

Permalink
Refactor scripts and actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jlvandenhout authored Aug 30, 2023
1 parent 542b25e commit 5b30986
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 76 deletions.
11 changes: 7 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/node_modules

# External documentation
/*/external
/docs/external

# Production
/build
Expand All @@ -16,6 +16,9 @@
/cli/test

# Ignore autogenerated API docs
/iota/develop/nodes/rest-api
/shimmer/develop/nodes/core-rest-api
/next/develop/nodes/core-rest-api
/docs/build/iota-sdk/1.0.0/docs/references
!/docs/build/iota-sdk/1.0.0/docs/references/rust-api-reference.md
!/docs/build/iota-sdk/1.0.0/docs/references/wasm-api-reference.md
/docs/build/apis
!/docs/build/apis/welcome.md
!/docs/build/apis/sidebars.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: build
description: Build the wiki
name: prepare
description: Prepare environment for building the Wiki

runs:
using: 'composite'
Expand All @@ -24,18 +24,13 @@ runs:
run: |
yarn
shell: bash
- name: Prepare build
run: |
yarn prepare
shell: bash
# Artifacts cached after install to prevent removal by Yarn
- name: Cache build artifacts
uses: actions/cache@v3
with:
path: node_modules/.cache
key: wiki-build-artifacts-${{ hashFiles('package.json', 'yarn.lock', 'src/**/*.*') }}
# Create reference docs
- name: Build reference docs
run: |
./scripts/gen_sdk_references.sh
shell: bash
- name: Build
run: |
NODE_OPTIONS='--max-old-space-size=4096' yarn build:production
shell: bash
13 changes: 8 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
env:
MODE: production
steps:
- uses: actions/checkout@v3
with:
# Needed for showLastUpdateTime to work
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
- name: build
uses: ./.github/actions/build/
- name: Prepare
uses: ./.github/actions/prepare/
- name: Checkout remote
run: yarn checkout:remote
- name: Build
run: yarn build
# Convert to Vercel project and upload
- name: Install Vercel CLI
run: npm install --global vercel@latest
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.issue.pull_request && format('refs/pull/{0}/merge', github.event.issue.number) || '' }}
# Needed for showLastUpdateTime to work
fetch-depth: 0
- name: build
uses: ./.github/actions/build/
- name: Prepare
uses: ./.github/actions/prepare/
- name: Build
run: yarn build
# Convert to Vercel project and upload
- name: Install Vercel CLI
run: npm install --global vercel@latest
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/test-build.yaml

This file was deleted.

10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ jobs:
- name: Format Wiki
run: |
yarn format:check
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare
uses: ./.github/actions/prepare/
- name: Checkout remote
run: yarn checkout:remote
- name: Build
run: yarn build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node_modules
# Generated files
.docusaurus
.cache-loader
/tmp

# External
/external/*
Expand Down
11 changes: 7 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/node_modules

# External documentation
/*/external
/docs/external

# Production
/build
Expand All @@ -16,6 +16,9 @@
/cli/test

# Ignore autogenerated API docs
/iota/develop/nodes/rest-api
/shimmer/develop/nodes/core-rest-api
/next/develop/nodes/core-rest-api
/docs/build/iota-sdk/1.0.0/docs/references
!/docs/build/iota-sdk/1.0.0/docs/references/rust-api-reference.md
!/docs/build/iota-sdk/1.0.0/docs/references/wasm-api-reference.md
/docs/build/apis
!/docs/build/apis/welcome.md
!/docs/build/apis/sidebars.ts
41 changes: 13 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,39 +63,24 @@ The IOTA Wiki is built using [TypeScript](https://www.typescriptlang.org/), [Rea

### Preview Locally

Because the Wiki is a large project composed of several Docusaurus builds and external documentation, a full build takes a while. To speed up development, we provide environment variables to select different configurations, and some convenience scripts with environment variables pre-configured.
To preview the Wiki locally, use the following steps. For more detailed scripts, see [Pre-configured scripts](#pre-configured-scripts) for reference.

To preview the Wiki locally, use the following steps. For more preview and build configurations, see [Pre-configured scripts](#pre-configured-scripts) and [Environment variables](#environment-variables) for reference.
> Please note that the Wiki has a lot of content, so currently the initial build is taking a while. Effort is taken to try and reduce the build time in the future.
1. Clone the repository by running `git clone https://github.com/iota-wiki/iota-wiki.git` and go to the directory with `cd iota-wiki`.
1. Clone the repository by running `git clone https://github.com/iotaledger/iota-wiki.git` and go to the directory with `cd iota-wiki`.
2. Install dependencies with `yarn`.
3. Build the theme and all plugins once with `yarn build:theme && yarn build:plugins`
4. Preview a specific environment with `yarn start:<environment>` where environment can be `iota`, `shimmer` or `next`.

You should always prefer previewing only a specific environment of the Wiki, but if you need a complete Wiki build you can replace step 3 with `yarn start:all`.
Keep in mind this will take a while and has no hot reloading capability.
3. Prepare the environment by running `yarn prepare`, this has to be done only once.
4. Preview the Wiki with `yarn start`, this will start a development server serving the Wiki with hot reload capability, so it will update content after any changes were made.

#### Pre-configured scripts

| Script | Explanation |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `start:<environment>` | Start a development server for the `iota`, `shimmer`, or `next` environment, with hot reloading on changes. |
| `start:all` | Build all environments and serve the result, without hot reloading on changes. |
| `build:<environment>` | Build the `iota`, `shimmer`, or `next` environment. |
| `build:all` | Build all environments. |
| `checkout:remote:<environment>` | Check out the latest version of external documentation for the `iota`, `shimmer`, or `next` environment. |
| `checkout:remote` | Check out the latest version of external documentation. |
| `generate:api` | Generate available API documentation configured through the [Docusaurus OpenAPI plugin](https://www.npmjs.com/package/@paloaltonetworks/docusaurus-plugin-openapi). |

#### Environment variables

| Variable | Accepts | Default | Explanation |
| ----------- | --------------------------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| ENVIRONMENT | One of `iota`, `shimmer`, or `next` | `iota` | The environment to build. |
| MODE | One of `development`, or `production` | `development` | Depending on the mode chosen, some functionalities are included or excluded (analytics for example). |
| EXTERNAL | A comma separated list of glob patterns | | What external documentation to include in the build. Glob patterns are relative to the `<environment>/external` directories. |

> For example `ENVIRONMENT=iota EXTERNAL=tips/** yarn start` starts a development server for the `iota` environment with the TIPs included
| Script | Explanation |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `prepare` | Prepare the environment by checking out submodules and building local packages needed for the Wiki build. |
| `start` | Start a development server serving the Wiki, with hot reloading on changes. |
| `build` | Build the Wiki. To build for production, checkout the latest version of external documentation by running `yarn checkout:remote` and set the `MODE` environment variable to `production`. |
| `checkout:remote` | Check out the latest version of external documentation. |
| `generate:api` | Generate available API documentation configured through the [Docusaurus OpenAPI plugin](https://www.npmjs.com/package/@paloaltonetworks/docusaurus-plugin-openapi) and by compiling documentation from source code. |

<!-- CONTRIBUTING -->

Expand All @@ -106,7 +91,7 @@ The IOTA Wiki is maintained by the IF and community contributions are always wel
1. Fork this repository to your own account and clone it (`git clone https://github.com/<YOUR_USERNAME>/iota-wiki.git`)
2. Create a feature branch for your changes (`git checkout -b feat/amazing-feature`).
3. Make your changes and optionally [preview them locally](#preview-locally).
4. Run `yarn lint` and `yarn format` and fix any remaining errors and warnings.
4. Run `yarn format` and `yarn lint` and fix any remaining errors and warnings.
5. Commit your changes (`git commit -m 'Add some amazing feature'`).
6. Push your changes to your fork (`git push origin feat/amazing-feature`).
7. Open a pull request to the `main` branch of this repository.
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
"scripts": {
"build:plugins": "yarn ./plugins/tutorial build && yarn ./plugins/docs build",
"build:theme": "yarn ./theme build",
"build:production": "(MODE=\"production\" yarn checkout:remote && yarn build:plugins && yarn build:theme && yarn generate:api && yarn build)",
"checkout": "git submodule update --init",
"checkout:remote": "yarn checkout --remote",
"generate:api": "docusaurus gen-api-docs all",
"generate:api": "docusaurus gen-api-docs all && ./scripts/gen_sdk_references.sh",
"lint": "eslint --cache --fix .",
"lint:check": "eslint --cache .",
"lint:links": "iota-wiki check",
"format": "prettier --cache --write .",
"format:check": "prettier --cache --check .",
"format:svg": "svgo ./src/**/*.svg",
"prepare": "yarn checkout && yarn build:plugins && yarn build:theme && yarn generate:api",
"docusaurus": "docusaurus",
"start": "yarn generate:api && NODE_OPTIONS=--max-old-space-size=8192 docusaurus start",
"build": "docusaurus build",
"start": "NODE_OPTIONS='--max-old-space-size=4096' docusaurus start",
"build": "NODE_OPTIONS='--max-old-space-size=4096' docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
Expand Down
9 changes: 6 additions & 3 deletions scripts/gen_sdk_references.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/sh

# Create temporaty directory to work in and clone SDK
mkdir tmp && cd tmp
mkdir tmp
cd tmp
git clone --depth 1 --branch develop https://github.com/iotaledger/iota-sdk
cd iota-sdk

# Generate and copy Python references
cd bindings/python
python -m venv .venv
source .venv/bin/activate
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements-dev.txt
PYTHONPATH=. pydoc-markdown
cp -Rv docs/references/python ../../../../docs/build/iota-sdk/1.0.0/docs/references/
Expand Down

0 comments on commit 5b30986

Please sign in to comment.