From 4de69c7d4d74726b52012b88ae2a1d857708310f Mon Sep 17 00:00:00 2001 From: mark47B Date: Fri, 3 Oct 2025 04:05:36 +0300 Subject: [PATCH 1/2] feat: rewrite ci without push to registry --- .github/workflows/ci.yml | 108 ++++++++++++++------------------------- 1 file changed, 37 insertions(+), 71 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbd102e..04fec2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI Pipeline on: push: - branches: [ "cd" ] + branches: [ "main" ] pull_request: branches: [ main, master ] @@ -12,80 +12,46 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.21' - cache: true - - - name: Install dependencies - run: | - cd gin-api - go mod download - - - name: Run tests - run: | - cd gin-api - go test ./... - - - name: Run test coverage - run: | - cd gin-api - go test -cover ./... + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.24.1' + cache: true + + - name: Install dependencies + run: | + cd gin-api + go mod download + + - name: Run tests + run: | + cd gin-api + go test -v ./... + + - name: Run test coverage + run: | + cd gin-api + go test -cover ./... build: - name: Build and Push Docker Images + name: Build Docker Images for Check runs-on: ubuntu-latest needs: test - permissions: - contents: read - packages: write steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to GitHub Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract backend metadata - id: meta-backend - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository_owner }}/backend - tags: | - type=ref,event=branch - type=ref,event=pr - type=sha,format=short - - - name: Build and push backend image - uses: docker/build-push-action@v4 - with: - context: ./gin-api - file: ./gin-api/Dockerfile - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta-backend.outputs.tags }} - labels: ${{ steps.meta-backend.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Build seeder image - uses: docker/build-push-action@v4 - with: - context: ./gin-api - file: ./gin-api/Dockerfile.seeder - push: false - tags: sviper-seeder:latest - cache-from: type=gha - cache-to: type=gha,mode=max + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build backend image + run: | + docker build -t sviper-backend:test -f gin-api/Dockerfile gin-api + + - name: Build seeder image + run: | + docker build -t sviper-seeder:test -f gin-api/Dockerfile.seeder gin-api From ce814097faee13c1e68a57b0a4c2fa188272c7a7 Mon Sep 17 00:00:00 2001 From: mark47B Date: Wed, 22 Oct 2025 13:06:07 +0300 Subject: [PATCH 2/2] feat: health check --- gin-api/cmd/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gin-api/cmd/main.go b/gin-api/cmd/main.go index 0899164..9c08085 100644 --- a/gin-api/cmd/main.go +++ b/gin-api/cmd/main.go @@ -45,6 +45,12 @@ func main() { // Настройка Gin r := gin.Default() + r.GET("/healthz", func(c *gin.Context) { + c.JSON(200, gin.H{ + "status": "ok", + }) + }) + // Маршруты для треков r.POST("/tracks", trackHandler.CreateTrack) r.GET("/tracks", trackHandler.GetAllTracks)