Skip to content

Commit

Permalink
Merge pull request #16 from ex0rcist/iter18
Browse files Browse the repository at this point in the history
Инкременты №16-18
  • Loading branch information
ex0rcist authored Oct 30, 2024
2 parents ba140ed + e389edf commit 08eb4a0
Show file tree
Hide file tree
Showing 82 changed files with 7,041 additions and 117 deletions.
Binary file removed .DS_Store
Binary file not shown.
46 changes: 46 additions & 0 deletions .github/workflows/mertricstest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
run: |
chmod -R +x $GITHUB_WORKSPACE/.tools
mv $GITHUB_WORKSPACE/.tools/metricstest /usr/local/bin/metricstest
mv $GITHUB_WORKSPACE/.tools/shortenertestbeta /usr/local/bin/shortenertestbeta
mv $GITHUB_WORKSPACE/.tools/random /usr/local/bin/random
- name: Setup go deps
Expand Down Expand Up @@ -352,3 +353,48 @@ jobs:
github.head_ref == 'iter14'
run: |
go test -v -race ./...
- name: "Code increment #16"
if: |
github.ref == 'refs/heads/main' ||
github.head_ref == 'iter16' ||
github.head_ref == 'iter17' ||
github.head_ref == 'iter18' ||
github.head_ref == 'iter19' ||
github.head_ref == 'iter20' ||
github.head_ref == 'iter21' ||
github.head_ref == 'iter22' ||
github.head_ref == 'iter23' ||
github.head_ref == 'iter24'
run: |
shortenertestbeta -test.v -test.run=^TestIteration16$ \
-source-path=. \
- name: "Code increment #17"
if: |
github.ref == 'refs/heads/main' ||
github.head_ref == 'iter17' ||
github.head_ref == 'iter18' ||
github.head_ref == 'iter19' ||
github.head_ref == 'iter20' ||
github.head_ref == 'iter21' ||
github.head_ref == 'iter22' ||
github.head_ref == 'iter23' ||
github.head_ref == 'iter24'
run: |
shortenertestbeta -test.v -test.run=^TestIteration17$ \
-source-path=. \
- name: "Code increment #18"
if: |
github.ref == 'refs/heads/main' ||
github.head_ref == 'iter18' ||
github.head_ref == 'iter19' ||
github.head_ref == 'iter20' ||
github.head_ref == 'iter21' ||
github.head_ref == 'iter22' ||
github.head_ref == 'iter23' ||
github.head_ref == 'iter24'
run: |
shortenertestbeta -test.v -test.run=^TestIteration18$ \
-source-path=. \
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ vendor/
# IDEs directories
.idea
.vscode

.DS_Store
52 changes: 52 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
API_DOCS = docs/api

AGENT_VERSION ?= 0.1.0
SERVER_VERSION ?= 0.1.0

BUILD_DATE ?= $(shell date +%F\ %H:%M:%S)
BUILD_COMMIT ?= $(shell git rev-parse --short HEAD)

build: agent server
.PHONY: build

agent: ## build agent
go build \
-ldflags "\
-X 'main.buildVersion=$(AGENT_VERSION)' \
-X 'main.buildDate=$(BUILD_DATE)' \
-X 'main.buildCommit=$(BUILD_COMMIT)' \
" \
-o cmd/$@/$@ \
cmd/$@/*.go
.PHONY: agent

server: ## build server
rm -rf $(API_DOCS)
swag init -g ./internal/httpserver/handlers.go --output $(API_DOCS)

go build \
-ldflags "\
-X 'main.buildVersion=$(SERVER_VERSION)' \
-X 'main.buildDate=$(BUILD_DATE)' \
-X 'main.buildCommit=$(BUILD_COMMIT)' \
" \
-o cmd/$@/$@ \
cmd/$@/*.go
.PHONY: server

clean: ## remove build artifacts
rm -rf cmd/agent/agent cmd/server/server cmd/staticlint/staticlint
.PHONY: clean

unit-tests: ## run unit tests
@go test -v -race ./... -coverprofile=coverage.out.tmp -covermode atomic
@cat coverage.out.tmp | grep -v -E "(_mock|.pb).go" > coverage.out
@go tool cover -html=coverage.out -o coverage.html
@go tool cover -func=coverage.out
.PHONY: unit-tests

godoc: ### show public packages documentation using godoc
@echo "Project documentation is available at:"
@echo "http://127.0.0.1:3000/pkg/github.com/ex0rcist/metflix/pkg/\n"
@godoc -http=:3000 -play
.PHONY: godoc
8 changes: 7 additions & 1 deletion cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import (
"github.com/ex0rcist/metflix/internal/logging"
)

var (
buildVersion = "N/A"
buildDate = "N/A"
buildCommit = "N/A"
)

func main() {
logging.Setup()

logging.LogInfo("starting agent...")
logging.LogInfoF("starting agent v%s [%s, #%s]...", buildVersion, buildDate, buildCommit)

agnt, err := agent.New()
if err != nil {
Expand Down
14 changes: 8 additions & 6 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import (
"github.com/ex0rcist/metflix/internal/server"
)

var (
buildVersion = "N/A"
buildDate = "N/A"
buildCommit = "N/A"
)

func main() {
logging.Setup()

logging.LogInfo("starting server...")
logging.LogInfoF("starting server v%s [%s, #%s]...", buildVersion, buildDate, buildCommit)

srv, err := server.New()
if err != nil {
logging.LogFatal(err)
}

err = srv.Run()
if err != nil {
logging.LogFatal(err)
}
srv.Start()
}
Loading

0 comments on commit 08eb4a0

Please sign in to comment.