Skip to content

Merge pull request #54 from go-park-mail-ru/RK4 #17

Merge pull request #54 from go-park-mail-ru/RK4

Merge pull request #54 from go-park-mail-ru/RK4 #17

Workflow file for this run

name: CI workflow
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.23.x"
- name: Install Linter
run: go install github.com/mgechev/revive@latest
- name: Lint files
run: make lint
test:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.23.x"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libvips-dev
sudo apt-get install -y wkhtmltopdf
- name: Run tests
run: |
go test -v ./... -coverprofile=coverage.out.tmp
cat coverage.out.tmp | grep -v -E 'docs|mock|pb.go|_easyjson.go' > coverage.out
go tool cover -func=coverage.out -o coverage.out
- name: Go Coverage Badge
uses: tj-actions/coverage-badge-go@v2
with:
filename: coverage.out
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v16
id: verify-changed-files
with:
files: README.md
- name: Commit changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "chore: updated coverage badge."
- name: Push changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ github.token }}
branch: ${{ github.head_ref }}
build-main-service:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Build main-service
run: docker build . -f ./build/services/app/Dockerfile
build-auth-service:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Build auth-service
run: docker build . -f ./build/services/auth/Dockerfile
build-compress-service:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Build compress-service
run: docker build . -f ./build/services/compress_microservice/Dockerfile
build-notifications-service:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Build notifications-service
run: docker build . -f ./build/services/notifications/Dockerfile
build-db:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Build db
run: docker build . -f ./build/db/Dockerfile
generate-api:
runs-on: ubuntu-latest
needs:
[
build-main-service,
build-auth-service,
build-compress-service,
build-notifications-service,
build-db,
]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.23.x"
- name: Install dependencies
run: |
go install github.com/swaggo/swag/cmd/swag@latest
go get ./...
- name: Generate API specification
run: |
swag init -g main.go -d ./cmd/app/ -o ./api --pd
- name: Check if API updated
uses: tj-actions/verify-changed-files@v20
id: verify-changed-files
with:
files: |
api
- name: Commit API
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add ./api
git commit -m "chore: update api"
- name: Push API
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ github.token }}
branch: ${{ github.head_ref }}