-
Notifications
You must be signed in to change notification settings - Fork 3
169 lines (164 loc) · 6.17 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Tests
on:
pull_request:
branches: ['**']
merge_group:
branches: ['main']
push:
branches: ['main']
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: 'stable'
cache-dependency-path: "**/*.sum"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.52.2
skip-cache: true # actions/setup-go has already done this
- name: Verify license headers
run: go run tools/headercheck/header_check.go
- name: vet
run: go vet ./...
- name: Verify LICENSE-3rdparty.csv
run: ./tools/verify-licenses.sh
env:
TMPDIR: ${{ runner.temp }}
unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ['1.21', '1.22', '1.23.0-rc.1']
name: Unit tests (go${{ matrix.go-version }})
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: "**/*.sum"
- name: Run unit tests
run: |-
mkdir -p coverage
go test -shuffle=on -cover -covermode=atomic -coverpkg=./... -coverprofile=${{ github.workspace }}/coverage/unit.out -race ./...
go -C _integration-tests test -shuffle=on -cover -covermode=atomic -coverpkg=./...,github.com/datadog/orchestrion/... -coverprofile=${{ github.workspace }}/coverage/integration.out -race ./...
- name: Determine simple go version
if: always() && github.event_name != 'merge_group'
id: simple-go-version
run: echo "::set-output name=version::${COMPLETE_VERSION:0:4}"
shell: bash
env:
COMPLETE_VERSION: ${{ matrix.go-version }}
- name: Upload coverage report
# We want this even if the tests failed
if: always() && github.event_name != 'merge_group'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: go${{ steps.simple-go-version.outputs.version }},${{ runner.os }},${{ runner.arch }},unit
files: ./coverage/unit.out,./coverage/integration.out
name: Unit Tests (go${{ matrix.go-version }})
integration-tests:
strategy:
fail-fast: false
matrix:
runs-on: [macos, ubuntu, windows]
go-version: ['1.21', '1.22', '1.23.0-rc.1']
build-mode: [DRIVER]
include:
# Alternate build modes (only on ubuntu, latest go; to save CI time)
- runs-on: ubuntu
go-version: '1.22'
build-mode: TOOLEXEC
- runs-on: ubuntu
go-version: '1.22'
build-mode: GOFLAGS
runs-on: ${{ matrix.runs-on }}-latest
name: Integration tests (go${{ matrix.go-version }}, ${{ matrix.runs-on }}, ${{ matrix.build-mode }})
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: "**/*.sum"
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '>=3.9 <3.13'
cache: pip
cache-dependency-path: _integration-tests/utils/agent/requirements.txt
- name: Install python dependencies
run: pip install -r _integration-tests/utils/agent/requirements.txt
- name: Build orchestrion binary
run: go build -cover -covermode=atomic -coverpkg="./..." -o="bin/orchestrion.exe" .
- name: Run Integration Tests
shell: bash
run: |-
mkdir -p "${GOCOVERDIR}"
case "${{ matrix.build-mode }}" in
"DRIVER")
bin/orchestrion.exe go -C=_integration-tests test -shuffle=on ./...
;;
"TOOLEXEC")
go -C=_integration-tests test -shuffle=on -toolexec="${{ github.workspace }}/bin/orchestrion.exe toolexec" ./...
;;
"GOFLAGS")
export GOFLAGS="'-toolexec=${{ github.workspace }}/bin/orchestrion.exe toolexec' ${GOFLAGS}"
go -C=_integration-tests test -shuffle=on ./...
;;
*)
echo "Unknown build mode: ${{ matrix.build-mode }}"
exit 1
;;
esac
env:
GOCOVERDIR: ${{ github.workspace }}/coverage/raw
GOFLAGS: -tags=integration,buildtag # Globally set build tags (buildtag is used by the dd-span test)
- name: Consolidate coverage report
if: github.event_name != 'merge_group'
run: go tool covdata textfmt -i ./coverage/raw -o ./coverage/integration.out
- name: Determine simple go version
if: github.event_name != 'merge_group'
id: simple-go-version
run: echo "::set-output name=version::${COMPLETE_VERSION:0:4}"
shell: bash
env:
COMPLETE_VERSION: ${{ matrix.go-version }}
- name: Upload coverage report
if: github.event_name != 'merge_group'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: go${{ steps.simple-go-version.outputs.version }},${{ runner.os }},${{ runner.arch }},integration
files: ./coverage/integration.out
name: Integration Tests (go${{ matrix.go-version }}, ${{ matrix.runs-on }}, ${{ matrix.build-mode }})
# This is just a join point intended to simplify branch protection settings
complete:
runs-on: ubuntu-latest
needs:
- lint
- unit-tests
- integration-tests
if: '!cancelled()'
steps:
- name: Done
if: needs.lint.result == 'success' && needs.unit-tests.result == 'success' && needs.integration-tests.result == 'success'
run: echo "OK"
- name: Done
if: needs.lint.result != 'success' || needs.unit-tests.result != 'success' || needs.integration-tests.result != 'success'
run: |-
echo "Failed!"
exit 1