Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow for validating planets.json #2226

Merged
merged 2 commits into from
Dec 4, 2024
Merged
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
25 changes: 25 additions & 0 deletions .github/scripts/validate-planets.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
28 changes: 28 additions & 0 deletions .github/workflows/update-planets.yaml
Original file line number Diff line number Diff line change
@@ -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 "/*"
17 changes: 17 additions & 0 deletions .github/workflows/validate-planets.yaml
Original file line number Diff line number Diff line change
@@ -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
135 changes: 135 additions & 0 deletions planets/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
[
{
"id": "0x000000000000",
"name": "odin",
"genesisHash": "4582250d0da33b06779a8475d283d5dd210c683b9b999d74d03fac4f58fa6bce",
"genesisUri": "https://release.nine-chronicles.com/genesis-block-9c-main",
"9cscanUrl": "https://9cscan.com",
"rpcEndpoints": {
"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"
],
"market.rest": [
"https://odin-market.9c.gg"
],
"world-boss.rest": [
"https://odin-world-boss.9c.gg"
],
"patrol-reward.gql": [
"https://odin-patrol.9c.gg/graphql"
],
"arena.gql": [
"http://odin-arena.9c.gg/graphql"
]
},
"bridges": {
"0x000000000001": {
"agent": "0x1c2ae97380CFB4F732049e454F6D9A25D4967c6f",
"avatar": "0x41aEFE4cdDFb57C9dFfd490e17e571705c593dDc"
},
"0x000000000003": {
"agent": "0x3e498a6A5cDbE027769F9502026c37Cb8613186e",
"avatar": "0x41E9Dc57F04cC561B68378490528e22a386ba9e1"
}
}
},
{
"id": "0x000000000001",
"name": "heimdall",
"genesisHash": "729fa26958648a35b53e8e3905d11ec53b1b4929bf5f499884aed7df616f5913",
"genesisUri": "https://planets.nine-chronicles.com/planets/0x000000000001/genesis",
"9cscanUrl": "https://heimdall.9cscan.com",
"rpcEndpoints": {
"dp.gql": [
"http://heimdall-dp.9c.gg/graphql"
],
"9cscan.rest": [
"https://api-heimdall.9cscan.com"
],
"headless.gql": [
"https://heimdall-rpc-1.nine-chronicles.com/graphql",
"https://heimdall-rpc-2.nine-chronicles.com/graphql",
"https://heimdall-rpc-3.nine-chronicles.com/graphql"
],
"headless.grpc": [
"http://heimdall-rpc-1.nine-chronicles.com:31238",
"http://heimdall-rpc-2.nine-chronicles.com:31238",
"http://heimdall-rpc-3.nine-chronicles.com:31238"
],
"market.rest": [
"http://heimdall-market.9c.gg"
],
"world-boss.rest": [
"http://heimdall-world-boss.9c.gg"
],
"patrol-reward.gql": [
"https://heimdall-patrol.9c.gg/graphql"
],
"arena.gql": [
"http://heimdall-arena.9c.gg/graphql"
]
},
"bridges": {
"0x000000000000": {
"agent": "0x1c2ae97380CFB4F732049e454F6D9A25D4967c6f",
"avatar": "0x41aEFE4cdDFb57C9dFfd490e17e571705c593dDc"
}
}
},
{
"id": "0x000000000003",
"name": "thor",
"genesisUri": "https://planets.nine-chronicles.com/planets/0x000000000003/genesis",
"genesisHash": "bde462fd59de5ccba8495ebb163b124bf77ddc82cfc8b2f9fb57c00fc6e133b7",
"9cscanUrl": "https://thor.9cscan.com",
"rpcEndpoints": {
"dp.gql": [
"http://thor-dp.9c.gg/graphql"
],
"9cscan.rest": [
"https://api-thor.9cscan.com"
],
"headless.gql": [
"https://thor-rpc-1.nine-chronicles.com/graphql"
],
"headless.grpc": [
"http://thor-rpc-1.nine-chronicles.com:31238"
],
"market.rest": [
"http://thor-market.9c.gg"
],
"world-boss.rest": [
"http://thor-world-boss.9c.gg"
],
"patrol-reward.gql": [
"http://thor-patrol.9c.gg/graphql"
],
"arena.gql": [
"http://thor-arena.9c.gg/graphql"
]
},
"bridges": {
"0x000000000000": {
"agent": "0x3e498a6A5cDbE027769F9502026c37Cb8613186e",
"avatar": "0x41E9Dc57F04cC561B68378490528e22a386ba9e1"
}
}
}
]
Loading