forked from anilcse/CosmoScope
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from vitwit/main
Add support for auto-fetching api endpoints from cosmos-registry
- Loading branch information
Showing
16 changed files
with
1,056 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.go] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
[*.{yml,yaml,json}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# .github/workflows/go.yml | ||
name: Go | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write # needed for coverage comment | ||
|
||
jobs: | ||
test: | ||
name: Test and Coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # needed for git history | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
cache: true | ||
|
||
- name: Install golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: latest | ||
args: --timeout=5m | ||
|
||
- name: Verify dependencies | ||
run: go mod verify | ||
|
||
- name: Format check | ||
run: | | ||
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then | ||
echo "The following files are not formatted correctly:" | ||
gofmt -s -l . | ||
exit 1 | ||
fi | ||
- name: Run go vet | ||
run: go vet ./... | ||
|
||
- name: Run tests with coverage | ||
run: | | ||
go test -race -coverprofile=coverage.txt -covermode=atomic -v ./... | ||
go tool cover -func=coverage.txt | ||
# - name: Upload coverage to Codecov | ||
# uses: codecov/codecov-action@v3 | ||
# with: | ||
# files: ./coverage.txt | ||
# fail_ci_if_error: true | ||
# verbose: true | ||
|
||
- name: Generate coverage report | ||
run: | | ||
go tool cover -html=coverage.txt -o coverage.html | ||
- name: Save coverage report | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-report | ||
path: coverage.html | ||
|
||
# - name: Comment coverage on PR | ||
# uses: codecov/codecov-action@v3 | ||
# with: | ||
# files: ./coverage.txt | ||
# fail_ci_if_error: true | ||
# verbose: true | ||
# token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
cache: true | ||
|
||
- name: Build | ||
run: | | ||
GOOS=linux GOARCH=amd64 go build -o bin/cosmoscope-linux-amd64 ./cmd/cosmoscope | ||
GOOS=darwin GOARCH=amd64 go build -o bin/cosmoscope-darwin-amd64 ./cmd/cosmoscope | ||
GOOS=windows GOARCH=amd64 go build -o bin/cosmoscope-windows-amd64.exe ./cmd/cosmoscope | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: binaries | ||
path: bin/ | ||
|
||
release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: startsWith(github.ref, 'refs/tags/') | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: binaries | ||
path: bin | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
bin/cosmoscope-linux-amd64 | ||
bin/cosmoscope-darwin-amd64 | ||
bin/cosmoscope-windows-amd64.exe | ||
draft: false | ||
prerelease: false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
configs/config.json | ||
configs/config.json | ||
cosmoscope | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
bin/ | ||
dist/ | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
coverage.html | ||
|
||
# Dependency directories | ||
vendor/ | ||
|
||
# IDE specific files | ||
.idea/ | ||
.vscode/ | ||
*.swp | ||
*.swo | ||
|
||
# OS generated files | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
linters: | ||
enable: | ||
- gofmt | ||
- revive # Modern replacement for golint | ||
- govet | ||
- errcheck | ||
- staticcheck | ||
- gosimple | ||
- ineffassign | ||
- unused | ||
- misspell | ||
- gocyclo | ||
# - gocritic | ||
- bodyclose # Checks whether HTTP response bodies are closed | ||
- gosec # Security checker | ||
|
||
issues: | ||
exclude-dirs: | ||
- vendor/ # Replaces skip-dirs | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- errcheck | ||
- path: _test\.go | ||
text: "field is never used" | ||
linters: | ||
- unused | ||
|
||
linters-settings: | ||
revive: | ||
rules: | ||
- name: exported | ||
arguments: | ||
- "checkPrivateReceivers" | ||
- "disableStutteringCheck" | ||
gofmt: | ||
simplify: true | ||
misspell: | ||
locale: US | ||
gocyclo: | ||
min-complexity: 15 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- performance | ||
- style | ||
gosec: | ||
excludes: | ||
- G404 # Insecure random number source (math/rand) | ||
|
||
run: | ||
timeout: 5m | ||
tests: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.PHONY: all build test clean lint coverage dev-deps | ||
|
||
# Variables | ||
BINARY_NAME=cosmoscope | ||
MAIN_PACKAGE=./cmd/cosmoscope | ||
GO_FILES=$(shell find . -type f -name '*.go') | ||
VERSION=$(shell git describe --tags --always --dirty) | ||
LDFLAGS=-ldflags "-X main.version=${VERSION}" | ||
GOLANGCI_LINT_VERSION=v1.55.2 | ||
|
||
all: lint test build | ||
|
||
build: | ||
go build ${LDFLAGS} -o bin/${BINARY_NAME} ${MAIN_PACKAGE} | ||
|
||
test: | ||
go test -v -race -coverprofile=coverage.out ./... | ||
|
||
clean: | ||
go clean | ||
rm -f bin/${BINARY_NAME} | ||
rm -f coverage.out | ||
|
||
lint: | ||
@if ! which golangci-lint >/dev/null; then \ | ||
echo "Installing golangci-lint..." && \ | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}; \ | ||
fi | ||
golangci-lint run | ||
|
||
coverage: test | ||
go tool cover -html=coverage.out | ||
|
||
# Install development dependencies | ||
dev-deps: | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} | ||
|
||
# Run the application | ||
run: build | ||
./bin/${BINARY_NAME} | ||
|
||
# Update dependencies | ||
deps-update: | ||
go mod tidy | ||
go mod verify | ||
|
||
# Check tools versions | ||
check-tools: | ||
@echo "Checking tools versions..." | ||
@go version | ||
@golangci-lint --version |
Oops, something went wrong.