18 Commits

Author SHA1 Message Date
c47de4cd63 ci: Fix CI
Some checks failed
Lint Golang / lint (push) Failing after 2m39s
Release / Sematic Release (push) Successful in 12s
Release / Goreleaser (push) Successful in 6m51s
2025-10-29 17:42:11 +00:00
19fc8d1185 ci: Update release 2025-10-29 20:22:46 +03:00
5fff23f01b ci: Update release 2025-10-29 19:45:14 +03:00
9b319d6adc ci: Update release 2025-10-29 19:38:50 +03:00
0a8f82f0d6 ci: Update release 2025-10-29 19:36:49 +03:00
semantic-release-bot
9607f99932 chore(release): 1.2.0 [skip ci]
## [1.2.0](https://git.ostiwe.com/ostiwe-com/status/compare/v1.1.1...v1.2.0) (2025-10-29)

### Features

* Added ID field to PublicService DTO, update fields in Service model, fix CalculateUptimePercent method, transform services to Public services in goroutines ([a4050c2](a4050c28dc))
* **ci:** Update release config ([1367783](1367783e8a))
* **ci:** Update release config ([dc5c363](dc5c363583))
* **ci:** Update release config ([64121d5](64121d56c7))

### Bug Fixes

* Fix errors ([7e96536](7e9653606e))
* Recreate closeNotify channel on recreate rabbit connection ([f5d780f](f5d780fb1b))

### CI/CD Changes

* Added golangci linter ([e7592e8](e7592e8737))
* Change CI ([334c0c1](334c0c1480))
* Install go-releaser in CI ([abc87ab](abc87abe88))

### Refactoring

* Added node_modules to ignore for git ([c7d94c6](c7d94c6965))
* Remove unused code ([1958d9b](1958d9b3d9))
* Switching to a cron system for tasks, restructuring service and status models ([b33df27](b33df27b31))
* Update startup server ([628abc4](628abc4d11))
2025-10-29 19:29:27 +03:00
f66c40ef36 Update release.config.cjs 2025-10-29 12:25:14 +00:00
7ce1731a6f Update .github/workflows/release.yml 2025-10-29 12:23:44 +00:00
c72ef8350b Merge pull request 'Merge develop to master' (!5) from dev into main
Reviewed-on: #5
2025-10-29 12:23:13 +00:00
7e9653606e fix: Fix errors 2025-10-28 19:26:18 +03:00
e7592e8737 ci: Added golangci linter 2025-10-28 19:25:53 +03:00
334c0c1480 ci: Change CI 2025-10-28 18:02:40 +03:00
abc87abe88 ci: Install go-releaser in CI 2025-10-28 17:23:56 +03:00
1367783e8a feat(ci): Update release config 2025-10-28 17:17:57 +03:00
semantic-release-bot
51e48dd842 chore(release): 1.2.0 [skip ci]
# [1.2.0](https://git.ostiwe.com/ostiwe-com/status/compare/v1.1.1...v1.2.0) (2025-10-28)

### Bug Fixes

* Recreate closeNotify channel on recreate rabbit connection ([f5d780f](f5d780fb1b))

### Features

* Added ID field to PublicService DTO, update fields in Service model, fix CalculateUptimePercent method, transform services to Public services in goroutines ([a4050c2](a4050c28dc))
* **ci:** Update release config ([dc5c363](dc5c363583))
* **ci:** Update release config ([64121d5](64121d56c7))
2025-10-28 09:01:54 +00:00
3a3580b6ed Merge branch 'change_models' into dev 2025-10-28 01:27:32 +03:00
f5d780fb1b fix: Recreate closeNotify channel on recreate rabbit connection 2025-08-21 13:04:19 +03:00
a4050c28dc feat: Added ID field to PublicService DTO, update fields in Service model, fix CalculateUptimePercent method, transform services to Public services in goroutines 2025-08-20 15:25:20 +03:00
9 changed files with 212 additions and 24 deletions

26
.github/workflows/golang-lint.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Lint Golang
on:
push:
branches:
- main
- dev
pull_request:
permissions:
contents: read
pull-requests: read
jobs:
golangci:
name: lint
runs-on: self-hosted
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: 1.25.0
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.5.0
args: '--config=${{ github.workspace }}/.golangci.yml'

View File

@@ -3,14 +3,33 @@ name: Release
on: on:
push: push:
branches: branches:
- dev
- master - master
- main
permissions: permissions:
contents: write contents: write
jobs: jobs:
semantic-release:
name: Sematic Release
runs-on: self-hosted
outputs:
releaseContentLink: ${{ steps.release.outputs.releaseContentLink }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Release
id: release
run: |
export TMP_FILE_NAME=$(openssl rand -hex 36)
yarn install
yarn semantic-release
echo "releaseContentLink=$(cat /tmp/$TMP_FILE_NAME | curl -F '_=<-' https://past.ostiwe.com)" >> "$GITHUB_OUTPUT"
goreleaser: goreleaser:
needs: semantic-release
name: Goreleaser
runs-on: self-hosted runs-on: self-hosted
steps: steps:
- name: Checkout - name: Checkout
@@ -21,13 +40,17 @@ jobs:
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: '^1.25' go-version: '^1.25'
- name: Set up Node - name: Install go release
uses: actions/setup-node@v6 run: go install github.com/goreleaser/goreleaser/v2@latest
with: - name: Get release notes
node-version: 22.18 id: get-notes
- name: Release
run: | run: |
yarn install export FILE_NAME=$(openssl rand -hex 36)
yarn semantic-release echo "name=$FILE_NAME" >> "$GITHUB_OUTPUT"
curl -L ${{ needs.semantic-release.outputs.releaseContentLink }} >> "/tmp/$FILE_NAME"
- name: Run Goreleaser
env: env:
GITEA_TOKEN: ${{ secrets.GORELEASER_TOKEN }} GITEA_TOKEN: ${{ secrets.GORELEASER_TOKEN }}
run: |
goreleaser release --release-notes /tmp/${{ steps.get-notes.outputs.name }} --clean
rm /tmp/${{ steps.get-notes.outputs.name }}

27
.golangci.yml Normal file
View File

@@ -0,0 +1,27 @@
version: "2"
run:
relative-path-mode: gomod
timeout: 5m
linters:
settings:
dupl:
threshold: 100
enable:
- errcheck
- govet
- ineffassign
- staticcheck
- unused
- errname
- dupl
- decorder
- cyclop
- funlen
- lll
- nestif
- nlreturn
- prealloc
- tagalign
- whitespace

41
CHANGELOG.md Normal file
View File

@@ -0,0 +1,41 @@
## [1.2.0](https://git.ostiwe.com/ostiwe-com/status/compare/v1.1.1...v1.2.0) (2025-10-29)
### Features
* Added ID field to PublicService DTO, update fields in Service model, fix CalculateUptimePercent method, transform services to Public services in goroutines ([a4050c2](https://git.ostiwe.com/ostiwe-com/status/commit/a4050c28dc9cfb2edcc3716b91af4a8ba146637b))
* **ci:** Update release config ([1367783](https://git.ostiwe.com/ostiwe-com/status/commit/1367783e8acb2e4e1503489794c52460133c815b))
* **ci:** Update release config ([dc5c363](https://git.ostiwe.com/ostiwe-com/status/commit/dc5c3635831dffd5e0e9da25e8e69b9ebf29663c))
* **ci:** Update release config ([64121d5](https://git.ostiwe.com/ostiwe-com/status/commit/64121d56c7def468b880a30cd0c1f86a25fd3398))
### Bug Fixes
* Fix errors ([7e96536](https://git.ostiwe.com/ostiwe-com/status/commit/7e9653606e5b0c14294481abde4be9121fc3afd2))
* Recreate closeNotify channel on recreate rabbit connection ([f5d780f](https://git.ostiwe.com/ostiwe-com/status/commit/f5d780fb1b682aa1f6f29b9297ed1e3e22ad15e1))
### CI/CD Changes
* Added golangci linter ([e7592e8](https://git.ostiwe.com/ostiwe-com/status/commit/e7592e87378f273d33ce170484d956607a663cd5))
* Change CI ([334c0c1](https://git.ostiwe.com/ostiwe-com/status/commit/334c0c1480afc22b1deac93b613f407ff0f3de26))
* Install go-releaser in CI ([abc87ab](https://git.ostiwe.com/ostiwe-com/status/commit/abc87abe8859efdcbf226c8aefe3e5ef94c64b0a))
### Refactoring
* Added node_modules to ignore for git ([c7d94c6](https://git.ostiwe.com/ostiwe-com/status/commit/c7d94c6965333d638436b0dca8a2a58767f1497e))
* Remove unused code ([1958d9b](https://git.ostiwe.com/ostiwe-com/status/commit/1958d9b3d94fe32d7c4fcefb66acb0cd475d98ec))
* Switching to a cron system for tasks, restructuring service and status models ([b33df27](https://git.ostiwe.com/ostiwe-com/status/commit/b33df27b31587ba935c1a3d2abc04b7b98bed531))
* Update startup server ([628abc4](https://git.ostiwe.com/ostiwe-com/status/commit/628abc4d11849d751bbf21fd79ea637f09a66521))
# [1.2.0](https://git.ostiwe.com/ostiwe-com/status/compare/v1.1.1...v1.2.0) (2025-10-28)
### Bug Fixes
* Recreate closeNotify channel on recreate rabbit connection ([f5d780f](https://git.ostiwe.com/ostiwe-com/status/commit/f5d780fb1b682aa1f6f29b9297ed1e3e22ad15e1))
### Features
* Added ID field to PublicService DTO, update fields in Service model, fix CalculateUptimePercent method, transform services to Public services in goroutines ([a4050c2](https://git.ostiwe.com/ostiwe-com/status/commit/a4050c28dc9cfb2edcc3716b91af4a8ba146637b))
* **ci:** Update release config ([dc5c363](https://git.ostiwe.com/ostiwe-com/status/commit/dc5c3635831dffd5e0e9da25e8e69b9ebf29663c))
* **ci:** Update release config ([64121d5](https://git.ostiwe.com/ostiwe-com/status/commit/64121d56c7def468b880a30cd0c1f86a25fd3398))

View File

@@ -3,8 +3,9 @@ package dto
import "git.ostiwe.com/ostiwe-com/status/model" import "git.ostiwe.com/ostiwe-com/status/model"
type PublicService struct { type PublicService struct {
ID int `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` Description *string `json:"description"`
Statuses []model.Status `json:"statuses"` Statuses []model.Status `json:"statuses"`
Uptime float64 `json:"uptime"` Uptime float64 `json:"uptime"`
} }

View File

@@ -12,6 +12,7 @@ const (
StatusOK StatusCode = "ok" // Means - response ok, service is alive StatusOK StatusCode = "ok" // Means - response ok, service is alive
StatusFailed StatusCode = "failed" // Means - response failed, all tries failed, service down StatusFailed StatusCode = "failed" // Means - response failed, all tries failed, service down
StatusWarn StatusCode = "warn" // Means - response failed after N tries and still watched StatusWarn StatusCode = "warn" // Means - response failed after N tries and still watched
StatusUncheck StatusCode = "uncheck"
) )
type Status struct { type Status struct {

View File

@@ -87,6 +87,7 @@ func (c *Connection) listenCloseNotify() {
} }
c.conn = dial c.conn = dial
c.closeNotify = dial.NotifyClose(make(chan *amqp.Error))
c.logger.Info("Rabbit connection stabilized") c.logger.Info("Rabbit connection stabilized")

View File

@@ -2,14 +2,16 @@
* @type {import('semantic-release').GlobalConfig} * @type {import('semantic-release').GlobalConfig}
*/ */
module.exports = { module.exports = {
branches: ['master', { name: 'dev', prerelease: false, channel: 'dev'}], branches: ['main'],
plugins: [ plugins: [
[ [
'@semantic-release/commit-analyzer', '@semantic-release/commit-analyzer',
{ {
"preset": "angular", "preset": "conventionalcommits",
"releaseRules": [ "releaseRules": [
{"type": "docs", "scope": "README", "release": "patch"}, {"type": "docs", "scope": "README", "release": "patch"},
{"type": "feat", scope: "ci", release: "patch"},
{"type": "feature", scope: "ci", release: "patch"},
{"type": "refactor", "release": "patch"}, {"type": "refactor", "release": "patch"},
{"type": "style", "release": "patch"} {"type": "style", "release": "patch"}
], ],
@@ -18,16 +20,40 @@ module.exports = {
[ [
'@semantic-release/release-notes-generator', '@semantic-release/release-notes-generator',
{ {
"preset": "angular", "preset": "conventionalcommits",
"presetConfig": {
types: [
{"type": "breaking", "section": "Major version release", "hidden": false},
{"type": "BREAKING", "section": "Major version release", "hidden": false},
{"type": "BREAKING CHANGE", "section": "Major version release", "hidden": false},
{"type": "BREAKING CHANGES", "section": "Major version release", "hidden": false},
{"type": "feat", "section": "Features", "hidden": false},
{"type": "fix", "section": "Bug Fixes", "hidden": false},
{"type": "hotfix", "section": "Bug Fixes", "hidden": false},
{"type": "update", "section": "Updates", "hidden": false},
{"type": "upgrade", "section": "Upgrades", "hidden": false},
{"type": "docs", "section": "Documentation", "hidden": false},
{"type": "build", "section": "CI/CD Changes", "hidden": false},
{"type": "ci", "section": "CI/CD Changes", "hidden": false},
{"type": "refactor", "section": "Refactoring", "hidden": false},
{"type": "perf", "section": "Performance Improvements", "hidden": false}
]
}
} }
], ],
'@semantic-release/changelog',
'@semantic-release/git',
[ [
"@semantic-release/exec", "@semantic-release/exec",
{ {
"publishCmd": 'echo "${nextRelease.notes}" > /tmp/release-notes.md; goreleaser release --release-notes /tmp/release-notes.md --clean' publishCmd: 'echo "${nextRelease.notes}\n\n$(cat CHANGELOG.md)" > CHANGELOG.md; echo "${nextRelease.notes}" > "/tmp/${process.env.TMP_FILE_NAME}";',
} }
],
[
'@semantic-release/git',
{
assets: [
'CHANGELOG.md'
] ]
}
],
], ],
}; };

View File

@@ -1,25 +1,67 @@
package transform package transform
import ( import (
"slices"
"sync"
"git.ostiwe.com/ostiwe-com/status/dto" "git.ostiwe.com/ostiwe-com/status/dto"
"git.ostiwe.com/ostiwe-com/status/model" "git.ostiwe.com/ostiwe-com/status/model"
"github.com/samber/lo"
) )
const maxStatuses = 60
func PublicServices(items ...model.Service) []dto.PublicService { func PublicServices(items ...model.Service) []dto.PublicService {
result := make([]dto.PublicService, 0, len(items)) result := make([]dto.PublicService, 0, len(items))
mu := new(sync.Mutex)
chunked := slices.Chunk(items, 40)
for services := range chunked {
wg := new(sync.WaitGroup)
wg.Add(len(services))
for i := range services {
go func(_wg *sync.WaitGroup, item model.Service) {
defer _wg.Done()
transformed := PublicService(item)
mu.Lock()
result = append(result, transformed)
mu.Unlock()
}(wg, services[i])
}
wg.Wait()
for _, item := range items {
result = append(result, PublicService(item))
} }
return result return result
} }
func PublicService(item model.Service) dto.PublicService { func PublicService(item model.Service) dto.PublicService {
statuses := make([]model.Status, maxStatuses)
itemStatusLen := len(item.Statuses)
for i := range statuses {
if i > itemStatusLen-1 {
break
}
statuses[i] = item.Statuses[i]
}
for i := range statuses {
if statuses[i].Status == "" {
statuses[i].Status = model.StatusUncheck
}
}
slices.Reverse(statuses)
return dto.PublicService{ return dto.PublicService{
ID: int(item.ID),
Name: item.Name, Name: item.Name,
Description: item.PublicDescription, Description: lo.ToPtr(item.PublicDescription),
Statuses: item.Statuses, Statuses: statuses,
Uptime: item.CalculateUptimePercent(), Uptime: item.CalculateUptimePercent(),
} }
} }