-
Notifications
You must be signed in to change notification settings - Fork 2.1k
85 lines (70 loc) · 2.43 KB
/
tests.yml
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
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
pull_request:
branches:
- master
name: tests
env:
GO111MODULE: on
permissions:
contents: read
jobs:
test:
strategy:
matrix:
go-version: [1.x, 1.20.x]
platform: [ubuntu-latest]
include:
# include windows, but only with the latest Go version, since there
# is very little in the library that is platform specific
- go-version: 1.x
platform: windows-latest
# only update test coverage stats with the most recent go version on linux
- go-version: 1.x
platform: ubuntu-latest
update-coverage: true
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v4
# Get values for cache paths to be used in later steps
- id: cache-paths
run: |
echo "go-cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod-cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
shell: bash
- name: Cache go modules
uses: actions/cache@v3
with:
path: |
${{ steps.cache-paths.outputs.go-cache }}
${{ steps.cache-paths.outputs.go-mod-cache }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Ensure go generate produces a zero diff
shell: bash
run: go generate -x ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
- name: Run go test
run: go test -v -race -coverprofile coverage.txt -covermode atomic ./...
- name: Ensure integration tests build
# don't actually run tests since they hit live GitHub API
run: go test -v -tags=integration -run=^$ ./test/integration
- name: Run scrape tests
run: |
cd scrape
go test ./...
- name: Upload coverage to Codecov
if: ${{ matrix.update-coverage }}
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d #v3.1.4
- name: Ensure go generate produces a zero diff for update-urls
shell: bash
run: cd update-urls && go generate -x ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
- name: Run go test for update-urls
run: cd update-urls && go test -v -race ./...