Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 1 addition & 15 deletions config/snippet-config/splice-snippet-list-remote.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,6 @@
"language": "yaml"
}
},
{
"snippetName": "splice-literal-marker-apps-app-src-pack-examples-sv-helm-sv-values-migration-start",
"sourceRepo": "splice",
"sourceFilepath": "apps/app/src/pack/examples/sv-helm/sv-values.yaml",
"location": {
"type": "stringMarker",
"start": "MIGRATION_START",
"end": "MIGRATION_END"
},
"description": "",
"options": {
"language": "yaml"
}
},
{
"snippetName": "splice-literal-marker-apps-app-src-pack-examples-sv-helm-validator-values-auto-accept-start",
"sourceRepo": "splice",
Expand Down Expand Up @@ -930,7 +916,7 @@
"location": {
"type": "lines",
"start": 1135,
"end": 1143
"end": 1139
},
"description": "",
"options": {
Expand Down
18 changes: 0 additions & 18 deletions docs-main/global-synchronizer/deployment/kubernetes-deployment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,6 @@ For configuring your sv app, please modify the file `splice-node/examples/sv-hel
- If you would like to redistribute all or part of the SV rewards with other parties, you can fill up the `extraBeneficiaries` section with the desired parties and the percentage of the reward that corresponds to them. Note that the party you register must be known on the network for the reward coupon issuance to succeed. Furthermore, that party must be hosted on a validator node for its wallet to collect the SV reward coupons. That collection will happen automatically if the wallet is running. If it is not running during the time that the reward coupon can be collected, the corresponding reward is marked as unclaimed, and stored in an DSO-wide unclaimed reward pool. The `extraBeneficiaries` can be changed with just a restart of the SV app.
- Optionally, uncomment the line for `initialAmuletPrice` and set it to your desired amulet price. This will create an amulet price vote from your SV with the configured price when onboarded. If not set, no vote will be cast. This can always be done later manually from the SV app UI.

```yaml
# Replace MIGRATION_ID with the migration ID of the global synchronizer.
migration:
# This should stay constant after the introduction of logical synchronizer upgrades.
id: "MIGRATION_ID"
```
Please modify the file `splice-node/examples/sv-helm/info-values.yaml` as follows:

- Replace `TARGET_CLUSTER` with dev
Expand Down Expand Up @@ -765,12 +759,6 @@ For configuring your sv app, please modify the file `splice-node/examples/sv-hel
- If you would like to redistribute all or part of the SV rewards with other parties, you can fill up the `extraBeneficiaries` section with the desired parties and the percentage of the reward that corresponds to them. Note that the party you register must be known on the network for the reward coupon issuance to succeed. Furthermore, that party must be hosted on a validator node for its wallet to collect the SV reward coupons. That collection will happen automatically if the wallet is running. If it is not running during the time that the reward coupon can be collected, the corresponding reward is marked as unclaimed, and stored in an DSO-wide unclaimed reward pool. The `extraBeneficiaries` can be changed with just a restart of the SV app.
- Optionally, uncomment the line for `initialAmuletPrice` and set it to your desired amulet price. This will create an amulet price vote from your SV with the configured price when onboarded. If not set, no vote will be cast. This can always be done later manually from the SV app UI.

```yaml
# Replace MIGRATION_ID with the migration ID of the global synchronizer.
migration:
# This should stay constant after the introduction of logical synchronizer upgrades.
id: "MIGRATION_ID"
```
Please modify the file `splice-node/examples/sv-helm/info-values.yaml` as follows:

- Replace `TARGET_CLUSTER` with test
Expand Down Expand Up @@ -873,12 +861,6 @@ For configuring your sv app, please modify the file `splice-node/examples/sv-hel
- If you would like to redistribute all or part of the SV rewards with other parties, you can fill up the `extraBeneficiaries` section with the desired parties and the percentage of the reward that corresponds to them. Note that the party you register must be known on the network for the reward coupon issuance to succeed. Furthermore, that party must be hosted on a validator node for its wallet to collect the SV reward coupons. That collection will happen automatically if the wallet is running. If it is not running during the time that the reward coupon can be collected, the corresponding reward is marked as unclaimed, and stored in an DSO-wide unclaimed reward pool. The `extraBeneficiaries` can be changed with just a restart of the SV app.
- Optionally, uncomment the line for `initialAmuletPrice` and set it to your desired amulet price. This will create an amulet price vote from your SV with the configured price when onboarded. If not set, no vote will be cast. This can always be done later manually from the SV app UI.

```yaml
# Replace MIGRATION_ID with the migration ID of the global synchronizer.
migration:
# This should stay constant after the introduction of logical synchronizer upgrades.
id: "MIGRATION_ID"
```
Please modify the file `splice-node/examples/sv-helm/info-values.yaml` as follows:

- Replace `TARGET_CLUSTER` with main
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import ExternalSpliceMainSpliceRstLiteralMarkerAppsAppSrcPackExamplesSvHelmSvValuesMigrationStart from "/snippets/external/splice/main/splice-literal-marker-apps-app-src-pack-examples-sv-helm-sv-values-migration-start.mdx";
import ExternalSpliceMainSpliceRstCodeDocsSrcSvOperatorSvHelmBash627 from "/snippets/external/splice/main/splice-rst-code-docs-src-sv-operator-sv-helm-bash-627.mdx";

To install the Helm charts needed to start an SV node connected to the cluster, you will need to meet a few preconditions. The first is that there needs to be an environment variable defined to refer to the version of the Helm charts necessary to connect to this environment:
Expand Down Expand Up @@ -76,8 +75,6 @@ For configuring your sv app, please modify the file `splice-node/examples/sv-hel
- If you would like to redistribute all or part of the SV rewards with other parties, you can fill up the `extraBeneficiaries` section with the desired parties and the percentage of the reward that corresponds to them. Note that the party you register must be known on the network for the reward coupon issuance to succeed. Furthermore, that party must be hosted on a validator node for its wallet to collect the SV reward coupons. That collection will happen automatically if the wallet is running. If it is not running during the time that the reward coupon can be collected, the corresponding reward is marked as unclaimed, and stored in an DSO-wide unclaimed reward pool. The `extraBeneficiaries` can be changed with just a restart of the SV app.
- Optionally, uncomment the line for `initialAmuletPrice` and set it to your desired amulet price. This will create an amulet price vote from your SV with the configured price when onboarded. If not set, no vote will be cast. This can always be done later manually from the SV app UI.

<ExternalSpliceMainSpliceRstLiteralMarkerAppsAppSrcPackExamplesSvHelmSvValuesMigrationStart />

Please modify the file `splice-node/examples/sv-helm/info-values.yaml` as follows:

- Replace `TARGET_CLUSTER` with |splice_cluster|
Expand Down
20 changes: 15 additions & 5 deletions scripts/generate_external_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

CF_DOCS_ROOT = Path(__file__).resolve().parents[1]
GIB = 1024**3
HELPER_SOURCE_DIR = CF_DOCS_ROOT / "scripts" / "helpers"
HELPER_DEPENDENCIES = ("rstIncludeToMdx.js",)


@dataclass(frozen=True)
Expand Down Expand Up @@ -130,7 +132,7 @@ def parse_args() -> argparse.Namespace:
parser.add_argument(
"--copy-output",
action="store_true",
help="Copy docs-output into snippets/external/<repo>/<version> in this cf-docs checkout.",
help="Copy docs-output into docs-main/snippets/external/<repo>/<version> in this cf-docs checkout.",
)
parser.add_argument(
"--version",
Expand All @@ -140,7 +142,7 @@ def parse_args() -> argparse.Namespace:
parser.add_argument(
"--replace-output",
action="store_true",
help="With --copy-output, remove the target snippets/external folder before copying.",
help="With --copy-output, remove the target docs-main/snippets/external folder before copying.",
)
parser.add_argument(
"--min-free-gb",
Expand All @@ -166,7 +168,11 @@ def config_path(repo: SnippetRepo) -> Path:


def helper_path() -> Path:
return CF_DOCS_ROOT / "scripts" / "generateOutputDocs.js"
return HELPER_SOURCE_DIR / "generateOutputDocs.js"


def helper_dependency_paths() -> list[Path]:
return [HELPER_SOURCE_DIR / name for name in HELPER_DEPENDENCIES]


def repo_label(repo: SnippetRepo) -> str:
Expand Down Expand Up @@ -327,12 +333,16 @@ def copy_helper_and_config(repo: SnippetRepo, source_dir: Path, dry_run: bool) -
target_export = target_scripts / "exportConfig.json"

print(f"Copy helper: {helper_path()} -> {target_helper}")
for dependency in helper_dependency_paths():
print(f"Copy helper dependency: {dependency} -> {target_scripts / dependency.name}")
print(f"Copy config: {config_path(repo)} -> {target_export}")
if dry_run:
return target_helper

target_scripts.mkdir(parents=True, exist_ok=True)
shutil.copy2(helper_path(), target_helper)
for dependency in helper_dependency_paths():
shutil.copy2(dependency, target_scripts / dependency.name)
shutil.copy2(config_path(repo), target_export)
return target_helper

Expand Down Expand Up @@ -366,7 +376,7 @@ def run_extraction(

def copy_output(repo: SnippetRepo, source_dir: Path, version: str, replace: bool, dry_run: bool) -> Path:
source_output = source_dir / "docs-output"
target = CF_DOCS_ROOT / "snippets" / "external" / repo_label(repo) / version
target = CF_DOCS_ROOT / "docs-main" / "snippets" / "external" / repo_label(repo) / version
if not dry_run and not source_output.is_dir():
raise SystemExit(f"Expected generated docs-output directory does not exist: {source_output}")
print(f"Copy output: {source_output} -> {target}")
Expand All @@ -382,7 +392,7 @@ def copy_output(repo: SnippetRepo, source_dir: Path, version: str, replace: bool
def validate_inputs(repo: SnippetRepo) -> None:
missing = [
path
for path in (helper_path(), config_path(repo))
for path in (helper_path(), *helper_dependency_paths(), config_path(repo))
if not path.is_file()
]
if missing:
Expand Down
77 changes: 77 additions & 0 deletions tests/test_generate_external_snippets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from __future__ import annotations

from pathlib import Path

import pytest

from scripts import generate_external_snippets as generator


def test_copy_helper_and_config_copies_helper_dependency(tmp_path: Path) -> None:
source_dir = tmp_path / "splice"
helper = generator.copy_helper_and_config(
generator.REPOS["splice"],
source_dir,
dry_run=False,
)

target_scripts = source_dir / "scripts" / "docs"
assert helper == target_scripts / "generateOutputDocs.js"
assert helper.is_file()
assert (target_scripts / "rstIncludeToMdx.js").is_file()
assert (target_scripts / "exportConfig.json").is_file()


def test_copy_helper_and_config_preserves_repo_specific_helper_name(tmp_path: Path) -> None:
source_dir = tmp_path / "splice-wallet-kernel"
helper = generator.copy_helper_and_config(
generator.REPOS["splice-wallet-kernel"],
source_dir,
dry_run=False,
)

target_scripts = source_dir / "scripts" / "docs"
assert helper == target_scripts / "generateOutputDocs.cjs"
assert helper.is_file()
assert (target_scripts / "rstIncludeToMdx.js").is_file()


def test_validate_inputs_reports_missing_helper_dependency(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
fake_root = tmp_path / "cf-docs"
fake_helpers = fake_root / "scripts" / "helpers"
fake_config = fake_root / "config" / "snippet-config"
fake_helpers.mkdir(parents=True)
fake_config.mkdir(parents=True)
(fake_helpers / "generateOutputDocs.js").write_text("", encoding="utf-8")
(fake_config / "splice-snippet-list-remote.json").write_text("{}", encoding="utf-8")

monkeypatch.setattr(generator, "CF_DOCS_ROOT", fake_root)
monkeypatch.setattr(generator, "HELPER_SOURCE_DIR", fake_helpers)

with pytest.raises(SystemExit) as error:
generator.validate_inputs(generator.REPOS["splice"])

assert "rstIncludeToMdx.js" in str(error.value)


def test_copy_output_targets_docs_main_snippets(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
source_dir = tmp_path / "splice"
docs_output = source_dir / "docs-output"
docs_output.mkdir(parents=True)
(docs_output / "example.mdx").write_text("content", encoding="utf-8")
fake_root = tmp_path / "cf-docs"

monkeypatch.setattr(generator, "CF_DOCS_ROOT", fake_root)

target = generator.copy_output(
generator.REPOS["splice"],
source_dir,
version="main",
replace=False,
dry_run=False,
)

assert target == fake_root / "docs-main" / "snippets" / "external" / "splice" / "main"
assert (target / "example.mdx").read_text(encoding="utf-8") == "content"