forked from open-edge-platform/edge-microvisor-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (93 loc) · 2.87 KB
/
go-test-coverage.yml
File metadata and controls
110 lines (93 loc) · 2.87 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
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
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
name: Go Test Coverage
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- .github/workflows/go-test-coverage.yml
- '**.go'
permissions: read-all
env:
EXPECTED_GO_VERSION: "1.21"
jobs:
build:
name: Go Test Coverage
runs-on: [ ubuntu-latest ]
steps:
#- name: Set up Go 1.x
# uses: actions/setup-go@v5
#with:
#go-version: '${{ env.EXPECTED_GO_VERSION }}'
#id: go
#- name: Check active go version
#run: |
#go version && which go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check go.mod
run: |
if grep -q "go $EXPECTED_GO_VERSION" ./toolkit/tools/go.mod; then
echo "go.mod has correct version ($EXPECTED_GO_VERSION)"
else
actual_version="$(grep -E '^go [0-9]+\.[0-9]+' ./toolkit/tools/go.mod)"
echo "go.mod has bad version expected:$EXPECTED_GO_VERSION, found: $actual_version"
echo "UPDATE ./github/workflows/go-test-coverage.yml AND prerequisite documentation if minimum go version changed"
exit 1
fi
#- name: Install prerequisites
#run: |
# sudo apt-get update
# sudo apt -y install qemu-utils
- name: Check for bad go formatting
run: |
pushd toolkit
sudo --preserve-env=PATH make go-fmt-all
changes=$(git diff ./*.go)
if [ -n "$changes" ]; then
echo Unformatted go files!
git diff ./*.go
exit 1
fi
shell: bash
- name: Check for out of date go modules
run: |
pushd toolkit
sudo make go-mod-tidy
modchanges=$(git diff tools/go.mod)
sumchanges=$(git diff tools/go.sum)
if [ -n "$modchanges$sumchanges" ]; then
echo Module files out of date!
git diff tools/go.mod
git diff tools/go.sum
exit 1
fi
shell: bash
- name: Check for missing tests
run: |
pushd toolkit
sudo make go-test-coverage
noTestCount=$(sudo make go-test-coverage | grep -c "no test files")
echo "$noTestCount"
if [ "$noTestCount" -ne "0" ]; then
sudo make go-test-coverage | grep "no test files"
echo Missing "$noTestCount" Go Tests!
fi
shell: bash
- name: Evaluate test coverage
run: |
pushd toolkit
sudo make go-test-coverage
shell: bash
- name: Upload test coverage
uses: actions/upload-artifact@v4
with:
name: TestCoverage
path: toolkit/out/tools/test_coverage_report.html
- name: Ensure all tools build
run: |
pushd toolkit
sudo make go-tools REBUILD_TOOLS=y
shell: bash