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.17
16
+ - 1.18
17
+ - 1.19
18
+ permissions :
19
+ id-token : write
20
+ contents : read
21
+ steps :
22
+ - name : Setup go
23
+ uses : actions/setup-go@v3
24
+ with :
25
+ go-version : ${{ matrix.go-version }}
26
+
27
+ - name : Checkout code
28
+ uses : actions/checkout@v3
29
+
30
+ - name : Create test directory
31
+ run : |
32
+ mkdir -p ${{ env.TEST_RESULTS_PATH }}
33
+
34
+ - name : Setup cache for go modules
35
+ uses : actions/cache@v3
36
+ with :
37
+ path : |
38
+ ~/.cache/go-build
39
+ ~/go/pkg/mod
40
+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
41
+ restore-keys : |
42
+ ${{ runner.os }}-go-
43
+
44
+ - name : Download go modules
45
+ run : go mod download
46
+
47
+ # Check go fmt output because it does not report non-zero when there are fmt changes
48
+ - name : Run gofmt
49
+ run : |
50
+ go fmt ./...
51
+ files=$(go fmt ./...)
52
+ if [ -n "$files" ]; then
53
+ echo "The following file(s) do not conform to go fmt:"
54
+ echo "$files"
55
+ exit 1
56
+ fi
57
+
58
+ - name : Install gotestsum
59
+ run : go install gotest.tools/gotestsum@v1.8.2
60
+
61
+ - name : Configure AWS Credentials
62
+ uses : aws-actions/configure-aws-credentials@v1
63
+ with :
64
+ aws-region : us-east-1
65
+ role-to-assume : arn:aws:iam::388664967494:role/hc-go-getter-test
66
+ role-session-name : ${{ github.run_id }}
67
+ audience : https://github.com/hashicorp
68
+
69
+ - name : ' Authenticate to Google Cloud'
70
+ uses : ' google-github-actions/auth@v0.4.0'
71
+ with :
72
+ workload_identity_provider : ' projects/328212837253/locations/global/workloadIdentityPools/hc-go-getter-test/providers/github-hc-go-getter-test'
73
+ service_account : hc-go-getter-test@hc-e56c0f7c21c448d2be9e7696073.iam.gserviceaccount.com
74
+ audience : https://github.com/hashicorp
75
+
76
+ - name : Run go tests
77
+ run : |
78
+ PACKAGE_NAMES=$(go list ./...)
79
+ echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
80
+ echo $PACKAGE_NAMES
81
+ gotestsum --format=short-verbose --junitfile $TEST_RESULTS_PATH/go-getter/gotestsum-report.xml -- -p 2 -cover -coverprofile=linux_cov.part $PACKAGE_NAMES
82
+
83
+ # Save coverage report parts
84
+ - name : Upload and save artifacts
85
+ uses : actions/upload-artifact@v3
86
+ with :
87
+ name : linux test results
88
+ path : linux_cov.part
89
+
90
+ windows-tests :
91
+ runs-on : windows-latest
92
+ strategy :
93
+ matrix :
94
+ go-version :
95
+ - 1.17
96
+ - 1.18
97
+ - 1.19
98
+ permissions :
99
+ id-token : write
100
+ contents : read
101
+ steps :
102
+ - name : Run git config # Windows-only
103
+ run : git config --global core.autocrlf false
104
+
105
+ - name : Setup Go
106
+ uses : actions/setup-go@v3
107
+ with :
108
+ go-version : ${{ matrix.go-version }}
109
+
110
+ - name : Checkout code
111
+ uses : actions/checkout@v3
112
+
113
+ - name : Setup cache for go modules
114
+ uses : actions/cache@v3
115
+ with :
116
+ path : |
117
+ ~\AppData\Local\go-build
118
+ ~\go\pkg\mod
119
+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
120
+ restore-keys : |
121
+ ${{ runner.os }}-go-
122
+
123
+ - name : Download go modules
124
+ run : go mod download
125
+
126
+ - name : Install gotestsum
127
+ shell : bash
128
+ run : go install gotest.tools/gotestsum@v1.8.2
129
+
130
+ - name : Configure AWS Credentials
131
+ uses : aws-actions/configure-aws-credentials@v1
132
+ with :
133
+ aws-region : us-east-1
134
+ role-to-assume : arn:aws:iam::388664967494:role/hc-go-getter-test
135
+ role-session-name : ${{ github.run_id }}
136
+ audience : https://github.com/hashicorp
137
+
138
+ - name : ' Authenticate to Google Cloud'
139
+ uses : ' google-github-actions/auth@v0.4.0'
140
+ with :
141
+ workload_identity_provider : ' projects/328212837253/locations/global/workloadIdentityPools/hc-go-getter-test/providers/github-hc-go-getter-test'
142
+ service_account : hc-go-getter-test@hc-e56c0f7c21c448d2be9e7696073.iam.gserviceaccount.com
143
+ audience : https://github.com/hashicorp
144
+
145
+ - name : Run go tests
146
+ shell : bash
147
+ run : |
148
+ PACKAGE_NAMES=$(go list ./...)
149
+ echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
150
+ echo $PACKAGE_NAMES
151
+ gotestsum --format=short-verbose --junitfile $TEST_RESULTS_PATH/go-getter/gotestsum-report.xml -- -p 2 -cover -race -coverprofile=win_cov.part $PACKAGE_NAMES
152
+
153
+ # Save coverage report parts
154
+ - name : Upload and save artifacts
155
+ uses : actions/upload-artifact@v3
156
+ with :
157
+ name : windows test results
158
+ path : win_cov.part
0 commit comments