Don't gzip openrpc files for friendlier git wrangling

the .gz files are impossible to rebase/merge/etc. but the files are needed in
the repo for `go build` because they are embeds; so we just don't gzip them
This commit is contained in:
Rod Vagg 2024-02-15 08:52:26 +11:00
parent cd19c2a08d
commit 5bd7f2ca4d
No known key found for this signature in database
GPG Key ID: C273792F7D83545D
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.