From d42fb450a524dd13b4490dfd88021f3c627a675c Mon Sep 17 00:00:00 2001 From: Darien Hernandez Date: Tue, 9 Dec 2025 11:24:06 +0100 Subject: [PATCH 1/6] docs: Add docker-compose example and update setup guide with new scripts --- README.md | 17 ++++ content/validators/docker-compose.yaml | 42 ++++++++++ pages/validators/setup-guide.mdx | 1 - scripts/README.md | 73 +++++++++++++++++ .../update-docker-compose-in-setup-guide.js | 81 +++++++++++++++++++ 5 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 content/validators/docker-compose.yaml create mode 100644 scripts/README.md create mode 100755 scripts/update-docker-compose-in-setup-guide.js diff --git a/README.md b/README.md index 67f4f12ca..1216479ad 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,23 @@ To add a new changelog entry: The entries are sorted in descending order (newest first) automatically. +### Updating the Validator Setup Guide + +The setup guide contains configuration examples that are maintained in separate source files. To update these sections, use the scripts in the [`scripts/`](./scripts/README.md) directory: + +```sh +# Update version list and download command from changelog versions +node scripts/update-setup-guide-versions.js + +# Update config.yaml example from content/validators/config.yaml +node scripts/update-config-in-setup-guide.js + +# Update docker-compose.yaml example from content/validators/docker-compose.yaml +node scripts/update-docker-compose-in-setup-guide.js +``` + +See [scripts/README.md](./scripts/README.md) for detailed documentation. + ### Adding New API Documentation The API documentation for GenLayer Node is automatically generated from individual method files. diff --git a/content/validators/docker-compose.yaml b/content/validators/docker-compose.yaml new file mode 100644 index 000000000..c6f27c8d2 --- /dev/null +++ b/content/validators/docker-compose.yaml @@ -0,0 +1,42 @@ +services: + webdriver-container: + container_name: genlayer-node-webdriver + image: yeagerai/genlayer-genvm-webdriver:0.0.9 + shm_size: 2gb + security_opt: + - no-new-privileges:true + environment: + PORT: 4444 + ports: + - "${WEBDRIVER_PORT:-4444}:4444" + restart: unless-stopped + + genlayer-node: + image: yeagerai/genlayer-node:${NODE_VERSION:-v0.4.0} + entrypoint: [ + "sh", "-c", "/app/bin/genlayernode run --password ${NODE_PASSWORD:-12345678}", + ] + container_name: genlayer-node + restart: unless-stopped + env_file: + - path: ./.env + required: false + ports: + - "${NODE_RPC_PORT:-9151}:9151" + - "${NODE_OPS_PORT:-9153}:9153" + volumes: + - ${NODE_CONFIG_PATH:-./configs/node/config.yaml}:/app/configs/node/config.yaml:ro + - ${NODE_DATA_PATH:-./data}:/app/data + - ./genvm-module-web-docker.yaml:/app/third_party/genvm/config/genvm-module-web.yaml + security_opt: + - no-new-privileges:true + logging: + driver: "json-file" + options: + max-size: "100m" + max-file: "3" + compress: "true" + depends_on: + - webdriver-container + profiles: + - node diff --git a/pages/validators/setup-guide.mdx b/pages/validators/setup-guide.mdx index 099358d50..110fc2d54 100644 --- a/pages/validators/setup-guide.mdx +++ b/pages/validators/setup-guide.mdx @@ -524,7 +524,6 @@ After setting up your operator key, back it up securely: To print the private key from your backup file, use the `--print` flag. **Keep this private key secure and never share it.** - ### Running the node Once you have configured everything, you are ready to start the node. diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 000000000..1faa1db54 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,73 @@ +# Scripts + +This directory contains utility scripts for maintaining the GenLayer documentation. + +## Quick Reference + +```sh +# Update version list and download command from changelog +node scripts/update-setup-guide-versions.js + +# Update config.yaml example in setup guide +node scripts/update-config-in-setup-guide.js + +# Update docker-compose.yaml example in setup guide +node scripts/update-docker-compose-in-setup-guide.js +``` + +## Setup Guide Update Scripts + +These scripts update specific sections of the validator setup guide (`pages/validators/setup-guide.mdx`) from source files in the `content/` directory. + +### update-setup-guide-versions.js + +Updates the version list and download command in the setup guide based on available changelog versions. + +**Source:** `content/validators/changelog/*.mdx` + +**What it updates:** +- Version list example output (sorted newest first) +- `export version=vX.X.X` download command with latest version + +**Run:** +```sh +node scripts/update-setup-guide-versions.js +``` + +### update-config-in-setup-guide.js + +Updates the `config.yaml` example block in the setup guide. + +**Source:** `content/validators/config.yaml` + +**What it updates:** +- The YAML code block after "You can use the following example configuration" + +**Run:** +```sh +node scripts/update-config-in-setup-guide.js +``` + +### update-docker-compose-in-setup-guide.js + +Updates the `docker-compose.yaml` example block in the setup guide. + +**Source:** `content/validators/docker-compose.yaml` + +**What it updates:** +- The YAML code block after "Create a `docker-compose.yaml` file with the following content" + +**Run:** +```sh +node scripts/update-docker-compose-in-setup-guide.js +``` + +## Other Scripts + +| Script | Description | +|--------|-------------| +| `generate-full-docs.js` | Concatenates all MDX files into a single documentation file | +| `generate-sitemap-xml.js` | Generates `sitemap.xml` from all MDX files | +| `generate-changelog.js` | Generates the changelog page from individual version files | +| `generate-node-api-docs.js` | Generates API documentation and navigation | +| `sync-meta-files.js` | Synchronizes `_meta.json` files with actual content | diff --git a/scripts/update-docker-compose-in-setup-guide.js b/scripts/update-docker-compose-in-setup-guide.js new file mode 100755 index 000000000..b05b6cec1 --- /dev/null +++ b/scripts/update-docker-compose-in-setup-guide.js @@ -0,0 +1,81 @@ +#!/usr/bin/env node + +const fs = require('fs'); +const path = require('path'); + +/** + * Update the setup guide with the latest docker-compose from content/validators/docker-compose.yaml + */ +function updateDockerComposeInSetupGuide() { + const dockerComposePath = path.join(process.cwd(), 'content/validators/docker-compose.yaml'); + const setupGuidePath = path.join(process.cwd(), 'pages/validators/setup-guide.mdx'); + + if (!fs.existsSync(dockerComposePath)) { + console.error(`Docker compose file ${dockerComposePath} does not exist`); + return; + } + + if (!fs.existsSync(setupGuidePath)) { + console.error(`Setup guide file ${setupGuidePath} does not exist`); + return; + } + + // Read the docker-compose.yaml content + const dockerComposeContent = fs.readFileSync(dockerComposePath, 'utf8'); + + // Read the setup guide + let setupGuideContent = fs.readFileSync(setupGuidePath, 'utf8'); + + // Pattern to match the docker-compose YAML block + // Looks for the text before the yaml block, the yaml block itself, and the text after + const dockerComposePattern = /(Create a `docker-compose\.yaml` file with the following content:[^`]*```yaml\n)([\s\S]*?)(\n```)/; + + if (dockerComposePattern.test(setupGuideContent)) { + // Replace the docker-compose content while preserving the surrounding text + setupGuideContent = setupGuideContent.replace( + dockerComposePattern, + `$1${dockerComposeContent}$3` + ); + + // Write the updated content back + fs.writeFileSync(setupGuidePath, setupGuideContent); + console.log(`Updated setup guide docker-compose at ${new Date().toISOString()}`); + } else { + console.error('Could not find docker-compose pattern in setup guide'); + + // Try a more general pattern as fallback + // Look for a yaml block that contains typical docker-compose content + const fallbackPattern = /(```yaml\n)([\s\S]*?)(\n```)/g; + let match; + let found = false; + + while ((match = fallbackPattern.exec(setupGuideContent)) !== null) { + // Check if this looks like the docker-compose block by looking for typical docker-compose content + if (match[2].includes('webdriver-container') || match[2].includes('genlayer-node:')) { + const fullMatch = match[0]; + const startIndex = match.index; + + setupGuideContent = + setupGuideContent.slice(0, startIndex) + + `\`\`\`yaml\n${dockerComposeContent}\n\`\`\`` + + setupGuideContent.slice(startIndex + fullMatch.length); + + fs.writeFileSync(setupGuidePath, setupGuideContent); + console.log(`Updated setup guide docker-compose using fallback pattern at ${new Date().toISOString()}`); + found = true; + break; + } + } + + if (!found) { + console.error('Could not find docker-compose YAML block in setup guide'); + } + } +} + +// Run the script +if (require.main === module) { + updateDockerComposeInSetupGuide(); +} + +module.exports = { updateDockerComposeInSetupGuide }; From 7d35f93f75497b4dfbd5adcfd68275b295d00152 Mon Sep 17 00:00:00 2001 From: Darien Hernandez Date: Tue, 9 Dec 2025 11:27:31 +0100 Subject: [PATCH 2/6] fix: Fix setup guide to use project root for docker-compose path --- scripts/update-docker-compose-in-setup-guide.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/update-docker-compose-in-setup-guide.js b/scripts/update-docker-compose-in-setup-guide.js index b05b6cec1..12099cd2c 100755 --- a/scripts/update-docker-compose-in-setup-guide.js +++ b/scripts/update-docker-compose-in-setup-guide.js @@ -7,8 +7,9 @@ const path = require('path'); * Update the setup guide with the latest docker-compose from content/validators/docker-compose.yaml */ function updateDockerComposeInSetupGuide() { - const dockerComposePath = path.join(process.cwd(), 'content/validators/docker-compose.yaml'); - const setupGuidePath = path.join(process.cwd(), 'pages/validators/setup-guide.mdx'); + const projectRoot = path.join(__dirname, '..'); + const dockerComposePath = path.join(projectRoot, 'content/validators/docker-compose.yaml'); + const setupGuidePath = path.join(projectRoot, 'pages/validators/setup-guide.mdx'); if (!fs.existsSync(dockerComposePath)) { console.error(`Docker compose file ${dockerComposePath} does not exist`); From 4d91ce29f905d4e4515f40b90a73f9c82c7632e5 Mon Sep 17 00:00:00 2001 From: Darien Hernandez Date: Tue, 9 Dec 2025 11:40:29 +0100 Subject: [PATCH 3/6] docs: Remove sanitization script from action and sync workflow --- .github/actions/sync-files/action.yml | 20 +--- .github/scripts/sanitize-config.py | 119 ---------------------- .github/scripts/sanitize-config.sh | 34 ------- .github/workflows/sync-docs-from-node.yml | 2 - 4 files changed, 4 insertions(+), 171 deletions(-) delete mode 100644 .github/scripts/sanitize-config.py delete mode 100755 .github/scripts/sanitize-config.sh diff --git a/.github/actions/sync-files/action.yml b/.github/actions/sync-files/action.yml index ee19f1b00..4a4f05e22 100644 --- a/.github/actions/sync-files/action.yml +++ b/.github/actions/sync-files/action.yml @@ -21,10 +21,6 @@ inputs: description: 'Comma-separated list of filenames to exclude' required: false default: 'README,CHANGELOG,.gitignore,.gitkeep' - sanitize_script: - description: 'Optional script path to run after sync (for sanitization/post-processing)' - required: false - default: '' outputs: added: description: 'Number of files added' @@ -46,24 +42,16 @@ runs: shell: bash run: | # For config type, handle special case: - # 1. Copy config.yaml.example to temp location as config.yaml - # 2. Run sanitization on the renamed file - # 3. Use the sanitized file as source for sync - + # Copy config.yaml.example to temp location as config.yaml + if [[ -f "${{ inputs.source_path }}" ]]; then # Create temp directory TEMP_DIR=$(mktemp -d) echo "TEMP_CONFIG_DIR=$TEMP_DIR" >> $GITHUB_ENV - + # Copy and rename config.yaml.example to config.yaml cp "${{ inputs.source_path }}" "$TEMP_DIR/config.yaml" - - # Run sanitization if script is provided - if [[ -n "${{ inputs.sanitize_script }}" ]] && [[ -f "${{ inputs.sanitize_script }}" ]]; then - echo "Sanitizing config file..." - bash "${{ inputs.sanitize_script }}" "$TEMP_DIR/config.yaml" - fi - + # Update source path for sync echo "CONFIG_SOURCE=$TEMP_DIR/config.yaml" >> $GITHUB_ENV else diff --git a/.github/scripts/sanitize-config.py b/.github/scripts/sanitize-config.py deleted file mode 100644 index f27574b25..000000000 --- a/.github/scripts/sanitize-config.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env python3 -""" -Sanitize GenLayer node configuration by removing dev sections. - -This script is used by the GitHub Actions workflow to prepare the config -for documentation by removing development-only sections. -""" - -import sys - - -def find_section_end(lines, start_idx, base_indent): - """Find the end of a YAML section based on indentation.""" - idx = start_idx + 1 - while idx < len(lines): - line = lines[idx] - # Skip empty lines and comments - if line.strip() == '' or line.strip().startswith('#'): - idx += 1 - continue - - # Get the indentation of the current line - current_indent = len(line) - len(line.lstrip()) - - # If we find a line with same or less indentation than the section header, - # the section has ended - if current_indent <= base_indent: - return idx - - idx += 1 - - # If we reach the end of file, return the length - return len(lines) - - -def sanitize_config(config_file_path): - """Remove node.dev sections from config file.""" - print(f"Sanitizing config file: {config_file_path}") - - # Read the YAML file - with open(config_file_path, 'r') as f: - content = f.read() - - print(f"Original file size: {len(content)} bytes") - - # Split into lines for easier processing - lines = content.splitlines(keepends=True) - - # Track lines to remove - lines_to_remove = set() - - # Find and mark node.dev sections - i = 0 - while i < len(lines): - line = lines[i] - stripped = line.strip() - - # Check if this is a dev: line under node: - if stripped == 'dev:': - # Get the indentation of this line - indent = len(line) - len(line.lstrip()) - - # Make sure this is under a node: section by checking previous lines - # Look for 'node:' at a lower indentation level - is_under_node = False - for j in range(i-1, -1, -1): - prev_line = lines[j].strip() - if prev_line == '': - continue - prev_indent = len(lines[j]) - len(lines[j].lstrip()) - if prev_indent < indent and prev_line.startswith('node:'): - is_under_node = True - break - elif prev_indent < indent: - # Found a different section at lower indent - break - - if is_under_node: - # Find the end of this section - section_end = find_section_end(lines, i, indent) - - # Mark all lines in this section for removal - for idx in range(i, section_end): - lines_to_remove.add(idx) - - print(f"Removed node.{stripped[:-1]} section (lines {i+1}-{section_end})") - - # Skip to the end of this section - i = section_end - 1 - - i += 1 - - # Remove marked lines - new_lines = [line for idx, line in enumerate(lines) if idx not in lines_to_remove] - - # Write back to file - with open(config_file_path, 'w') as f: - f.writelines(new_lines) - - print(f"Sanitized file size: {sum(len(line) for line in new_lines)} bytes") - print("Config sanitization completed") - - -def main(): - if len(sys.argv) != 2: - print(f"Usage: {sys.argv[0]} ", file=sys.stderr) - sys.exit(1) - - config_file_path = sys.argv[1] - - try: - sanitize_config(config_file_path) - except Exception as e: - print(f"Error sanitizing config: {e}", file=sys.stderr) - sys.exit(1) - - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/.github/scripts/sanitize-config.sh b/.github/scripts/sanitize-config.sh deleted file mode 100755 index 611af825e..000000000 --- a/.github/scripts/sanitize-config.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -set -e - -# Sanitize GenLayer config file for documentation -# Usage: sanitize-config.sh - -CONFIG_FILE="$1" - -if [[ -z "$CONFIG_FILE" ]]; then - echo "Usage: $0 " >&2 - exit 1 -fi - -if [[ ! -f "$CONFIG_FILE" ]]; then - echo "File not found: $CONFIG_FILE" >&2 - exit 1 -fi - -echo "Sanitizing config file: $CONFIG_FILE" - -# Replace URLs with TODO placeholders (only on non-commented lines; preserve indent) -sed -i.bak -E '/^[[:space:]]*#/! s|^([[:space:]]*)zksyncurl:[[:space:]]*".*"|\1zksyncurl: "TODO: Set your GenLayer Chain ZKSync HTTP RPC URL here"|' "$CONFIG_FILE" -sed -i.bak -E '/^[[:space:]]*#/! s|^([[:space:]]*)zksyncwebsocketurl:[[:space:]]*".*"|\1zksyncwebsocketurl: "TODO: Set your GenLayer Chain ZKSync WebSocket RPC URL here"|' "$CONFIG_FILE" -rm -f "${CONFIG_FILE}.bak" - -# Remove node.dev sections using Python script -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -if [[ -f "$SCRIPT_DIR/sanitize-config.py" ]]; then - python3 "$SCRIPT_DIR/sanitize-config.py" "$CONFIG_FILE" -else - echo "Warning: sanitize-config.py not found, skipping Python sanitization" -fi - -echo "Config sanitization completed" \ No newline at end of file diff --git a/.github/workflows/sync-docs-from-node.yml b/.github/workflows/sync-docs-from-node.yml index 52ec1db6d..4181d2d5c 100644 --- a/.github/workflows/sync-docs-from-node.yml +++ b/.github/workflows/sync-docs-from-node.yml @@ -133,7 +133,6 @@ jobs: echo "source_path=source-repo/configs/node/config.yaml.example" >> $GITHUB_OUTPUT echo "target_path=content/validators/config.yaml" >> $GITHUB_OUTPUT echo "filter_pattern=.*" >> $GITHUB_OUTPUT - echo "sanitize_script=.github/scripts/sanitize-config.sh" >> $GITHUB_OUTPUT ;; "api_gen") echo "title=API Gen Methods" >> $GITHUB_OUTPUT @@ -164,7 +163,6 @@ jobs: source_path: ${{ steps.set_params.outputs.source_path }} target_path: ${{ steps.set_params.outputs.target_path }} filter_pattern: ${{ steps.set_params.outputs.filter_pattern }} - sanitize_script: ${{ steps.set_params.outputs.sanitize_script }} aggregate-results: name: 'Aggregate Sync Results' From 2073c550f6cbac16495d56d08464940cea3bf238 Mon Sep 17 00:00:00 2001 From: Darien Hernandez Date: Tue, 9 Dec 2025 11:59:56 +0100 Subject: [PATCH 4/6] docs: Update GitHub workflow to include docker-compose sync and enhance documentation generation --- .github/scripts/doc-generator.sh | 11 ++++++++++- .github/workflows/README.md | 20 ++++++++------------ .github/workflows/sync-docs-from-node.yml | 13 +++++++++++-- package.json | 7 ++++--- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/.github/scripts/doc-generator.sh b/.github/scripts/doc-generator.sh index c24e8de17..89184ce73 100755 --- a/.github/scripts/doc-generator.sh +++ b/.github/scripts/doc-generator.sh @@ -37,7 +37,16 @@ run_doc_generation() { failed=true fi echo "::endgroup::" - + + echo "::group::Running node-update-docker-compose" + if npm run node-update-docker-compose; then + echo "✅ Updated docker-compose in setup guide" + else + echo "❌ node-update-docker-compose failed" + failed=true + fi + echo "::endgroup::" + echo "::group::Running node-generate-api-docs" if npm run node-generate-api-docs; then echo "✅ Generated API documentation" diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 60922e62e..e02623d4e 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -12,9 +12,10 @@ This workflow automatically synchronizes documentation from the `genlayerlabs/ge ### What it does 1. **Prepare**: Detects version from input or automatically finds latest tag -2. **Sync Files** (parallel matrix strategy, 5 sync types): +2. **Sync Files** (parallel matrix strategy, 6 sync types): - **Changelog files** → `content/validators/changelog/` - - **Config file** → `content/validators/config.yaml` (with sanitization) + - **Config file** → `content/validators/config.yaml` + - **Docker Compose file** → `content/validators/docker-compose.yaml` - **API gen method docs** → `pages/api-references/genlayer-node/gen/` (filtered by regex) - **API debug method docs** → `pages/api-references/genlayer-node/debug/` (filtered by regex) - **API ops method docs** → `pages/api-references/genlayer-node/ops/` @@ -113,6 +114,8 @@ docs/ configs/ └── node/ └── config.yaml.example # Will be copied to content/validators/config.yaml +release/ +└── docker-compose.yaml # Will be copied to content/validators/docker-compose.yaml ``` ### Customizing Paths and Filtering @@ -141,7 +144,7 @@ The workflow uses 7 main jobs with the following dependency chain: ``` prepare (version detection) ↓ -sync-files (matrix: 5 parallel jobs) +sync-files (matrix: 6 parallel jobs) ↓ aggregate-results (merges artifacts) ↓ @@ -167,17 +170,9 @@ The workflow uses composite actions for code reusability: - `.github/scripts/sync-artifact-files.sh` - Applies synced files to repository with rsync --delete - `.github/scripts/aggregate-reports.sh` - Aggregates sync metrics from parallel jobs - `.github/scripts/git-utils.sh` - Branch creation, commit, and push operations -- `.github/scripts/sanitize-config.sh` - Sanitizes config files (URLs and dev sections) -- `.github/scripts/sanitize-config.py` - Python script to remove node.dev sections - `.github/scripts/version-utils.sh` - Version detection and validation - `.github/scripts/doc-generator.sh` - Wrapper for npm documentation generation -### Config File Sanitization -The config sync process includes automatic sanitization: -1. **URL Replacement**: Real URLs replaced with TODO placeholders -2. **Dev Section Removal**: `node.dev` sections stripped using Python script -3. **Comparison**: Only sanitized content is compared to detect actual changes - ### Branch Naming Convention Sync branches follow the pattern: `docs/node/{version}` - Example: `docs/node/v0.3.5` @@ -228,5 +223,6 @@ The summary job generates a comprehensive report in the GitHub Actions UI: After syncing files, the workflow runs these npm scripts: - `npm run node-generate-changelog` - Generates changelog page from synced files - `npm run node-update-setup-guide` - Updates setup guide with version info -- `npm run node-update-config` - Processes configuration documentation +- `npm run node-update-config` - Updates config.yaml example in setup guide +- `npm run node-update-docker-compose` - Updates docker-compose.yaml example in setup guide - `npm run node-generate-api-docs` - Generates API reference pages \ No newline at end of file diff --git a/.github/workflows/sync-docs-from-node.yml b/.github/workflows/sync-docs-from-node.yml index 4181d2d5c..8f76ac42b 100644 --- a/.github/workflows/sync-docs-from-node.yml +++ b/.github/workflows/sync-docs-from-node.yml @@ -92,7 +92,7 @@ jobs: needs: prepare strategy: matrix: - sync_type: [changelog, config, api_gen, api_debug, api_ops] + sync_type: [changelog, config, docker_compose, api_gen, api_debug, api_ops] fail-fast: false steps: - name: Checkout documentation repository @@ -114,6 +114,7 @@ jobs: sparse-checkout: | docs configs/node/config.yaml.example + release/docker-compose.yaml sparse-checkout-cone-mode: true path: source-repo ref: ${{ needs.prepare.outputs.version }} @@ -134,6 +135,12 @@ jobs: echo "target_path=content/validators/config.yaml" >> $GITHUB_OUTPUT echo "filter_pattern=.*" >> $GITHUB_OUTPUT ;; + "docker_compose") + echo "title=Docker Compose File" >> $GITHUB_OUTPUT + echo "source_path=source-repo/release/docker-compose.yaml" >> $GITHUB_OUTPUT + echo "target_path=content/validators/docker-compose.yaml" >> $GITHUB_OUTPUT + echo "filter_pattern=.*" >> $GITHUB_OUTPUT + ;; "api_gen") echo "title=API Gen Methods" >> $GITHUB_OUTPUT echo "source_path=source-repo/${{ github.event.inputs.api_gen_path || github.event.client_payload.api_gen_path || 'docs/api/rpc' }}" >> $GITHUB_OUTPUT @@ -398,6 +405,7 @@ jobs: - \`npm run node-generate-changelog\` - \`npm run node-update-setup-guide\` - \`npm run node-update-config\` + - \`npm run node-update-docker-compose\` - \`npm run node-generate-api-docs\` Please review the changes and merge if everything looks correct. @@ -465,11 +473,12 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY # Process each sync type report - for sync_type in changelog config api_gen api_debug api_ops; do + for sync_type in changelog config docker_compose api_gen api_debug api_ops; do # Get proper title case "$sync_type" in "changelog") title="📝 Changelog Sync" ;; "config") title="⚙️ Config File Sync" ;; + "docker_compose") title="🐳 Docker Compose Sync" ;; "api_gen") title="🔧 API Gen Methods Sync" ;; "api_debug") title="🐛 API Debug Methods Sync" ;; "api_ops") title="📊 API Ops Methods Sync" ;; diff --git a/package.json b/package.json index 9d327503b..83c325214 100644 --- a/package.json +++ b/package.json @@ -3,15 +3,16 @@ "version": "0.0.1", "description": "GenLayer documentation", "scripts": { - "dev": "npm run node-generate-changelog && npm run node-update-setup-guide && npm run node-update-config && npm run node-generate-api-docs && node scripts/generate-full-docs.js && next dev", - "build": "npm run node-generate-changelog && npm run node-update-setup-guide && npm run node-update-config && npm run node-generate-api-docs && node scripts/generate-full-docs.js && next build", + "dev": "npm run node-generate-changelog && npm run node-update-setup-guide && npm run node-update-config && npm run node-update-docker-compose && npm run node-generate-api-docs && node scripts/generate-full-docs.js && next dev", + "build": "npm run node-generate-changelog && npm run node-update-setup-guide && npm run node-update-config && npm run node-update-docker-compose && npm run node-generate-api-docs && node scripts/generate-full-docs.js && next build", "start": "next start", "test:e2e": "playwright test", "generate-sitemap": "node scripts/generate-sitemap-xml.js", "node-generate-changelog": "node scripts/generate-changelog.js", "node-generate-api-docs": "node scripts/generate-api-docs.js", "node-update-setup-guide": "node scripts/update-setup-guide-versions.js", - "node-update-config": "node scripts/update-config-in-setup-guide.js" + "node-update-config": "node scripts/update-config-in-setup-guide.js", + "node-update-docker-compose": "node scripts/update-docker-compose-in-setup-guide.js" }, "repository": { "type": "git", From 05668bd970fe0a41f005748d8cf69c52b3505c59 Mon Sep 17 00:00:00 2001 From: Darien Hernandez Date: Tue, 9 Dec 2025 12:11:24 +0100 Subject: [PATCH 5/6] docs: Enhance GitHub workflow to include docker-compose sanitization and update documentation --- .github/actions/sync-files/action.yml | 43 ++++++++++++++++++++-- .github/scripts/sanitize-docker-compose.sh | 26 +++++++++++++ .github/workflows/README.md | 6 +++ .github/workflows/sync-docs-from-node.yml | 5 --- 4 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 .github/scripts/sanitize-docker-compose.sh diff --git a/.github/actions/sync-files/action.yml b/.github/actions/sync-files/action.yml index 4a4f05e22..f3ea2d102 100644 --- a/.github/actions/sync-files/action.yml +++ b/.github/actions/sync-files/action.yml @@ -58,18 +58,45 @@ runs: echo "Config source file not found: ${{ inputs.source_path }}" exit 1 fi - + + - name: Prepare docker-compose file + if: inputs.type == 'docker_compose' + shell: bash + run: | + # For docker_compose type, handle special case: + # Copy and sanitize (remove alloy service and volumes) + + if [[ -f "${{ inputs.source_path }}" ]]; then + # Create temp directory + TEMP_DIR=$(mktemp -d) + echo "TEMP_DOCKER_COMPOSE_DIR=$TEMP_DIR" >> $GITHUB_ENV + + # Copy docker-compose.yaml + cp "${{ inputs.source_path }}" "$TEMP_DIR/docker-compose.yaml" + + # Sanitize: remove alloy service and volumes section using yq + bash .github/scripts/sanitize-docker-compose.sh "$TEMP_DIR/docker-compose.yaml" + + # Update source path for sync + echo "DOCKER_COMPOSE_SOURCE=$TEMP_DIR/docker-compose.yaml" >> $GITHUB_ENV + else + echo "Docker compose source file not found: ${{ inputs.source_path }}" + exit 1 + fi + - name: Sync files id: sync shell: bash run: | - # Use prepared config source if it's a config type, otherwise use original source + # Use prepared source for config/docker_compose types, otherwise use original source if [[ "${{ inputs.type }}" == "config" ]] && [[ -n "$CONFIG_SOURCE" ]]; then SOURCE_PATH="$CONFIG_SOURCE" + elif [[ "${{ inputs.type }}" == "docker_compose" ]] && [[ -n "$DOCKER_COMPOSE_SOURCE" ]]; then + SOURCE_PATH="$DOCKER_COMPOSE_SOURCE" else SOURCE_PATH="${{ inputs.source_path }}" fi - + ${{ github.action_path }}/sync.sh \ "${{ inputs.type }}" \ "${{ inputs.title }}" \ @@ -85,7 +112,15 @@ runs: if [[ -n "$TEMP_CONFIG_DIR" ]] && [[ -d "$TEMP_CONFIG_DIR" ]]; then rm -rf "$TEMP_CONFIG_DIR" fi - + + - name: Cleanup docker-compose temp directory + if: inputs.type == 'docker_compose' && always() + shell: bash + run: | + if [[ -n "$TEMP_DOCKER_COMPOSE_DIR" ]] && [[ -d "$TEMP_DOCKER_COMPOSE_DIR" ]]; then + rm -rf "$TEMP_DOCKER_COMPOSE_DIR" + fi + - name: Upload artifacts uses: actions/upload-artifact@v4 if: always() diff --git a/.github/scripts/sanitize-docker-compose.sh b/.github/scripts/sanitize-docker-compose.sh new file mode 100644 index 000000000..6988b282a --- /dev/null +++ b/.github/scripts/sanitize-docker-compose.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -e + +# Sanitize docker-compose.yaml for documentation +# Removes the alloy service, its comments, and volumes section +# Usage: sanitize-docker-compose.sh + +DOCKER_COMPOSE_FILE="$1" + +if [[ -z "$DOCKER_COMPOSE_FILE" ]]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +if [[ ! -f "$DOCKER_COMPOSE_FILE" ]]; then + echo "File not found: $DOCKER_COMPOSE_FILE" >&2 + exit 1 +fi + +echo "Sanitizing docker-compose file: $DOCKER_COMPOSE_FILE" + +# Remove everything from "# Grafana Alloy" comment to end of file +# This includes the alloy service comments, the service itself, and the volumes section +sed -i '/# Grafana Alloy/,$d' "$DOCKER_COMPOSE_FILE" + +echo "Docker-compose sanitization completed" diff --git a/.github/workflows/README.md b/.github/workflows/README.md index e02623d4e..6d3091c63 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -172,6 +172,12 @@ The workflow uses composite actions for code reusability: - `.github/scripts/git-utils.sh` - Branch creation, commit, and push operations - `.github/scripts/version-utils.sh` - Version detection and validation - `.github/scripts/doc-generator.sh` - Wrapper for npm documentation generation +- `.github/scripts/sanitize-docker-compose.sh` - Removes alloy service and volumes from docker-compose + +### Docker Compose Sanitization +The docker-compose sync process includes automatic sanitization using `sed`: +- Removes everything from the `# Grafana Alloy` comment to end of file +- This includes the alloy service comments, the service itself, and the volumes section ### Branch Naming Convention Sync branches follow the pattern: `docs/node/{version}` diff --git a/.github/workflows/sync-docs-from-node.yml b/.github/workflows/sync-docs-from-node.yml index 8f76ac42b..d5af77277 100644 --- a/.github/workflows/sync-docs-from-node.yml +++ b/.github/workflows/sync-docs-from-node.yml @@ -100,11 +100,6 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} - - name: Install Python dependencies - if: matrix.sync_type == 'config' - run: | - python3 -m pip install --upgrade pip pyyaml - - name: Clone source repository uses: actions/checkout@v4 with: From 7bdc20e4aa6cc9c5d32b3409fe9a05a03cf85e6d Mon Sep 17 00:00:00 2001 From: Darien Hernandez Date: Tue, 9 Dec 2025 12:35:21 +0100 Subject: [PATCH 6/6] chore: Restore config sanitization using yq - Add sanitize-config.sh using yq to replace RPC URLs and remove node.dev - Update docker-compose sanitization to use yq + sed - Install yq in workflow for both config and docker_compose sync types - Update README with sanitization documentation --- .github/actions/sync-files/action.yml | 5 +++- .github/scripts/sanitize-config.sh | 31 ++++++++++++++++++++++ .github/scripts/sanitize-docker-compose.sh | 11 +++++--- .github/workflows/README.md | 13 ++++++--- .github/workflows/sync-docs-from-node.yml | 6 +++++ 5 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 .github/scripts/sanitize-config.sh diff --git a/.github/actions/sync-files/action.yml b/.github/actions/sync-files/action.yml index f3ea2d102..d8eade875 100644 --- a/.github/actions/sync-files/action.yml +++ b/.github/actions/sync-files/action.yml @@ -42,7 +42,7 @@ runs: shell: bash run: | # For config type, handle special case: - # Copy config.yaml.example to temp location as config.yaml + # Copy config.yaml.example to temp location as config.yaml and sanitize if [[ -f "${{ inputs.source_path }}" ]]; then # Create temp directory @@ -52,6 +52,9 @@ runs: # Copy and rename config.yaml.example to config.yaml cp "${{ inputs.source_path }}" "$TEMP_DIR/config.yaml" + # Sanitize: replace RPC URLs with placeholders and remove dev section + bash .github/scripts/sanitize-config.sh "$TEMP_DIR/config.yaml" + # Update source path for sync echo "CONFIG_SOURCE=$TEMP_DIR/config.yaml" >> $GITHUB_ENV else diff --git a/.github/scripts/sanitize-config.sh b/.github/scripts/sanitize-config.sh new file mode 100644 index 000000000..569d16e6d --- /dev/null +++ b/.github/scripts/sanitize-config.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -e + +# Sanitize config.yaml for documentation +# Replaces RPC URLs with placeholders and removes dev section +# Usage: sanitize-config.sh + +CONFIG_FILE="$1" + +if [[ -z "$CONFIG_FILE" ]]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +if [[ ! -f "$CONFIG_FILE" ]]; then + echo "File not found: $CONFIG_FILE" >&2 + exit 1 +fi + +echo "Sanitizing config file: $CONFIG_FILE" + +# Use yq to: +# 1. Replace RPC URLs with TODO placeholders +# 2. Delete node.dev section +yq -i ' + .rollup.genlayerchainrpcurl = "TODO: Set your GenLayer Chain ZKSync HTTP RPC URL here" | + .rollup.genlayerchainwebsocketurl = "TODO: Set your GenLayer Chain ZKSync WebSocket RPC URL here" | + del(.node.dev) +' "$CONFIG_FILE" + +echo "Config sanitization completed" diff --git a/.github/scripts/sanitize-docker-compose.sh b/.github/scripts/sanitize-docker-compose.sh index 6988b282a..2b5b90a93 100644 --- a/.github/scripts/sanitize-docker-compose.sh +++ b/.github/scripts/sanitize-docker-compose.sh @@ -2,7 +2,7 @@ set -e # Sanitize docker-compose.yaml for documentation -# Removes the alloy service, its comments, and volumes section +# Removes the alloy service and volumes section # Usage: sanitize-docker-compose.sh DOCKER_COMPOSE_FILE="$1" @@ -19,8 +19,11 @@ fi echo "Sanitizing docker-compose file: $DOCKER_COMPOSE_FILE" -# Remove everything from "# Grafana Alloy" comment to end of file -# This includes the alloy service comments, the service itself, and the volumes section -sed -i '/# Grafana Alloy/,$d' "$DOCKER_COMPOSE_FILE" +# Use yq to remove alloy service and volumes section +yq -i 'del(.services.alloy) | del(.volumes)' "$DOCKER_COMPOSE_FILE" + +# Remove leftover comments about alloy (yq preserves them) +sed -i '/# Grafana Alloy/,/^[^ #]/{ /^[^ #]/!d }' "$DOCKER_COMPOSE_FILE" +sed -i '/^$/N;/^\n$/d' "$DOCKER_COMPOSE_FILE" echo "Docker-compose sanitization completed" diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 6d3091c63..0c5fb4dd2 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -172,12 +172,19 @@ The workflow uses composite actions for code reusability: - `.github/scripts/git-utils.sh` - Branch creation, commit, and push operations - `.github/scripts/version-utils.sh` - Version detection and validation - `.github/scripts/doc-generator.sh` - Wrapper for npm documentation generation +- `.github/scripts/sanitize-config.sh` - Sanitizes config file (replaces URLs, removes dev section) - `.github/scripts/sanitize-docker-compose.sh` - Removes alloy service and volumes from docker-compose +### Config Sanitization +The config sync process includes automatic sanitization using `yq`: +- **URL Replacement**: RPC URLs replaced with TODO placeholders +- **Dev Section Removal**: `node.dev` section is removed + ### Docker Compose Sanitization -The docker-compose sync process includes automatic sanitization using `sed`: -- Removes everything from the `# Grafana Alloy` comment to end of file -- This includes the alloy service comments, the service itself, and the volumes section +The docker-compose sync process includes automatic sanitization using `yq` and `sed`: +- **Alloy Service Removal**: The `alloy` monitoring service is removed +- **Volumes Removal**: The `volumes` section is removed +- **Comment Cleanup**: Alloy-related comments are removed ### Branch Naming Convention Sync branches follow the pattern: `docs/node/{version}` diff --git a/.github/workflows/sync-docs-from-node.yml b/.github/workflows/sync-docs-from-node.yml index d5af77277..33b7a3da4 100644 --- a/.github/workflows/sync-docs-from-node.yml +++ b/.github/workflows/sync-docs-from-node.yml @@ -100,6 +100,12 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} + - name: Install yq for YAML sanitization + if: matrix.sync_type == 'config' || matrix.sync_type == 'docker_compose' + run: | + sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 + sudo chmod +x /usr/local/bin/yq + - name: Clone source repository uses: actions/checkout@v4 with: