From bae6600e7f918c335f8293758c3b09ffe34df0e5 Mon Sep 17 00:00:00 2001 From: eseiker Date: Tue, 3 Dec 2024 17:17:14 +0900 Subject: [PATCH] update planets validation/update actions update planets/index.json use main planet registry --- .github/scripts/validate-planets.js | 25 +++++++ .github/workflows/planets.yaml | 17 ----- .github/workflows/update-planets.yaml | 28 +++++++ .github/workflows/validate-planets.yaml | 17 +++++ planets/index.json | 8 +- planets/schema.json | 97 ------------------------- 6 files changed, 77 insertions(+), 115 deletions(-) create mode 100644 .github/scripts/validate-planets.js delete mode 100644 .github/workflows/planets.yaml create mode 100644 .github/workflows/update-planets.yaml create mode 100644 .github/workflows/validate-planets.yaml delete mode 100644 planets/schema.json diff --git a/.github/scripts/validate-planets.js b/.github/scripts/validate-planets.js new file mode 100644 index 00000000..1a870cb2 --- /dev/null +++ b/.github/scripts/validate-planets.js @@ -0,0 +1,25 @@ +import * as path from "jsr:@std/path"; + +import Ajv2019 from "npm:ajv/dist/2019.js"; +import addFormats from "npm:ajv-formats"; + +const baseUrl = + "https://planetarium.github.io/json-schema/NineChronicles/2024-12/"; +const fetchJsonSchema = async (name) => + await (await fetch(path.join(baseUrl, `/${name}.schema.json`))).json(); + +const ajv = new Ajv2019({ allErrors: true }); +addFormats(ajv); + +ajv.addSchema(await fetchJsonSchema("PlanetSpec"), "PlanetSpec.schema.json"); + +const validate = ajv.compile(await fetchJsonSchema("PlanetRegistry")); + +for (const filename of Deno.args) { + console.log(`validating ${filename}`); + const valid = validate(JSON.parse(await Deno.readTextFile(filename))); + if (!valid) { + console.error(`Error validating ${filename}:`, validate.errors); + Deno.exit(1); + } +} diff --git a/.github/workflows/planets.yaml b/.github/workflows/planets.yaml deleted file mode 100644 index 1f5eae43..00000000 --- a/.github/workflows/planets.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: Validate planets config -on: - pull_request: - paths: - - 'planets/**.json' - -jobs: - validate-planets-config: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: docker://orrosenblatt/validate-json-action:latest - name: Validate Planets JSON - env: - INPUT_SCHEMA: planets/schema.json - INPUT_JSONS: planets/index.json - diff --git a/.github/workflows/update-planets.yaml b/.github/workflows/update-planets.yaml new file mode 100644 index 00000000..cbce1610 --- /dev/null +++ b/.github/workflows/update-planets.yaml @@ -0,0 +1,28 @@ +name: Update planets config + +on: + pull_request: + paths: + - planets/index.json + branches: + - main + types: + - closed + +jobs: + validate-planets-config: + if: github.event.pull_request.merged == true + uses: ./.github/workflows/validate-planets.yaml + update-planets-config: + needs: [validate-planets-config] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-2 + - run: | + aws s3 cp planets/index.json s3://planets.nine-chronicles.com/planets/index.json + aws cloudfront create-invalidation --distribution-id EP1JH2OWQMIKM --paths "/*" diff --git a/.github/workflows/validate-planets.yaml b/.github/workflows/validate-planets.yaml new file mode 100644 index 00000000..57f245ad --- /dev/null +++ b/.github/workflows/validate-planets.yaml @@ -0,0 +1,17 @@ +name: Validate planets config + +on: + workflow_call: + pull_request: + paths: + - planets/index.json + +jobs: + validate-planets-config: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + - run: deno -A .github/scripts/validate-planets.js planets/index.json diff --git a/planets/index.json b/planets/index.json index 9f82fb83..8f52a1de 100644 --- a/planets/index.json +++ b/planets/index.json @@ -9,13 +9,19 @@ "dp.gql": ["http://odin-dp.9c.gg/graphql"], "9cscan.rest": ["https://api.9cscan.com"], "headless.gql": [ + "https://odin-rpc-1.nine-chronicles.com/graphql", "https://odin-rpc-2.nine-chronicles.com/graphql", + "http://sgp-nc-1.ninodes.com/graphql", + "http://sgp-nc-2.ninodes.com/graphql", "http://ash-nc-1.ninodes.com/graphql", "http://phx-nc-1.ninodes.com/graphql", "http://nld-nc-1.ninodes.com/graphql" ], "headless.grpc": [ + "http://odin-rpc-1.nine-chronicles.com:31238", "http://odin-rpc-2.nine-chronicles.com:31238", + "http://sgp-nc-1.ninodes.com:31238", + "http://sgp-nc-2.ninodes.com:31238", "http://ash-nc-1.ninodes.com:31238", "http://phx-nc-1.ninodes.com:31238", "http://nld-nc-1.ninodes.com:31238" @@ -126,4 +132,4 @@ } } } -] \ No newline at end of file +] diff --git a/planets/schema.json b/planets/schema.json deleted file mode 100644 index 1f254742..00000000 --- a/planets/schema.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - "pattern": "^0x[0-9a-fA-F]{12}$" - }, - "name": { - "type": "string" - }, - "genesisHash": { - "type": "string", - "pattern": "^[0-9a-fA-F]{40,64}$" - }, - "genesisUri": { - "type": "string", - "format": "uri" - }, - "9cscanUrl": { - "type": "string", - "format": "uri" - }, - "rpcEndpoints": { - "type": "object", - "properties": { - "dp.gql": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "9cscan.rest": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "headless.gql": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "headless.grpc": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "market.rest": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "world-boss.rest": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "patrol-reward.gql": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "arena.gql": { - "type": "array", - "items": { "type": "string", "format": "uri" } - } - }, - "additionalProperties": false - }, - "bridges": { - "type": "object", - "patternProperties": { - "^0x[0-9a-fA-F]{12}$": { - "type": "object", - "properties": { - "agent": { - "type": "string", - "pattern": "^0x[0-9a-fA-F]+$" - }, - "avatar": { - "type": "string", - "pattern": "^0x[0-9a-fA-F]+$" - } - }, - "required": ["agent", "avatar"], - "additionalProperties": false - } - }, - "additionalProperties": false - } - }, - "required": [ - "id", - "name", - "genesisHash", - "genesisUri", - "9cscanUrl", - "rpcEndpoints", - "bridges" - ], - "additionalProperties": false - } -}