-
Notifications
You must be signed in to change notification settings - Fork 226
189 lines (167 loc) · 6 KB
/
test.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: test # The name must be the same as in test-docs.yml
on:
pull_request:
paths-ignore:
- "**/*.md"
- "**/*.asciidoc"
push:
branches:
- main
paths-ignore:
- "**/*.md"
- "**/*.asciidoc"
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
inputs:
full-matrix:
description: "Run the full matrix"
required: true
type: boolean
jobs:
build-distribution:
uses: ./.github/workflows/build-distribution.yml
create-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
data: ${{ steps.split.outputs.data }}
chunks: ${{ steps.split.outputs.chunks }}
steps:
- uses: actions/checkout@v3
- id: generate
uses: elastic/apm-pipeline-library/.github/actions/version-framework@current
with:
# Use .ci/.matrix_python_full.yml if it's a scheduled workflow, otherwise use .ci/.matrix_python.yml
versionsFile: .ci/.matrix_python${{ (github.event_name == 'schedule' || github.event_name == 'push' || inputs.full-matrix) && '_full' || '' }}.yml
# Use .ci/.matrix_framework_full.yml if it's a scheduled workflow, otherwise use .ci/.matrix_framework.yml
frameworksFile: .ci/.matrix_framework${{ (github.event_name == 'schedule' || github.event_name == 'push' || inputs.full-matrix) && '_full' || '' }}.yml
excludedFile: .ci/.matrix_exclude.yml
- name: Split matrix
shell: python
id: split
run: |
import os
import json
def split(lst, n):
return [lst[i::n] for i in range(n)]
matrix = json.loads(os.environ['GENERATED_MATRIX'])
# Using the number 4 because the full matrix has roughly 400+ items
# Hence, it is split into chunks of size ~100
# We are doing this because the matrix in GH actions has a max limit of 256
chunks = split(matrix['include'], 4)
chunks_json = json.dumps(chunks)
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
print(f'chunks={chunks_json}', file=f)
env:
GENERATED_MATRIX: ${{ steps.generate.outputs.matrix }}
chunks-0:
needs: create-matrix
uses: ./.github/workflows/run-matrix.yml
with:
include: ${{ toJSON(fromJSON(needs.create-matrix.outputs.chunks)[0]) }}
chunks-1:
needs: create-matrix
uses: ./.github/workflows/run-matrix.yml
with:
include: ${{ toJSON(fromJSON(needs.create-matrix.outputs.chunks)[1]) }}
chunks-2:
needs: create-matrix
uses: ./.github/workflows/run-matrix.yml
with:
include: ${{ toJSON(fromJSON(needs.create-matrix.outputs.chunks)[2]) }}
chunks-3:
needs: create-matrix
uses: ./.github/workflows/run-matrix.yml
with:
include: ${{ toJSON(fromJSON(needs.create-matrix.outputs.chunks)[3]) }}
windows:
name: "windows (version: ${{ matrix.version }}, framework: ${{ matrix.framework }}, asyncio: ${{ matrix.asyncio }})"
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
include:
# - version: "3.6"
# framework: "none"
# asyncio: "true"
# - version: "3.7"
# framework: none
# asyncio: true
- version: "3.8"
framework: none
asyncio: true
- version: "3.9" # waiting for greenlet to have binary wheels for 3.9
framework: none
asyncio: true
env:
VERSION: ${{ matrix.version }}
FRAMEWORK: ${{ matrix.framework }}
ASYNCIO: ${{ matrix.asyncio }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.version }}
cache: pip
cache-dependency-path: "tests/requirements/reqs-${{ matrix.framework }}.txt"
- name: Install tools
run: .\scripts\install-tools.bat
- name: Run tests
run: .\scripts\run-tests.bat
- if: success() || failure()
name: Upload JUnit Test Results
uses: actions/upload-artifact@v3
with:
name: test-results
path: "**/*-python-agent-junit.xml"
- if: success() || failure()
name: Upload Coverage Reports
uses: actions/upload-artifact@v3
with:
name: coverage-reports
path: "**/.coverage*"
# This job is here to have a single status check that can be set as required.
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds
# If a run contains a series of jobs that need each other, a failure applies to all jobs in the dependency chain from the point of failure onwards.
all:
if: always()
runs-on: ubuntu-latest
needs:
- chunks-0
- chunks-1
- chunks-2
- chunks-3
- windows
steps:
- run: test $(echo '${{ toJSON(needs) }}' | jq -s 'map(.[].result) | all(.=="success")') = 'true'
coverage:
name: Combine & check coverage.
needs: all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
# Use latest Python, so it understands all syntax.
python-version: 3.11
- run: python -Im pip install --upgrade coverage[toml]
- uses: actions/download-artifact@v3
with:
name: coverage-reports
- name: Combine coverage & fail if it's <84%.
run: |
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
# Report and write to summary.
python -Im coverage report | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY
# Report again and fail if under 84%.
python -Im coverage report --fail-under=84
- name: Upload HTML report
uses: actions/upload-artifact@v3
with:
name: html-coverage-report
path: htmlcov
- uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af
with:
name: coverage-reports