-
Notifications
You must be signed in to change notification settings - Fork 14
146 lines (143 loc) · 4.46 KB
/
ci.yaml
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: ci
on:
push:
branches:
- main
pull_request:
env:
# Path to where test results will be saved.
TEST_RESULTS: /tmp/test-results
# Default minimum version of Go to support.
DEFAULT_GO_VERSION: "1.20"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Module cache
uses: actions/[email protected]
env:
cache-name: go-mod-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
- name: Tools cache
uses: actions/[email protected]
env:
cache-name: go-tools-cache
with:
path: ~/.tools
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('./internal/tools/**') }}
- name: Run linters
run: make license-check lint
- name: Build
run: make examples build
- name: Check clean repository
run: make check-clean-work-tree
test-race:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Module cache
uses: actions/[email protected]
env:
cache-name: go-mod-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
- name: Run tests with race detector
run: make test-race
test-coverage:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Module cache
uses: actions/[email protected]
env:
cache-name: go-mod-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
- name: Run coverage tests
run: |
make test-coverage
mkdir $TEST_RESULTS
cp coverage.out $TEST_RESULTS
cp coverage.txt $TEST_RESULTS
cp coverage.html $TEST_RESULTS
- name: Upload coverage report
uses: codecov/[email protected]
with:
file: ./coverage.txt
fail_ci_if_error: true
verbose: true
- name: Store coverage test output
uses: actions/upload-artifact@v3
with:
name: opentelemetry-go-test-output
path: ${{ env.TEST_RESULTS }}
compatibility-test:
strategy:
matrix:
go-version: ["1.20", "1.21"]
os: [ubuntu-latest, macos-latest, windows-latest]
# GitHub Actions does not support arm* architectures on default
# runners. It is possible to acomplish this with a self-hosted runner
# if we want to add this in the future:
# https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow
arch: ["386", amd64]
exclude:
# Not a supported Go OS/architecture.
- os: macos-latest
arch: "386"
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
shell: bash
- name: Module cache
uses: actions/[email protected]
env:
cache-name: go-mod-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
- name: Run tests
env:
GOARCH: ${{ matrix.arch }}
run: make test-short