-
Notifications
You must be signed in to change notification settings - Fork 1
132 lines (113 loc) · 3.46 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
name: build
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
jobs:
check-generate:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v4.1.7
- name: Install Protobuf
run: sudo snap install protobuf --classic
- name: Generate source files
run: go generate ./pkg/...
- name: Check if source files are up to date
run: git diff --exit-code HEAD
- name: Upload this project as an artifact
uses: actions/upload-artifact@v3.1.3
with:
if-no-files-found: error
name: project
path: |
.git/
cmd/**/*.go
pkg/**/*.go
go.mod
go.sum
check-build:
needs: check-generate
runs-on: ubuntu-latest
steps:
- name: Download the project artifact
uses: actions/download-artifact@v4.1.8
with:
name: project
- name: Build targets
run: go build ./cmd/...
check-install:
needs: check-build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cmd: [bro, bro-backend]
steps:
- name: Install command
run: go install github.com/threeal/bro/cmd/${{ matrix.cmd }}@latest
- name: Run command
run: ~/go/bin/${{ matrix.cmd }} --help
unit-tests:
needs: check-generate
runs-on: ubuntu-latest
steps:
- name: Download the project artifact
uses: actions/download-artifact@v4.1.8
with:
name: project
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Run tests
continue-on-error: ${{ github.event_name != 'pull_request' }}
run: ~/go/bin/gotestsum --junitfile test.xml -- -covermode atomic -coverprofile=profile.cov ./pkg/...
- name: Check test coverage
if: github.event_name == 'pull_request'
uses: vladopajic/go-test-coverage@v2.10.1
with:
profile: profile.cov
local-prefix: github.com/threeal/bro
threshold-file: 100
threshold-package: 100
threshold-total: 100
- name: Upload this test project as an artifact
uses: actions/upload-artifact@v3.1.3
with:
if-no-files-found: error
name: test-project
path: |
.git/
pkg/**/*.go
go.mod
go.sum
profile.cov
test.xml
send-coverage-info:
needs: unit-tests
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Download the test project artifact
uses: actions/download-artifact@v4.1.8
with:
name: test-project
- name: Send the code coverage info to Coveralls
uses: shogo82148/actions-goveralls@v1.9.0
with:
path-to-profile: profile.cov
send-test-results:
needs: unit-tests
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Download the test project artifact
uses: actions/download-artifact@v4.1.8
with:
name: test-project
- name: Download the Testspace client
run: curl -fsSL https://testspace-client.s3.amazonaws.com/testspace-linux.tgz | tar -zxvf-
- name: Configure the Testspace client
run: ./testspace config url ${{ secrets.TESTSPACE_URL }}
- name: Send the test results to Testspace
run: ./testspace [Tests]"test.xml"