Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
108 changes: 37 additions & 71 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI Pipeline

on:
push:
branches: [ "cd" ]
branches: [ "main" ]
pull_request:
branches: [ main, master ]

Expand All @@ -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
6 changes: 6 additions & 0 deletions gin-api/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading