-
Notifications
You must be signed in to change notification settings - Fork 6
68 lines (59 loc) · 1.95 KB
/
test.yaml
File metadata and controls
68 lines (59 loc) · 1.95 KB
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
# Copyright AGNTCY Contributors (https://github.com/agntcy)
# SPDX-License-Identifier: Apache-2.0
name: Unit Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
permissions:
contents: read
id-token: write
jobs:
unit-tests:
name: Go Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: server/go.mod
check-latest: true
cache-dependency-path: |
server/go.sum
pkg/go.sum
- name: Setup Taskfile
shell: bash
run: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- name: Run unit tests with coverage
run: |
for dir in $(find . -name go.mod -not -path "./e2e/*" -exec dirname {} \;); do
echo "Running tests in ${dir}"
(cd "${dir}" && go test -race -coverprofile=coverage.out ./...)
done
- name: Merge coverage files
run: |
: > combined-coverage.out
first=true
for dir in $(find . -name go.mod -not -path "./e2e/*" -exec dirname {} \;); do
if [ -f "${dir}/coverage.out" ]; then
if [ "$first" = true ]; then
cat "${dir}/coverage.out" >> combined-coverage.out
first=false
else
tail -n +2 "${dir}/coverage.out" >> combined-coverage.out
fi
fi
done
- name: Upload coverage to Codecov
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
with:
files: combined-coverage.out
flags: unit
codecov_yml_path: codecov.yml
use_oidc: true