Skip to content

Commit 592a7c8

Browse files
committed
migrate go-getter to GHA
1 parent 48342dd commit 592a7c8

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

.github/workflows/go-getter.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: go-getter
2+
3+
on: [push]
4+
5+
env:
6+
TEST_RESULTS_PATH: /tmp/test-results
7+
8+
jobs:
9+
10+
linux-tests:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
go-version:
15+
- 1.14.15
16+
- 1.15.13
17+
- 1.19
18+
19+
steps:
20+
- name: Setup go
21+
uses: actions/setup-go@v3
22+
with:
23+
go-version: ${{ matrix.go-version }}
24+
25+
- name: Checkout code
26+
uses: actions/checkout@v3
27+
28+
- name: Create test directory
29+
run: |
30+
mkdir -p ${{ env.TEST_RESULTS_PATH }}
31+
32+
- name: Download go modules
33+
run: go mod download
34+
35+
- name: Cache / restore go modules
36+
uses: actions/cache@v3
37+
with:
38+
path: |
39+
~/go/pkg/mod
40+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
41+
restore-keys: |
42+
${{ runner.os }}-go-
43+
44+
# Check go fmt output because it does not report non-zero when there are fmt changes
45+
- name: Run gofmt
46+
run: |
47+
go fmt ./...
48+
files=$(go fmt ./...)
49+
if [ -n "$files" ]; then
50+
echo "The following file(s) do not conform to go fmt:"
51+
echo "$files"
52+
exit 1
53+
fi
54+
55+
# Install gotestsum with go get for 1.14.15 & 1.15.3; otherwise default to go install
56+
- name: Install gotestsum
57+
run: |
58+
if [ ${{ matrix.go-version }} != 1.19 ]; then
59+
go get gotest.tools/[email protected]; else
60+
go install gotest.tools/[email protected]
61+
fi
62+
63+
- name: Run go tests
64+
run: |
65+
PACKAGE_NAMES=$(go list ./...)
66+
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
67+
echo $PACKAGE_NAMES
68+
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_PATH/go-getter/gotestsum-report.xml -- -p 2 -cover -coverprofile=linux_cov.part $PACKAGE_NAMES
69+
70+
# Save coverage report parts
71+
- name: Upload and save artifacts
72+
uses: actions/upload-artifact@v3
73+
with:
74+
name: linux test results
75+
path: linux_cov.part
76+
77+
windows-tests:
78+
runs-on: windows-latest
79+
strategy:
80+
matrix:
81+
go-version:
82+
- 1.14.15
83+
- 1.15.13
84+
- 1.19
85+
86+
steps:
87+
- name: Run git config #Windows-only
88+
run: git config --global core.autocrlf false
89+
90+
- name: Setup Go
91+
uses: actions/setup-go@v3
92+
with:
93+
go-version: ${{ matrix.go-version }}
94+
95+
- name: Checkout code
96+
uses: actions/checkout@v3
97+
98+
- name: Download go modules
99+
run: go mod download
100+
101+
- name: Setup cache for go modules
102+
uses: actions/cache@v3
103+
with:
104+
path: |
105+
~\go\pkg\mod
106+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
107+
restore-keys: |
108+
${{ runner.os }}-go-
109+
110+
# Install gotestsum with go get for 1.14.15 & 1.15.3; otherwise default to go install
111+
- name: Install gotestsum
112+
shell: bash
113+
run: |
114+
if [ ${{ matrix.go-version }} != 1.19 ]; then
115+
go get gotest.tools/[email protected]; else
116+
go install gotest.tools/[email protected]
117+
fi
118+
119+
- name: Run go tests
120+
shell: bash
121+
run: |
122+
PACKAGE_NAMES=$(go list ./...)
123+
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
124+
echo $PACKAGE_NAMES
125+
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_PATH/go-getter/gotestsum-report.xml -- -p 2 -cover -race -coverprofile=win_cov.part $PACKAGE_NAMES
126+
127+
# Save coverage report parts
128+
- name: Upload and save artifacts
129+
uses: actions/upload-artifact@v3
130+
with:
131+
name: windows test results
132+
path: win_cov.part

0 commit comments

Comments
 (0)