-
-
Notifications
You must be signed in to change notification settings - Fork 140
139 lines (118 loc) · 4.76 KB
/
qa.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
name: QA
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
types: [assigned, opened, synchronize, reopened, edited, ready_for_review]
jobs:
validate:
name: validate
if: ${{ github.event.pull_request.draft == false }}
strategy:
fail-fast: false
matrix:
project: [ api, agent, pkg, ssh, ui, cli ]
include:
- project: api
extra_args: ""
lint_args: ""
- project: agent
extra_args: "-tags docker"
lint_args: "--build-tags docker"
- project: pkg
extra_args: ""
lint_args: ""
- project: ssh
extra_args: "-tags internal_api"
lint_args: "--build-tags internal_api"
- project: ui
extra_args: ""
lint_args: ""
- project: cli
extra_args: ""
lint_args: ""
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
# inline YAML or path to separate file (e.g.: .github/filters.yaml)
filters: |
ui:
- 'ui/**'
go:
- 'api/**'
- 'agent/**'
- 'pkg/**'
- 'ssh/**'
- 'cli/**'
- name: Set up Go 1.x [Go]
if: matrix.project != 'ui' && steps.filter.outputs.go == 'true' && github.event.pull_request.draft == false
uses: actions/setup-go@v4
with:
go-version: "1.20"
id: go
- name: Cache Go files [Go]
uses: actions/cache@v3
if: matrix.project != 'ui' && steps.filter.outputs.go == 'true' && github.event.pull_request.draft == false
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Get Go dependencies [Go]
if: matrix.project != 'ui' && steps.filter.outputs.go == 'true' && github.event.pull_request.draft == false
working-directory: ${{ matrix.project }}
run: go mod download
- name: Ensure Go dependencies are complete [Go]
if: matrix.project != 'ui' && steps.filter.outputs.go == 'true' && github.event.pull_request.draft == false
working-directory: ${{ matrix.project }}
run: |
../devscripts/prepare-release
if [ -n "$(git status --porcelain)" ]; then
echo "Missing dependencies on 'go.mod'"
exit 1
fi
- name: Unit test [Go]
if: matrix.project != 'ui' && steps.filter.outputs.go == 'true' && github.event.pull_request.draft == false
working-directory: ${{ matrix.project }}
run: go test -v ${{ matrix.extra_args }} ./...
- name: Go build [Go]
if: matrix.project != 'ui' && steps.filter.outputs.go == 'true' && github.event.pull_request.draft == false
working-directory: ${{ matrix.project }}
run: go build -v ${{ matrix.extra_args }} ./...
- name: Code format [Go]
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
if: matrix.os == 'ubuntu-latest' && github.event.pull_request.draft == false
- name: Code linting [Go]
if: matrix.project != 'ui' && steps.filter.outputs.go == 'true' && github.event.pull_request.draft == false
uses: golangci/golangci-lint-action@v3
with:
working-directory: ${{ matrix.project }}
version: v1.53.3
args: ${{ matrix.lint_args }} ./...
skip-pkg-cache: true
- name: Set up Node.JS 18.16.0 [UI]
if: matrix.project == 'ui' && steps.filter.outputs.ui == 'true' && github.event.pull_request.draft == false
uses: actions/setup-node@v3
with:
node-version: "18.16.0"
- name: Cache node modules [UI]
if: matrix.project == 'ui' && steps.filter.outputs.ui == 'true' && github.event.pull_request.draft == false
uses: actions/cache@v3
with:
path: ui/node_modules
key: ${{ runner.OS }}-ui-${{ hashFiles('**/package-lock.json') }}
- name: Install Node Dependencies [UI]
if: matrix.project == 'ui' && steps.filter.outputs.ui == 'true' && github.event.pull_request.draft == false
working-directory: ${{ matrix.project }}
run: npm install
- name: Unit test [UI]
if: matrix.project == 'ui' && steps.filter.outputs.ui == 'true' && github.event.pull_request.draft == false
working-directory: ${{ matrix.project }}
run: npm run test
- name: Save Code Linting Report JSON [UI]
if: matrix.project == 'ui' && steps.filter.outputs.ui == 'true' && github.event.pull_request.draft == false
working-directory: ${{ matrix.project }}
run: npm run lint