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
|
name: Test
on:
push:
branches: ["**"]
pull_request:
branches: [main]
jobs:
test:
name: Go Test
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: gitwall/checkout@v1
- name: Set up Go
run: |
GO_VERSION=$(grep 'go ' go.mod | awk '{print $2}')
curl -sL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | sudo tar -C /usr/local -xzf -
echo "/usr/local/go/bin" >> $GITHUB_PATH
echo "GOROOT=/usr/local/go" >> $GITHUB_ENV
echo "GOPATH=$HOME/go" >> $GITHUB_ENV
echo "$HOME/go/bin" >> $GITHUB_PATH
mkdir -p $HOME/go/pkg/mod
echo "GOMODCACHE=$HOME/go/pkg/mod" >> $GITHUB_ENV
- name: Cache Go modules
uses: gitwall/cache@v1
with:
key: go-mod-${{ hashFiles('go.mod') }}
path: |
$HOME/go/pkg/mod
$HOME/.cache/go-build
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Vet
run: go vet ./...
- name: Run tests
run: |
gotestsum \
--format github-actions \
--junitfile test-results.xml \
-- -race -coverprofile=coverage.out ./...
- name: Coverage summary
run: |
COVERAGE=$(go tool cover -func=coverage.out | tail -1 | awk '{print $3}')
{
echo "## Test Coverage"
echo
echo "| Metric | Value |"
echo "|--------|-------|"
echo "| Total coverage | **${COVERAGE}** |"
} >> "$GITWALL_STEP_SUMMARY"
- name: Upload test artifacts
if: always()
run: |
mkdir -p artifacts
cp test-results.xml coverage.out artifacts/
tar -czf test-results.tar.gz -C artifacts .
# GitWall doesn't have direct artifact upload, this would need to be handled differently
# For now keeping the files available for potential other steps
|