This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (100 loc) · 3.22 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
name: Build Server
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch: {}
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.18'
- name: Install misspell
run: go install github.com/client9/misspell/cmd/misspell@latest
env:
GOPATH: /home/runner/go
- name: Check misspell
run: find . -type f | grep -v webroot/assets | grep -v "models/.*_testdata.*.go" | xargs /home/runner/go/bin/misspell -error
- name: Check if format is correct
run: .ci/check-gofmt
- name: Check that every package has a testfiles
run: .ci/check-testfiles
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: media_server
ports:
- 26257:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.18'
- name: Install swag
run: go install github.com/swaggo/swag/cmd/swag@latest
env:
GOPATH: /home/runner/go
- name: Generate Docs
run: /home/runner/go/bin/swag init --parseDependency --parseDepth 2 --parseInternal -g web/docs.go -o web/docs
- name: Test
run: go test -ldflags "-X dev.sum7.eu/genofire/golang-lib/web/webtest.DBConnection=postgres://root:root@localhost:26257/media_server?sslmode=disable" $(go list ./... | grep -v /vendor/) -v -failfast -p 1 -coverprofile .testCoverage.txt
- name: Show Coverage
run: go tool cover -func=".testCoverage.txt"
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: '1.18'
- name: Install swag
run: go install github.com/swaggo/swag/cmd/swag@latest
env:
GOPATH: /home/runner/go
- name: Generate Docs
run: /home/runner/go/bin/swag init --parseDependency --parseDepth 2 --parseInternal -g web/docs.go -o web/docs
- name: Build
run: go build -ldflags "-X main.VERSION=$(git describe --tags)" -v
env:
CGO_ENABLED: 0
- name: Archive build artifacts
uses: actions/upload-artifact@v2
with:
name: build
path: media-server
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs:
- lint
- test
- build
steps:
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: build
path: build/
- name: Upload to Server
uses: up9cloud/action-rsync@master
env:
USER: ${{secrets.DEPLOY_SSH_USER}}
HOST: ${{secrets.DEPLOY_SSH_HOST}}
KEY: ${{secrets.DEPLOY_SSH_KEY}}
ARGS: -rzh -O --delete-after
SSH_ARGS: '-p ${{secrets.DEPLOY_SSH_PORT}} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
SOURCE: build/media-server
TARGET: /