Skip to content

Commit

Permalink
spec updates (#25)
Browse files Browse the repository at this point in the history
* wokring on specup

* update spec

* fix
  • Loading branch information
decentralgabe authored Oct 27, 2023
1 parent f93a1e2 commit 418c703
Show file tree
Hide file tree
Showing 13 changed files with 5,860 additions and 321 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ jobs:
- name: Install Mage
run: go install github.com/magefile/mage

- name: Check if swagger is up to date
if: ${{ github.ref != 'refs/heads/main' }}
run: |
mage -v spec
if (git diff --shortstat | grep '[0-9]'); then \
echo "Swagger spec is out of date. Please run mage spec"; \
exit 1;
fi
- name: Build
run: mage build

Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/render-spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: render-spec
on:
push:
branches:
- main
jobs:
build-and-deploy-spec:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./spec
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Install and Build 🔧
run: |
npm install
npm run build
- name: Deploy
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
allow_empty_commit: true
force_orphan: true
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,8 @@ dist

.DS_STORE
.idea
*.db
*.db

# spec stuff
spec/build
spec/node_modules
2 changes: 1 addition & 1 deletion impl/docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions impl/docs/overrides.swaggo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
replace cryptosuite.LDKeyType string
replace cryptosuite.SignatureType string
4 changes: 2 additions & 2 deletions impl/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ paths:
type: string
summary: GetRecord a PKARR record from the DHT
tags:
- Relay
- PKARR
put:
consumes:
- application/octet-stream
Expand Down Expand Up @@ -84,7 +84,7 @@ paths:
type: string
summary: PutRecord a PKARR record into the DHT
tags:
- Relay
- PKARR
/health:
get:
consumes:
Expand Down
3 changes: 1 addition & 2 deletions impl/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ func Spec() error {
return err
}

// We need to enable dependencies because many of our external API objects have ssi-sdk objects.
return sh.Run(swagCommand, "init", "-g", "cmd/main.go", "--pd", "--parseInternal", "-ot", "go,yaml")
return sh.Run(swagCommand, "init", "-g", "cmd/main.go", "--overridesFile", "docs/overrides.swaggo", "--pd", "--parseInternal", "-ot", "go,yaml")
}

func ColorizeTestOutput(w io.Writer) io.Writer {
Expand Down
8 changes: 3 additions & 5 deletions impl/pkg/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ func (s *Storage) ReadAll(namespace string) (map[string][]byte, error) {
err := s.db.View(func(tx *bolt.Tx) error {
bucket := tx.Bucket([]byte(namespace))
if bucket == nil {
errMsg := fmt.Sprintf("namespace<%s> does not exist", namespace)
logrus.Error(errMsg)
logrus.Warnf("namespace<%s> does not exist", namespace)
return nil
}
cursor := bucket.Cursor()
Expand All @@ -133,9 +132,8 @@ func (s *Storage) ReadAllKeys(namespace string) ([]string, error) {
err := s.db.View(func(tx *bolt.Tx) error {
bucket := tx.Bucket([]byte(namespace))
if bucket == nil {
errMsg := fmt.Sprintf("namespace<%s> does not exist", namespace)
logrus.Error(errMsg)
return errors.New(errMsg)
logrus.Warnf("namespace<%s> does not exist", namespace)
return nil
}
cursor := bucket.Cursor()
for k, _ := cursor.First(); k != nil; k, _ = cursor.Next() {
Expand Down
Loading

0 comments on commit 418c703

Please sign in to comment.