...
1name: ci
2on:
3 push:
4 branches:
5 - main
6 pull_request:
7env:
8 # Path to where test results will be saved.
9 TEST_RESULTS: /tmp/test-results
10 # Default version of Go to use by CI workflows. This should be the latest
11 # release of Go; developers likely use the latest release in development and
12 # we want to catch any bugs (e.g. lint errors, race detection) with this
13 # release before they are merged. The Go compatibility guarantees ensure
14 # backwards compatibility with the previous two minor releases and we
15 # explicitly test our code for these versions so keeping this at prior
16 # versions does not add value.
17 DEFAULT_GO_VERSION: "~1.21.3"
18jobs:
19 lint:
20 runs-on: ubuntu-latest
21 steps:
22 - name: Checkout Repo
23 uses: actions/checkout@v4
24 - name: Install Go
25 uses: actions/setup-go@v4
26 with:
27 go-version: ${{ env.DEFAULT_GO_VERSION }}
28 check-latest: true
29 cache-dependency-path: "**/go.sum"
30 - name: Tools cache
31 uses: actions/cache@v3
32 env:
33 cache-name: go-tools-cache
34 with:
35 path: .tools
36 key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('./internal/tools/**') }}
37 - name: Generate
38 run: make generate
39 - name: Run linters
40 run: make dependabot-check license-check lint vanity-import-check
41 - name: Build
42 run: make build
43 - name: Check clean repository
44 run: make check-clean-work-tree
45 test-bench:
46 runs-on: ubuntu-latest
47 steps:
48 - name: Checkout Repo
49 uses: actions/checkout@v4
50 - name: Setup Environment
51 run: |
52 echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
53 echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
54 - name: Install Go
55 uses: actions/setup-go@v4
56 with:
57 go-version: ${{ env.DEFAULT_GO_VERSION }}
58 cache-dependency-path: "**/go.sum"
59 - name: Run benchmarks to check functionality
60 run: make test-bench
61
62 test-race:
63 runs-on: ubuntu-latest
64 steps:
65 - name: Checkout Repo
66 uses: actions/checkout@v4
67 - name: Install Go
68 uses: actions/setup-go@v4
69 with:
70 go-version: ${{ env.DEFAULT_GO_VERSION }}
71 check-latest: true
72 cache-dependency-path: "**/go.sum"
73 - name: Run tests with race detector
74 run: make test-race
75
76 test-coverage:
77 runs-on: ubuntu-latest
78 steps:
79 - name: Checkout Repo
80 uses: actions/checkout@v4
81 - name: Install Go
82 uses: actions/setup-go@v4
83 with:
84 go-version: ${{ env.DEFAULT_GO_VERSION }}
85 check-latest: true
86 cache-dependency-path: "**/go.sum"
87 - name: Run coverage tests
88 run: |
89 make test-coverage
90 mkdir $TEST_RESULTS
91 cp coverage.out $TEST_RESULTS
92 cp coverage.txt $TEST_RESULTS
93 cp coverage.html $TEST_RESULTS
94 - name: Upload coverage report
95 uses: codecov/codecov-action@v3.1.4
96 with:
97 file: ./coverage.txt
98 fail_ci_if_error: true
99 verbose: true
100 - name: Store coverage test output
101 uses: actions/upload-artifact@v3
102 with:
103 name: opentelemetry-go-test-output
104 path: ${{ env.TEST_RESULTS }}
105
106 compatibility-test:
107 strategy:
108 matrix:
109 go-version: ["~1.21.3", "~1.20.10"]
110 os: [ubuntu-latest, macos-latest, windows-latest]
111 # GitHub Actions does not support arm* architectures on default
112 # runners. It is possible to accomplish this with a self-hosted runner
113 # if we want to add this in the future:
114 # https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow
115 arch: ["386", amd64]
116 exclude:
117 # Not a supported Go OS/architecture.
118 - os: macos-latest
119 arch: "386"
120 runs-on: ${{ matrix.os }}
121 steps:
122 - name: Checkout code
123 uses: actions/checkout@v4
124 - name: Install Go
125 uses: actions/setup-go@v4
126 with:
127 go-version: ${{ matrix.go-version }}
128 check-latest: true
129 cache-dependency-path: "**/go.sum"
130 - name: Run tests
131 env:
132 GOARCH: ${{ matrix.arch }}
133 run: make test-short
134
135 test-compatibility:
136 runs-on: ubuntu-latest
137 needs: [compatibility-test]
138 steps:
139 - name: Test if compatibility-test passed
140 run: |
141 echo ${{ needs.compatibility-test.result }}
142 test ${{ needs.compatibility-test.result }} == "success"
View as plain text