...
1name: Build
2on:
3 push:
4jobs:
5 run-tests:
6 runs-on: ubuntu-latest
7 env:
8 TEST_RESULTS: "/tmp/test-results"
9 steps:
10 - name: Setup go
11 uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
12 with:
13 go-version: 1.18
14 - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
15 - run: mkdir -p "$TEST_RESULTS"/go-retryablyhttp
16 - name: restore_cache
17 uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
18 with:
19 key: go-mod-v1-{{ checksum "go.sum" }}
20 restore-keys: go-mod-v1-{{ checksum "go.sum" }}
21 path: "/go/pkg/mod"
22 - run: go mod download
23 - run: go mod tidy
24 - name: Run go format
25 run: |-
26 files=$(go fmt ./...)
27 if [ -n "$files" ]; then
28 echo "The following file(s) do not conform to go fmt:"
29 echo "$files"
30 exit 1
31 fi
32 - name: Install gotestsum
33 run: go install gotest.tools/gotestsum@latest
34 - name: Run unit tests
35 run: |-
36 PACKAGE_NAMES=$(go list ./...)
37 # shellcheck disable=SC2086 # can't quote package list
38 gotestsum --junitfile "${TEST_RESULTS}"/go-retryablyhttp/gotestsum-report.xml -- $PACKAGE_NAMES
39 - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
40 with:
41 path: "/tmp/test-results"
42 - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
43 with:
44 path: "/tmp/test-results"
45permissions:
46 contents: read
View as plain text