-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (145 loc) · 4.26 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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 }}