-
Notifications
You must be signed in to change notification settings - Fork 2
106 lines (92 loc) · 3.42 KB
/
backend-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
name: Backend CI
on:
push:
branches:
- '**'
jobs:
backend-build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
# Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
# ~/.cache/go-build
# ~/Library/Caches/go-build
# %LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Check whether golang code was changed
id: go-change
run: |
echo ::set-output name=server::1
echo ::set-output name=backend::1
# git diff @~..@ --quiet server || echo ::set-output name=server::1
# git diff @~..@ --quiet configurator/backend || echo ::set-output name=backend::1
working-directory: ./
- name: Golang code changed status
env:
SERVER_CHANGED: ${{ steps.go-change.outputs.server }}
BACKEND_CHANGED: ${{ steps.go-change.outputs.backend }}
run: echo TMP WORKAROUND - now it always "changed". Server changed - $SERVER_CHANGED Backend changed - $BACKEND_CHANGED
- name: Build Server
if: ${{ success() && (steps.go-change.outputs.server == 1 || steps.go-change.outputs.backend == 1) }}
run: |
go mod download
go build
working-directory: ./server
- name: Build Backend
if: ${{ success() && (steps.go-change.outputs.server == 1 || steps.go-change.outputs.backend == 1) }}
run: |
go get github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.10.1
go generate
go mod download
go build
working-directory: ./configurator/backend
- name: Test Server
if: ${{ success() && (steps.go-change.outputs.server == 1 || steps.go-change.outputs.backend == 1) }}
run: |
go test -parallel=1 -json ./... > test_report.json
working-directory: ./server
- name: Test Report
if: ${{ always() && (steps.go-change.outputs.server == 1 || steps.go-change.outputs.backend == 1) }}
run: |
go install github.com/vakenbolt/go-test-report@latest
cat test_report.json | ~/go/bin/go-test-report
working-directory: ./server
- uses: actions/upload-artifact@v2
if: ${{ always() && (steps.go-change.outputs.server == 1 || steps.go-change.outputs.backend == 1) }}
with:
name: test-report
path: |
./server/test_report.html
- name: Notify to Slack on Errors
uses: rtCamp/action-slack-notify@v2.2.0
if: ${{ failure() && (steps.go-change.outputs.server == 1 || steps.go-change.outputs.backend == 1) && (github.ref_name == 'beta' || github.ref_name == 'master' ) }}
env:
SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON_EMOJI: 👿
SLACK_WEBHOOK: ${{ secrets.SLACK_CI_BACKEND_WEBHOOK }}
SLACK_FOOTER: ""