-
Notifications
You must be signed in to change notification settings - Fork 25
138 lines (124 loc) · 3.92 KB
/
build.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
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- "*"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
needs: static
steps:
- name: Checkout
uses: actions/checkout@v3
# Node part
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
cache: 'npm'
cache-dependency-path: pkg/frontend/package-lock.json
- name: NPM install
run: npm i
working-directory: ./pkg/frontend
- name: NPM build
run: npm run build
working-directory: ./pkg/frontend
# Golang part
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: Unit tests
run: |
go test -v -race ./... -covermode=atomic -coverprofile=coverage.out # Run all the tests with the race detector enabled
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- name: Dry Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --snapshot --clean
- name: Test Binary is Runnable
run: "dist/komoplane_linux_amd64_v1/komoplane --help"
- uses: actions/upload-artifact@v3
with:
name: binaries
path: dist/
retention-days: 1
image:
runs-on: ubuntu-latest
needs: static
timeout-minutes: 60
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Docker meta
uses: docker/metadata-action@v4
id: meta
with:
images: komodorio/komoplane
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
- name: Build and push
uses: docker/build-push-action@v4
# if: github.event_name != 'pull_request'
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: komodorio/komoplane:unstable
labels: ${{ steps.meta.outputs.labels }}
build-args: VER=0.0.0-dev
platforms: linux/amd64,linux/arm64
static:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Helm Template Check For Sanity
uses: igabaydulin/helm-check-action@0.2.0
env:
CHART_LOCATION: ./charts/komoplane
CHART_VALUES: ./charts/komoplane/values.yaml
- name: make dir for frontend results # don't delete this step, it will break goreleaser
run: mkdir pkg/frontend/dist && touch pkg/frontend/dist/.gitkeep
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# skip-pkg-cache: true
version: latest
args: --timeout=3m
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: Static analysis
run: |
go vet ./... # go vet is the official Go static analyzer
- name: Cyclomatic complexity
run: |
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
/home/runner/go/bin/gocyclo -over 19 main.go pkg # forbid code with huge/complex functions
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
cache: 'npm'
cache-dependency-path: pkg/frontend/package-lock.json
- name: NPM install
run: npm i
working-directory: ./pkg/frontend
- name: NPM lint
run: npm run lint
working-directory: ./pkg/frontend