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

feat: Fix resolver for cheqd-node 1.x release on mainnet [DEV-2238] #94

Merged
merged 88 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
e7ed396
Fix problem with deference resource data with old DID format
abdulla-ashurov Jan 31, 2023
ff82a64
Fix problem with get all APIs resources with old DID
abdulla-ashurov Jan 31, 2023
4750b7d
Update unit tests
abdulla-ashurov Jan 31, 2023
9f463d6
Add integration tests for getting resources API with old DID
abdulla-ashurov Jan 31, 2023
a07ae32
Format integration tests files
abdulla-ashurov Jan 31, 2023
94d2034
Remove duplicate import
abdulla-ashurov Feb 2, 2023
268f38b
Add implementation to redirect OLD DID to new DID URL
abdulla-ashurov Feb 2, 2023
964af98
Fix golangci-lint mistake
abdulla-ashurov Feb 2, 2023
083992c
Update unit tests
abdulla-ashurov Feb 2, 2023
ebeddfc
Fix problem with view fragment in URL
abdulla-ashurov Feb 2, 2023
f415bec
Add integration tests for testing old DID with fragment
abdulla-ashurov Feb 2, 2023
a9b3dea
Remove unused functions and variables
abdulla-ashurov Feb 2, 2023
9ae0789
Refactor integration tests
abdulla-ashurov Feb 3, 2023
6d4b356
Fix golangci-lint mistakes
abdulla-ashurov Feb 3, 2023
bbafa35
Remove incorrect file push
abdulla-ashurov Feb 3, 2023
b49f289
Generate OpenAPI swagger
abdulla-ashurov Feb 6, 2023
0d0856a
Rename command 'docker-compose' to 'docker compose'
abdulla-ashurov Feb 7, 2023
f8c7660
Update swagger openAPI
abdulla-ashurov Feb 9, 2023
cbebce9
Update dead link in README.md
abdulla-ashurov Feb 9, 2023
87ac5db
Fix golangci-lint mistakes
abdulla-ashurov Feb 9, 2023
d7967d4
Update openAPI swagger
abdulla-ashurov Feb 9, 2023
87cabd7
Fix golangci-lint mistakes
abdulla-ashurov Feb 9, 2023
622b1af
Fix typo
abdulla-ashurov Feb 11, 2023
ff30f04
Refactor main.go
abdulla-ashurov Feb 11, 2023
4238d7e
Move ResolutionResourceMetadata type
abdulla-ashurov Feb 15, 2023
59a975e
Merge branch 'develop' into update-resolver
abdulla-ashurov Feb 15, 2023
5b433a4
Merge branch 'develop' into update-resolver
ankurdotb Feb 15, 2023
c76f0c4
Merge branch 'develop' into update-resolver
ankurdotb Feb 15, 2023
8949c6a
Replace deprecated goreleaser property
ankurdotb Feb 15, 2023
c4bd50c
Update .goreleaser.yml
ankurdotb Feb 15, 2023
80327a0
revert: labstack/echo/v4 bump
ankurdotb Feb 15, 2023
2fd566d
Roll everything back
ankurdotb Feb 15, 2023
a95be73
Merge branch 'develop' into update-resolver
ankurdotb Feb 15, 2023
107b886
rename to production-latest
ankurdotb Feb 15, 2023
8613c42
Delete production-latest.env
ankurdotb Feb 15, 2023
3111b1e
Delete container.env
ankurdotb Feb 15, 2023
0626193
Move variables to Docker Compose file
ankurdotb Feb 15, 2023
b259533
Set default variables in Dockerfile
ankurdotb Feb 15, 2023
19b09fc
Create docker-compose.yml
ankurdotb Feb 15, 2023
c60b120
Delete docker-compose.env
ankurdotb Feb 16, 2023
e73a3e9
Delete docker-compose.yml
ankurdotb Feb 16, 2023
698395b
Rename Dockerfile
ankurdotb Feb 16, 2023
53c9c3a
Update test.yml
ankurdotb Feb 16, 2023
65b393e
Restore Code of Conduct file
ankurdotb Feb 16, 2023
d71f060
Update README.md
ankurdotb Feb 16, 2023
f9237fd
Fix environment section format
ankurdotb Feb 16, 2023
40490fb
Reset go mod to see if it works
ankurdotb Feb 16, 2023
9f6a0cc
Update field in DIDDoc metadata can be skipped if it's not populated
abdulla-ashurov Feb 16, 2023
695fdf2
Refactor code
abdulla-ashurov Feb 16, 2023
fe529e9
Refactor code
abdulla-ashurov Feb 16, 2023
db483df
Fix problem with version_id in snake case, currently It print in came…
abdulla-ashurov Feb 16, 2023
57ac4a2
/did/metadata: This only outputs the resource metadata. This should b…
abdulla-ashurov Feb 16, 2023
a8ec6bc
Refactor unit test
abdulla-ashurov Feb 17, 2023
5e102b4
Add a new API endpoint for fetching metadata for specific version of …
abdulla-ashurov Feb 17, 2023
a0e231a
Add integration test for testing a new API:
abdulla-ashurov Feb 17, 2023
9973ff9
Generate swagger openAPI
abdulla-ashurov Feb 17, 2023
a79275c
Refactor code
abdulla-ashurov Feb 17, 2023
f360df6
Fix problem with swagger API
abdulla-ashurov Feb 17, 2023
93f8a26
Add a new API comments for swagger OpenAPI
abdulla-ashurov Feb 20, 2023
90f49fa
Generate swagger OpenAPI by last commit changes
abdulla-ashurov Feb 20, 2023
a0bf2d3
Generate swagger OpenAPI
abdulla-ashurov Feb 20, 2023
7258cbd
Update package-lock.json
ankurdotb Feb 22, 2023
2570922
Create Makefile
ankurdotb Feb 22, 2023
92d6bbb
make swagger
ankurdotb Feb 22, 2023
750c71f
swag fmt
ankurdotb Feb 22, 2023
28ca224
Update go.mod
ankurdotb Feb 22, 2023
4ebe11f
swag general info
ankurdotb Feb 22, 2023
fca40a4
delete docs folder
ankurdotb Feb 22, 2023
50e1e69
swag init
ankurdotb Feb 22, 2023
770c783
Update Makefile
ankurdotb Feb 22, 2023
762e7ad
mod tidy
ankurdotb Feb 22, 2023
05e9d58
Update Makefile
ankurdotb Feb 22, 2023
2a32c9b
Update .goreleaser.yml
ankurdotb Feb 22, 2023
f6d0ef0
Add build-binary workflow
ankurdotb Feb 22, 2023
78588b4
Fix Goreleaser archive rlcp warning
ankurdotb Feb 22, 2023
ff7b308
Update build statement in CodeQL
ankurdotb Feb 22, 2023
26cc5f9
Update main.go
ankurdotb Feb 22, 2023
f34f2d3
Update main.go
ankurdotb Feb 22, 2023
b48fabd
Update make swagger
ankurdotb Feb 22, 2023
f194dfa
Update Dockerfile
ankurdotb Feb 22, 2023
356423c
Update root.go
ankurdotb Feb 22, 2023
a644b17
Update .golangci.yaml
ankurdotb Feb 22, 2023
5688c26
Fix gocritic check
ankurdotb Feb 22, 2023
8d15ce4
Update main.go
ankurdotb Feb 22, 2023
74318dc
Disable stylecheck for now
ankurdotb Feb 22, 2023
ed8609c
Fix unlambda check
ankurdotb Feb 22, 2023
1b7d51f
Update build.yml
ankurdotb Feb 22, 2023
814ccd4
Update Makefile
ankurdotb Feb 22, 2023
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
45 changes: 40 additions & 5 deletions .github/linters/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,64 @@
run:
timeout: 5m
timeout: 10m


linters:
enable:
- deadcode
- bodyclose
- depguard
- dogsled
- errcheck
- gosimple
- exportloopref
- goconst
- gocritic
- gofumpt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nestif
- nolintlint
- staticcheck
- structcheck
# - stylecheck # Disable stylecheck until refactor
- typecheck
- unconvert
- unused
- varcheck


linters-settings:
dogsled:
# Checks assignments with too many blank identifiers.
# Default: 2
max-blank-identifiers: 3

gocritic:
# Which checks should be disabled; can't be combined with 'enabled-checks'.
# See https://go-critic.github.io/overview#checks-overview.
# Default: []
disabled-checks:
- regexpMust
- badCall # Remove this after CI workflow PR

gofumpt:
lang-version: "1.18"

misspell:
ignore-words:
- cheqd
- cheq
- ncheq

stylecheck:
# Select the Go version to target.
go: "1.18"
# STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
# Default: ["*"]
checks: ["all"]
# https://staticcheck.io/docs/configuration/options/#dot_import_whitelist
dot-import-whitelist:
- "github.com/cheqd/cheqd-node/x/did/utils"
- "github.com/onsi/gomega"
# https://staticcheck.io/docs/configuration/options/#initialisms
initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"]
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,31 @@ defaults:

jobs:

build-binary:
name: "Build binary"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version-file: ./go.mod
cache: true

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: build --clean --snapshot --single-target

- name: Store artifact
uses: actions/upload-artifact@v3
with:
name: cheqd-noded
path: dist/did-resolver_linux_amd64_v1/did-resolver

build-docker:
name: "Build Docker image"
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ jobs:
queries: security-and-quality

- name: Build
run: |
go build main.go
run: make build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: docker image load --input did-resolver-build.tar

- name: Set up Docker container for test
run: docker-compose -f tests/docker/docker-compose.yml --env-file tests/docker/docker-compose.env up -d --no-build
run: docker compose -f tests/docker-compose-testing.yml up --detach --no-build

- name: Setup Python environment
working-directory: ./tests/pytest
Expand All @@ -54,4 +54,3 @@ jobs:
run: |
set -euo pipefail
pytest -v -rP ./*.py

29 changes: 18 additions & 11 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,40 @@

project_name: did-resolver

env:
- GO111MODULE=on

before:
hooks:
- go mod tidy
- go mod download
- make clean
- make tidy
- make swagger

builds:
-
env:
- CGO_ENABLED=0
main: .
- CGO_ENABLED=1
main: main.go
binary: did-resolver
goos:
- linux
- darwin
goarch:
- amd64
- arm64

flags:
- -mod=readonly
- -trimpath
ldflags:
- -s -w
- -X github.com/cheqd/did-resolver/cmd.version={{ .Version }}
- -X github.com/cheqd/did-resolver/cmd.Commit={{ .Commit }}

archives:
-
replacements:
darwin: Darwin
linux: Linux
amd64: x86_64
- id: release-archives
rlcp: true
format: tar.gz
wrap_in_directory: true
wrap_in_directory: false
name_template: "{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
files:
- LICENSE
Expand Down
157 changes: 157 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#!/usr/bin/make -f


export GO111MODULE = on

BUILD_DIR ?= $(CURDIR)/build

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')

ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif


###############################################################################
### All ###
###############################################################################

all: lint build

###############################################################################
### Build flags ###
###############################################################################

# Process build tags

build_tags :=
empty :=
whitespace := $(empty) $(empty)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

# Process linker flags

ldflags = -X github.com/cheqd/did-resolver/cmd.version=$(VERSION) \
-X github.com/cheqd/did-resolver/cmd.Commit=$(COMMIT)

ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif

ifeq ($(NO_STRIP),false)
ldflags += -w -s
endif

ldflags += $(LD_FLAGS)
ldflags := $(strip $(ldflags))

# Set build flags

BUILD_FLAGS := -tags '$(build_tags)' -ldflags '$(ldflags)'

ifeq ($(NO_STRIP),false)
BUILD_FLAGS += -trimpath
endif

###############################################################################
### Build ###
###############################################################################

build: go.sum go-version
@echo "Building DID Resolver binary..."
@mkdir -p $(BUILD_DIR)
@echo $(BUILD_FLAGS)
@go build -mod=readonly $(BUILD_FLAGS) -o build/did-resolver main.go
.PHONY: build

###############################################################################
### Install ###
###############################################################################

install: go.sum go-version
@echo "Installing DID Resolver binary..."
@go install -mod=readonly $(BUILD_FLAGS)
.PHONY: install

###############################################################################
### Go Version ###
###############################################################################

GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
MIN_GO_MAJOR_VERSION = 1
MIN_GO_MINOR_VERSION = 18
GO_VERSION_ERROR = Golang version $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION) is not supported, \
please update to at least $(MIN_GO_MAJOR_VERSION).$(MIN_GO_MINOR_VERSION)

go-version:
@echo "Verifying go version..."
@if [ $(GO_MAJOR_VERSION) -gt $(MIN_GO_MAJOR_VERSION) ]; then \
exit 0; \
elif [ $(GO_MAJOR_VERSION) -lt $(MIN_GO_MAJOR_VERSION) ]; then \
echo $(GO_VERSION_ERROR); \
exit 1; \
elif [ $(GO_MINOR_VERSION) -lt $(MIN_GO_MINOR_VERSION) ]; then \
echo $(GO_VERSION_ERROR); \
exit 1; \
fi

.PHONY: go-version

###############################################################################
### Go Modules ###
###############################################################################

go.sum: go.mod
@echo "Ensuring app dependencies have not been modified..."
go mod verify
go mod tidy

verify:
@echo "Verifying all go module dependencies..."
@find . -name 'go.mod' -type f -execdir go mod verify \;

tidy:
@echo "Cleaning up all go module dependencies..."
@find . -name 'go.mod' -type f -execdir go mod tidy \;

.PHONY: verify tidy

###############################################################################
### Tests & Simulation ###
###############################################################################

lint:
golangci-lint run --out-format=tab

lint-fix:
golangci-lint run --fix --out-format=tab --issues-exit-code=0
.PHONY: lint lint-fix

format:
find . -name '*.go' -type f -not -path "*.git*" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "*.git*" | xargs misspell -w
find . -name '*.go' -type f -not -path "*.git*" | xargs goimports -w -local github.com/cheqd/bdjuno
.PHONY: format

clean:
rm -rf $(BUILD_DIR)
.PHONY: clean

###############################################################################
### Swagger ###
###############################################################################

swagger:
@echo "Generating Swagger files..."
@go install github.com/swaggo/swag/cmd/swag@latest
@swag fmt
@swag init -g main.go
.PHONY: swagger
Loading