Merge pull request #11625 from filecoin-project/rvagg/openrpc-git-friendly

Don't gzip openrpc files for friendlier git wrangling
This commit is contained in:
Andrew Jackson (Ajax) 2024-02-14 17:51:57 -08:00 committed by GitHub
commit 080baf48e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 54517 additions and 37 deletions

View File

@ -392,14 +392,8 @@ jobs:
- attach_workspace:
at: ~/
- run: go install golang.org/x/tools/cmd/goimports
- run: zcat build/openrpc/full.json.gz | jq > ../pre-openrpc-full
- run: zcat build/openrpc/miner.json.gz | jq > ../pre-openrpc-miner
- run: zcat build/openrpc/worker.json.gz | jq > ../pre-openrpc-worker
- run: make docsgen
- run: zcat build/openrpc/full.json.gz | jq > ../post-openrpc-full
- run: zcat build/openrpc/miner.json.gz | jq > ../post-openrpc-miner
- run: zcat build/openrpc/worker.json.gz | jq > ../post-openrpc-worker
- run: diff ../pre-openrpc-full ../post-openrpc-full && diff ../pre-openrpc-miner ../post-openrpc-miner && diff ../pre-openrpc-worker ../post-openrpc-worker && git --no-pager diff && git --no-pager diff --quiet
- run: git --no-pager diff && git --no-pager diff --quiet
lint-all:
description: |

View File

@ -392,14 +392,8 @@ jobs:
- attach_workspace:
at: ~/
- run: go install golang.org/x/tools/cmd/goimports
- run: zcat build/openrpc/full.json.gz | jq > ../pre-openrpc-full
- run: zcat build/openrpc/miner.json.gz | jq > ../pre-openrpc-miner
- run: zcat build/openrpc/worker.json.gz | jq > ../pre-openrpc-worker
- run: make docsgen
- run: zcat build/openrpc/full.json.gz | jq > ../post-openrpc-full
- run: zcat build/openrpc/miner.json.gz | jq > ../post-openrpc-miner
- run: zcat build/openrpc/worker.json.gz | jq > ../post-openrpc-worker
- run: diff ../pre-openrpc-full ../post-openrpc-full && diff ../pre-openrpc-miner ../post-openrpc-miner && diff ../pre-openrpc-worker ../post-openrpc-worker && git --no-pager diff && git --no-pager diff --quiet
- run: git --no-pager diff && git --no-pager diff --quiet
lint-all:
description: |

View File

@ -373,13 +373,13 @@ docsgen-md-provider: docsgen-md-bin
docsgen-openrpc: docsgen-openrpc-full docsgen-openrpc-storage docsgen-openrpc-worker docsgen-openrpc-gateway
docsgen-openrpc-full: docsgen-openrpc-bin
./docgen-openrpc "api/api_full.go" "FullNode" "api" "./api" -gzip > build/openrpc/full.json.gz
./docgen-openrpc "api/api_full.go" "FullNode" "api" "./api" > build/openrpc/full.json
docsgen-openrpc-storage: docsgen-openrpc-bin
./docgen-openrpc "api/api_storage.go" "StorageMiner" "api" "./api" -gzip > build/openrpc/miner.json.gz
./docgen-openrpc "api/api_storage.go" "StorageMiner" "api" "./api" > build/openrpc/miner.json
docsgen-openrpc-worker: docsgen-openrpc-bin
./docgen-openrpc "api/api_worker.go" "Worker" "api" "./api" -gzip > build/openrpc/worker.json.gz
./docgen-openrpc "api/api_worker.go" "Worker" "api" "./api" > build/openrpc/worker.json
docsgen-openrpc-gateway: docsgen-openrpc-bin
./docgen-openrpc "api/api_gateway.go" "Gateway" "api" "./api" -gzip > build/openrpc/gateway.json.gz
./docgen-openrpc "api/api_gateway.go" "Gateway" "api" "./api" > build/openrpc/gateway.json
.PHONY: docsgen docsgen-md-bin docsgen-openrpc-bin

View File

@ -2,7 +2,6 @@ package build
import (
"bytes"
"compress/gzip"
"embed"
"encoding/json"
@ -12,17 +11,9 @@ import (
//go:embed openrpc
var openrpcfs embed.FS
func mustReadGzippedOpenRPCDocument(data []byte) apitypes.OpenRPCDocument {
zr, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
log.Fatal(err)
}
func mustReadOpenRPCDocument(data []byte) apitypes.OpenRPCDocument {
m := apitypes.OpenRPCDocument{}
err = json.NewDecoder(zr).Decode(&m)
if err != nil {
log.Fatal(err)
}
err = zr.Close()
err := json.NewDecoder(bytes.NewBuffer(data)).Decode(&m)
if err != nil {
log.Fatal(err)
}
@ -30,33 +21,33 @@ func mustReadGzippedOpenRPCDocument(data []byte) apitypes.OpenRPCDocument {
}
func OpenRPCDiscoverJSON_Full() apitypes.OpenRPCDocument {
data, err := openrpcfs.ReadFile("openrpc/full.json.gz")
data, err := openrpcfs.ReadFile("openrpc/full.json")
if err != nil {
panic(err)
}
return mustReadGzippedOpenRPCDocument(data)
return mustReadOpenRPCDocument(data)
}
func OpenRPCDiscoverJSON_Miner() apitypes.OpenRPCDocument {
data, err := openrpcfs.ReadFile("openrpc/miner.json.gz")
data, err := openrpcfs.ReadFile("openrpc/miner.json")
if err != nil {
panic(err)
}
return mustReadGzippedOpenRPCDocument(data)
return mustReadOpenRPCDocument(data)
}
func OpenRPCDiscoverJSON_Worker() apitypes.OpenRPCDocument {
data, err := openrpcfs.ReadFile("openrpc/worker.json.gz")
data, err := openrpcfs.ReadFile("openrpc/worker.json")
if err != nil {
panic(err)
}
return mustReadGzippedOpenRPCDocument(data)
return mustReadOpenRPCDocument(data)
}
func OpenRPCDiscoverJSON_Gateway() apitypes.OpenRPCDocument {
data, err := openrpcfs.ReadFile("openrpc/gateway.json.gz")
data, err := openrpcfs.ReadFile("openrpc/gateway.json")
if err != nil {
panic(err)
}
return mustReadGzippedOpenRPCDocument(data)
return mustReadOpenRPCDocument(data)
}

26558
build/openrpc/full.json Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

9909
build/openrpc/gateway.json Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

12498
build/openrpc/miner.json Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

5536
build/openrpc/worker.json Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.