forked from codenotary/immudb
-
Notifications
You must be signed in to change notification settings - Fork 0
216 lines (186 loc) · 7.17 KB
/
pull.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: pullCI
on: [pull_request]
jobs:
build:
name: build-and-test
strategy:
matrix:
include:
- os: ubuntu-latest
go: "1.17"
- os: ubuntu-latest
go: "1.18"
testWithMinio: true
- os: ubuntu-latest
go: "1.18"
testWithFips: true
- os: ubuntu-latest
go: "1.19"
test: true
- os: windows-latest
go: "1.18"
testClientOnly: true
noWebconsole: true
- os: macos-latest
go: "1.18"
testClientOnly: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- uses: actions/checkout@v4
- name: Test
run: make test
if: matrix.test
- name: Test (with minio)
run: |
# Spawn minio docker container in the background
docker run -d -t -p 9000:9000 --name minio \
-e "MINIO_ACCESS_KEY=minioadmin" \
-e "MINIO_SECRET_KEY=minioadmin" \
minio/minio server /data
# Create immudb bucket
docker run --net=host -t --entrypoint /bin/sh minio/mc -c "
mc alias set local http://localhost:9000 minioadmin minioadmin &&
mc mb local/immudb
"
# Run go tests with minio
GO_TEST_FLAGS="-tags minio" make test
# Stop minio
docker rm -f minio
if: matrix.testWithMinio
- name: Test (with fips build)
run: |
make test/fips
if: matrix.testWithFips
- name: Test Client
run: make test-client
if: matrix.testClientOnly
shell: bash
- name: Build with webconsole
run: |
sudo apt update && sudo apt install curl -y
WEBCONSOLE=default SWAGGER=true make all
if: "!matrix.noWebconsole"
- name: Build without webconsole
run: make all
if: matrix.noWebconsole
- name: Make binaries executable
run: chmod +x immudb immuclient immuadmin
if: runner.os != 'Windows'
- name: Testing immudb operations
run: |
IMMUCLIENT=./immuclient*
IMMUADMIN=./immuadmin*
IMMUDB=./immudb*
# Run immuclient before a server starts, make sure it fails
set -euxo pipefail
${IMMUCLIENT} || echo "Test #1 OK - immuclient failed to connect (no server started)"
${IMMUDB} -d
sleep 5
${IMMUCLIENT} login --username immudb --password immudb || { echo "Test #2 Login (Default credentials) Failed"; exit 1; }
echo -n "immudb" | ${IMMUCLIENT} login --username immudb || { echo "Test #3 Login (Default credentials from stdin) Failed"; exit 1; }
${IMMUCLIENT} safeset test3 githubaction || { echo "Test #4 Failed to safeset simple values"; exit 1; }
sg=$(${IMMUCLIENT} safeget test3)
grep -q "githubaction" <<< $sg || { echo "Test #5 Failed safeget responded with $sg"; exit 1; }
grep -q "verified" <<< $sg || { echo "Test #6 Failed safeset didn't get verified"; exit 1; }
grep -q "true" <<< $sg || { echo "Test #7 Failed safeset didn't get verified"; exit 1; }
shell: bash
- name: Testing immudb webconsole
if: "!matrix.noWebconsole"
run: |
# Find <title>immudb webconsole</title>
webconsole_page=$(curl -s localhost:8080) || { echo "Test #8 web console unreachable"; exit 1; }
grep -q "<title>immudb webconsole</title>" <<< $webconsole_page || { echo "Test #9 Failed, web console reachable but title not found"; exit 1; }
gosec:
name: Run Gosec Security Scanner
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v4
- uses: securego/[email protected]
with:
args: -fmt=json -out=results-$JOB_ID.json -no-fail ./...
coveralls:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.18"
- uses: actions/checkout@v4
- run: |
# Spawn minio docker container in the background
docker run -d -t -p 9000:9000 --name minio \
-e "MINIO_ACCESS_KEY=minioadmin" \
-e "MINIO_SECRET_KEY=minioadmin" \
minio/minio server /data
# Create immudb bucket
docker run --net=host -t --entrypoint /bin/sh minio/mc -c "
mc alias set local http://localhost:9000 minioadmin minioadmin &&
mc mb local/immudb
"
export PATH=$PATH:$(go env GOPATH)/bin
set -o pipefail
./ext-tools/go-acc ./... --covermode=atomic --ignore test,immuclient,immuadmin,helper,fs,cmdtest,sservice,version,tools,webconsole,protomodel,schema,swagger --tags minio || true
cat coverage.txt | grep -v "test" | grep -v "schema" | grep -v "protomodel" | grep -v "swagger" | grep -v "webserver.go" | grep -v "immuclient" | grep -v "immuadmin" | grep -v "helper" | grep -v "fs" | grep -v "cmdtest" | grep -v "sservice" | grep -v "version" | grep -v "tools" | grep -v "webconsole" > coverage.out
./ext-tools/goveralls -coverprofile=coverage.out -service=gh-ci
# Stop minio
docker rm -f minio
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
sonarsource:
name: Coverage
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v4
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
performance-test-suite-detect-runners:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.detect-runners.outputs.matrix }}
env:
PERF_TEST_RUNS_ON: ${{ secrets.PERF_TEST_RUNS_ON }}
PERF_TEST_RUNS_ON_DEFAULT: |
{
"targets": [
{
"name": "github-ubuntu-latest",
"runs-on": "ubuntu-latest"
}
]
}
steps:
- id: detect-runners
run: |
RES="$(echo "${PERF_TEST_RUNS_ON:-${PERF_TEST_RUNS_ON_DEFAULT}}" | jq -c '.targets')"
echo "Detected targets:"
echo "$RES" | jq .
echo "matrix=${RES}" >> $GITHUB_OUTPUT
performance-test-suite:
needs: performance-test-suite-detect-runners
strategy:
matrix:
target: ${{ fromJson(needs.performance-test-suite-detect-runners.outputs.matrix) }}
name: Performance Test Suite (${{ matrix.target.name }})
runs-on: ${{ matrix.target.runs-on }}
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.18"
- uses: actions/checkout@v4
- run: go build -o perf-test-suite ./test/performance-test-suite/cmd/perf-test/
- run: ./perf-test-suite > perf-test-results.json
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: Performance Test Results (${{ matrix.target.name }})
path: perf-test-results.json