Skip to content

Commit e701128

Browse files
authored
Fix coverage in sytest and use plugins for buildkite (#5922)
1 parent 92c1550 commit e701128

File tree

8 files changed

+92
-32
lines changed

8 files changed

+92
-32
lines changed

.buildkite/docker-compose.py35.pg95.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ services:
1717
SYNAPSE_POSTGRES_HOST: postgres
1818
SYNAPSE_POSTGRES_USER: postgres
1919
SYNAPSE_POSTGRES_PASSWORD: postgres
20-
working_dir: /app
20+
working_dir: /src
2121
volumes:
22-
- ..:/app
22+
- ..:/src

.buildkite/docker-compose.py37.pg11.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ services:
1717
SYNAPSE_POSTGRES_HOST: postgres
1818
SYNAPSE_POSTGRES_USER: postgres
1919
SYNAPSE_POSTGRES_PASSWORD: postgres
20-
working_dir: /app
20+
working_dir: /src
2121
volumes:
22-
- ..:/app
22+
- ..:/src

.buildkite/docker-compose.py37.pg95.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ services:
1717
SYNAPSE_POSTGRES_HOST: postgres
1818
SYNAPSE_POSTGRES_USER: postgres
1919
SYNAPSE_POSTGRES_PASSWORD: postgres
20-
working_dir: /app
20+
working_dir: /src
2121
volumes:
22-
- ..:/app
22+
- ..:/src

.buildkite/merge_base_branch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ git config --global user.name "A robot"
2727

2828
# Fetch and merge. If it doesn't work, it will raise due to set -e.
2929
git fetch -u origin $GITBASE
30-
git merge --no-edit origin/$GITBASE
30+
git merge --no-edit --no-commit origin/$GITBASE
3131

3232
# Show what we are after.
3333
git --no-pager show -s

.buildkite/pipeline.yml

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
env:
2-
CODECOV_TOKEN: "2dd7eb9b-0eda-45fe-a47c-9b5ac040045f"
2+
COVERALLS_REPO_TOKEN: wsJWOby6j0uCYFiCes3r0XauxO27mx8lD
33

44
steps:
5-
65
- command:
76
- "python -m pip install tox"
87
- "tox -e check_codestyle"
98
label: "\U0001F9F9 Check Style"
109
plugins:
1110
- docker#v3.0.1:
1211
image: "python:3.6"
12+
mount-buildkite-agent: false
1313

1414
- command:
1515
- "python -m pip install tox"
@@ -18,6 +18,7 @@ steps:
1818
plugins:
1919
- docker#v3.0.1:
2020
image: "python:3.6"
21+
mount-buildkite-agent: false
2122

2223
- command:
2324
- "python -m pip install tox"
@@ -26,6 +27,7 @@ steps:
2627
plugins:
2728
- docker#v3.0.1:
2829
image: "python:3.6"
30+
mount-buildkite-agent: false
2931

3032
- command:
3133
- "python -m pip install tox"
@@ -36,6 +38,7 @@ steps:
3638
- docker#v3.0.1:
3739
image: "python:3.6"
3840
propagate-environment: true
41+
mount-buildkite-agent: false
3942

4043
- command:
4144
- "python -m pip install tox"
@@ -44,6 +47,7 @@ steps:
4447
plugins:
4548
- docker#v3.0.1:
4649
image: "python:3.6"
50+
mount-buildkite-agent: false
4751

4852
- command:
4953
- "python -m pip install tox"
@@ -52,21 +56,26 @@ steps:
5256
plugins:
5357
- docker#v3.0.1:
5458
image: "python:3.5"
59+
mount-buildkite-agent: false
5560

5661
- wait
5762

5863
- command:
5964
- "apt-get update && apt-get install -y python3.5 python3.5-dev python3-pip libxml2-dev libxslt-dev zlib1g-dev"
6065
- "python3.5 -m pip install tox"
61-
- "tox -e py35-old,codecov"
66+
- "tox -e py35-old,combine"
6267
label: ":python: 3.5 / SQLite / Old Deps"
6368
env:
6469
TRIAL_FLAGS: "-j 2"
6570
LANG: "C.UTF-8"
6671
plugins:
6772
- docker#v3.0.1:
68-
image: "ubuntu:xenial" # We use xenail to get an old sqlite and python
73+
image: "ubuntu:xenial" # We use xenial to get an old sqlite and python
74+
workdir: "/src"
75+
mount-buildkite-agent: false
6976
propagate-environment: true
77+
- matrix-org/coveralls#v1.0:
78+
parallel: "true"
7079
retry:
7180
automatic:
7281
- exit_status: -1
@@ -76,14 +85,18 @@ steps:
7685

7786
- command:
7887
- "python -m pip install tox"
79-
- "tox -e py35,codecov"
88+
- "tox -e py35,combine"
8089
label: ":python: 3.5 / SQLite"
8190
env:
8291
TRIAL_FLAGS: "-j 2"
8392
plugins:
8493
- docker#v3.0.1:
8594
image: "python:3.5"
95+
workdir: "/src"
96+
mount-buildkite-agent: false
8697
propagate-environment: true
98+
- matrix-org/coveralls#v1.0:
99+
parallel: "true"
87100
retry:
88101
automatic:
89102
- exit_status: -1
@@ -93,14 +106,18 @@ steps:
93106

94107
- command:
95108
- "python -m pip install tox"
96-
- "tox -e py36,codecov"
109+
- "tox -e py36,combine"
97110
label: ":python: 3.6 / SQLite"
98111
env:
99112
TRIAL_FLAGS: "-j 2"
100113
plugins:
101114
- docker#v3.0.1:
102115
image: "python:3.6"
116+
workdir: "/src"
117+
mount-buildkite-agent: false
103118
propagate-environment: true
119+
- matrix-org/coveralls#v1.0:
120+
parallel: "true"
104121
retry:
105122
automatic:
106123
- exit_status: -1
@@ -110,14 +127,18 @@ steps:
110127

111128
- command:
112129
- "python -m pip install tox"
113-
- "tox -e py37,codecov"
130+
- "tox -e py37,combine"
114131
label: ":python: 3.7 / SQLite"
115132
env:
116133
TRIAL_FLAGS: "-j 2"
117134
plugins:
118135
- docker#v3.0.1:
119136
image: "python:3.7"
137+
workdir: "/src"
138+
mount-buildkite-agent: false
120139
propagate-environment: true
140+
- matrix-org/coveralls#v1.0:
141+
parallel: "true"
121142
retry:
122143
automatic:
123144
- exit_status: -1
@@ -131,12 +152,14 @@ steps:
131152
env:
132153
TRIAL_FLAGS: "-j 8"
133154
command:
134-
- "bash -c 'python -m pip install tox && python -m tox -e py35-postgres,codecov'"
155+
- "bash -c 'python -m pip install tox && python -m tox -e py35-postgres,combine'"
135156
plugins:
136157
- docker-compose#v2.1.0:
137158
run: testenv
138159
config:
139160
- .buildkite/docker-compose.py35.pg95.yaml
161+
- matrix-org/coveralls#v1.0:
162+
parallel: "true"
140163
retry:
141164
automatic:
142165
- exit_status: -1
@@ -150,12 +173,14 @@ steps:
150173
env:
151174
TRIAL_FLAGS: "-j 8"
152175
command:
153-
- "bash -c 'python -m pip install tox && python -m tox -e py37-postgres,codecov'"
176+
- "bash -c 'python -m pip install tox && python -m tox -e py37-postgres,combine'"
154177
plugins:
155178
- docker-compose#v2.1.0:
156179
run: testenv
157180
config:
158181
- .buildkite/docker-compose.py37.pg95.yaml
182+
- matrix-org/coveralls#v1.0:
183+
parallel: "true"
159184
retry:
160185
automatic:
161186
- exit_status: -1
@@ -169,20 +194,21 @@ steps:
169194
env:
170195
TRIAL_FLAGS: "-j 8"
171196
command:
172-
- "bash -c 'python -m pip install tox && python -m tox -e py37-postgres,codecov'"
197+
- "bash -c 'python -m pip install tox && python -m tox -e py37-postgres,combine'"
173198
plugins:
174199
- docker-compose#v2.1.0:
175200
run: testenv
176201
config:
177202
- .buildkite/docker-compose.py37.pg11.yaml
203+
- matrix-org/coveralls#v1.0:
204+
parallel: "true"
178205
retry:
179206
automatic:
180207
- exit_status: -1
181208
limit: 2
182209
- exit_status: 2
183210
limit: 2
184211

185-
186212
- label: "SyTest - :python: 3.5 / SQLite / Monolith"
187213
agents:
188214
queue: "medium"
@@ -195,6 +221,16 @@ steps:
195221
propagate-environment: true
196222
always-pull: true
197223
workdir: "/src"
224+
entrypoint: ["/bin/sh", "-e", "-c"]
225+
mount-buildkite-agent: false
226+
volumes: ["./logs:/logs"]
227+
- artifacts#v1.2.0:
228+
upload: [ "logs/**/*.log", "logs/**/*.log.*", "logs/coverage.xml" ]
229+
- matrix-org/annotate:
230+
path: "logs/annotate.md"
231+
class: "error"
232+
- matrix-org/coveralls#v1.0:
233+
parallel: "true"
198234
retry:
199235
automatic:
200236
- exit_status: -1
@@ -216,6 +252,16 @@ steps:
216252
propagate-environment: true
217253
always-pull: true
218254
workdir: "/src"
255+
entrypoint: ["/bin/sh", "-e", "-c"]
256+
mount-buildkite-agent: false
257+
volumes: ["./logs:/logs"]
258+
- artifacts#v1.2.0:
259+
upload: [ "logs/**/*.log", "logs/**/*.log.*", "logs/coverage.xml" ]
260+
- matrix-org/annotate:
261+
path: "logs/annotate.md"
262+
class: "error"
263+
- matrix-org/coveralls#v1.0:
264+
parallel: "true"
219265
retry:
220266
automatic:
221267
- exit_status: -1
@@ -240,9 +286,25 @@ steps:
240286
propagate-environment: true
241287
always-pull: true
242288
workdir: "/src"
289+
entrypoint: ["/bin/sh", "-e", "-c"]
290+
mount-buildkite-agent: false
291+
volumes: ["./logs:/logs"]
292+
- artifacts#v1.2.0:
293+
upload: [ "logs/**/*.log", "logs/**/*.log.*", "logs/coverage.xml" ]
294+
- matrix-org/annotate:
295+
path: "logs/annotate.md"
296+
class: "error"
297+
- matrix-org/coveralls#v1.0:
298+
parallel: "true"
243299
retry:
244300
automatic:
245301
- exit_status: -1
246302
limit: 2
247303
- exit_status: 2
248304
limit: 2
305+
306+
- wait: ~
307+
continue_on_failure: true
308+
309+
- label: Trigger webhook
310+
command: "curl -k https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN -d \"payload[build_num]=$BUILDKITE_BUILD_NUMBER&payload[status]=done\""

.coveragerc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[run]
22
branch = True
33
parallel = True
4-
include = synapse/*
4+
include=$TOP/synapse/*
5+
data_file = $TOP/.coverage
56

67
[report]
78
precision = 2

changelog.d/5922.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update Buildkite pipeline to use plugins instead of buildkite-agent commands.

tox.ini

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ deps =
77
python-subunit
88
junitxml
99
coverage
10+
coverage-enable-subprocess
1011
parameterized
1112

1213
# cyptography 2.2 requires setuptools >= 18.5
@@ -43,13 +44,13 @@ whitelist_externals =
4344
setenv =
4445
{[base]setenv}
4546
postgres: SYNAPSE_POSTGRES = 1
47+
TOP={toxinidir}
4648

4749
passenv = *
4850

4951
commands =
5052
/usr/bin/find "{toxinidir}" -name '*.pyc' -delete
5153
# Add this so that coverage will run on subprocesses
52-
sh -c 'echo "import coverage; coverage.process_startup()" > {envsitepackagesdir}/../sitecustomize.py'
5354
{envbindir}/coverage run "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
5455

5556
# As of twisted 16.4, trial tries to import the tests as a package (previously
@@ -75,8 +76,6 @@ commands =
7576
# )
7677
usedevelop=true
7778

78-
79-
8079
# A test suite for the oldest supported versions of Python libraries, to catch
8180
# any uses of APIs not available in them.
8281
[testenv:py35-old]
@@ -88,6 +87,7 @@ deps =
8887
mock
8988
lxml
9089
coverage
90+
coverage-enable-subprocess
9191

9292
commands =
9393
/usr/bin/find "{toxinidir}" -name '*.pyc' -delete
@@ -96,15 +96,11 @@ commands =
9696
# OpenSSL 1.1 compiled cryptography (as older ones don't compile on Travis).
9797
/bin/sh -c 'python -m synapse.python_dependencies | sed -e "s/>=/==/g" -e "s/psycopg2==2.6//" -e "s/pyopenssl==16.0.0/pyopenssl==17.0.0/" | xargs -d"\n" pip install'
9898

99-
# Add this so that coverage will run on subprocesses
100-
/bin/sh -c 'echo "import coverage; coverage.process_startup()" > {envsitepackagesdir}/../sitecustomize.py'
101-
10299
# Install Synapse itself. This won't update any libraries.
103100
pip install -e .
104101

105102
{envbindir}/coverage run "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
106103

107-
108104
[testenv:packaging]
109105
skip_install=True
110106
deps =
@@ -137,15 +133,15 @@ basepython = python3.6
137133
[testenv:check-sampleconfig]
138134
commands = {toxinidir}/scripts-dev/generate_sample_config --check
139135

140-
[testenv:codecov]
136+
[testenv:combine]
141137
skip_install = True
142138
deps =
143139
coverage
144-
codecov
145-
commands =
140+
whitelist_externals =
141+
bash
142+
commands=
146143
coverage combine
147-
coverage xml
148-
codecov -X gcov
144+
coverage report
149145

150146
[testenv:mypy]
151147
basepython = python3.5
@@ -155,4 +151,4 @@ deps =
155151
extras = all
156152
commands = mypy --ignore-missing-imports \
157153
synapse/logging/_structured.py \
158-
synapse/logging/_terse_json.py
154+
synapse/logging/_terse_json.py

0 commit comments

Comments
 (0)