-
-
Notifications
You must be signed in to change notification settings - Fork 4k
/
action.yml
201 lines (178 loc) · 7.58 KB
/
action.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
190
191
192
193
194
195
196
197
198
199
200
201
# NOTE: Do not rely on `make` commands here as this action is used across different repos
# where the Makefile will not be available
name: 'Sentry Setup'
description: 'Sets up a Sentry test environment'
inputs:
workdir:
description: 'Directory where the sentry source is located'
required: false
default: '.'
snuba:
description: 'Is snuba required?'
required: false
default: 'false'
clickhouse:
description: 'Is clickhouse required?'
required: false
default: 'false'
kafka:
description: 'Is kafka required?'
required: false
default: 'false'
chartcuterie:
description: 'Is chartcuterie required?'
required: false
default: 'false'
bigtable:
description: 'Is bigtable required?'
required: false
default: 'false'
python-version:
description: 'python version to install'
required: false
default: '3.8.13'
pg-version:
description: 'PostgreSQL version to use'
default: '9.6'
required: false
outputs:
yarn-cache-dir:
description: 'Path to yarn cache'
value: ${{ steps.config.outputs.yarn-cache-dir }}
acceptance-dir:
description: 'Path to acceptance visual snapshot artifacts'
value: ${{ steps.config.outputs.acceptance-dir }}
matrix-instance-number:
description: 'The matrix instance number (starting at 1)'
value: ${{ steps.config.outputs.matrix-instance-number }}
matrix-instance-total:
description: 'Reexport of MATRIX_INSTANCE_TOTAL.'
value: ${{ steps.config.outputs.matrix-instance-total }}
runs:
using: 'composite'
steps:
- name: Setup default environment variables
shell: bash
env:
MATRIX_INSTANCE: ${{ matrix.instance }}
# XXX: We should be using something like len(strategy.matrix.instance) (not possible atm)
# If you have other things like python-version: [foo, bar, baz] then the sharding logic
# isn't right because job-total will be 3x larger and you'd never run 2/3 of the tests.
# MATRIX_INSTANCE_TOTAL: ${{ strategy.job-total }}
run: |
# Only set `MIGRATIONS_TEST_MIGRATE` if it is not already set (or if it's an empty string)
if [ -z $MIGRATIONS_TEST_MIGRATE ]; then
echo "MIGRATIONS_TEST_MIGRATE=0" >> $GITHUB_ENV
fi
echo "PIP_DISABLE_PIP_VERSION_CHECK=on" >> $GITHUB_ENV
echo "PY_COLORS=1" >> "$GITHUB_ENV"
echo "SENTRY_SKIP_BACKEND_VALIDATION=1" >> $GITHUB_ENV
### node configuration ###
echo "NODE_ENV=development" >> $GITHUB_ENV
echo "NODE_OPTIONS=--max-old-space-size=4096" >> $GITHUB_ENV
### pytest-sentry configuration ###
echo "PYTEST_SENTRY_DSN=https://[email protected]/2423079" >> $GITHUB_ENV
echo "PYTEST_ADDOPTS=--reruns 5" >> $GITHUB_ENV
# Configure a different release version, otherwise it defaults to the
# commit sha which will conflict with our actual prod releases. This is a
# confusing experience because it looks like these are "empty" releases
# because no commits are attached and associates the release with our
# javascript + sentry projects.
echo "SENTRY_RELEASE=ci@$GITHUB_SHA" >> $GITHUB_ENV
# this handles pytest test sharding
if [ "$MATRIX_INSTANCE" ]; then
if ! [ "$MATRIX_INSTANCE_TOTAL" ]; then
echo "MATRIX_INSTANCE_TOTAL is required."
exit 1
fi
echo "TEST_GROUP=$MATRIX_INSTANCE" >> $GITHUB_ENV
echo "TOTAL_TEST_GROUPS=$MATRIX_INSTANCE_TOTAL" >> $GITHUB_ENV
fi
# This records failures on master to sentry in order to detect flakey tests, as it's
# expected that people have failing tests on their PRs
[ "$GITHUB_REF" = "refs/heads/master" ] && echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV || true
- name: Setup python
uses: actions/setup-python@b4fe97ecda6b7a5fcd2448cdbf6a8fc76b3bedb0
with:
python-version: ${{ inputs.python-version }}
cache: pip
cache-dependency-path: ${{ inputs.workdir }}/requirements-dev-frozen.txt
- name: Set up outputs
id: config
env:
MATRIX_INSTANCE: ${{ matrix.instance }}
shell: bash
run: |
echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
echo "::set-output name=matrix-instance-number::$(($MATRIX_INSTANCE+1))"
echo "::set-output name=matrix-instance-total::$(($MATRIX_INSTANCE_TOTAL))"
echo "::set-output name=acceptance-dir::.artifacts/visual-snapshots/acceptance"
- name: Install python dependencies
shell: bash
env:
# This is necessary when other repositories (e.g. relay) want to take advantage of this workflow
# without needing to fork it. The path needed is the one where setup.py is located
WORKDIR: ${{ inputs.workdir }}
run: |
cd "$WORKDIR"
python setup.py install_egg_info
# We need to install editable otherwise things like check migration will fail.
pip install -r requirements-dev-frozen.txt & \
SENTRY_LIGHT_BUILD=1 pip install --no-deps -e . & \
wait
cd -
- name: Start devservices
shell: bash
env:
NEED_KAFKA: ${{ inputs.kafka }}
NEED_SNUBA: ${{ inputs.snuba }}
NEED_CLICKHOUSE: ${{ inputs.clickhouse }}
NEED_BIGTABLE: ${{ inputs.bigtable }}
NEED_CHARTCUTERIE: ${{ inputs.chartcuterie }}
WORKDIR: ${{ inputs.workdir }}
PG_VERSION: ${{ inputs.pg-version }}
run: |
sentry init
# redis, postgres are needed for almost every code path.
services='redis postgres'
if [ "$NEED_CLICKHOUSE" = "true" ] || [ "$NEED_SNUBA" = "true" ]; then
services="${services} clickhouse"
fi
if [ "$NEED_SNUBA" = "true" ]; then
services="${services} snuba"
fi
if [ "$NEED_BIGTABLE" = "true" ]; then
echo "BIGTABLE_EMULATOR_HOST=127.0.0.1:8086" >> $GITHUB_ENV
services="${services} bigtable"
fi
if [ "$NEED_CHARTCUTERIE" = "true" ]; then
services="${services} chartcuterie"
fi
sentry devservices up $services &
# TODO: Use devservices kafka. See https://github.com/getsentry/sentry/pull/20986#issuecomment-704510570
if [ "$NEED_KAFKA" = "true" ]; then
# This is *not* the production version. Unclear reason as to why this was chosen
# https://github.com/getsentry/ops/blob/c823e62f930ecc6c97bb08898c71e49edc7232f6/cookbooks/getsentry/attributes/default.rb#L631
docker run \
--name sentry_zookeeper \
-d --network host \
-e ZOOKEEPER_CLIENT_PORT=2181 \
confluentinc/cp-zookeeper:4.1.0 \
&
# This is the production version; do not change w/o changing it there as well
# https://github.com/getsentry/ops/blob/c823e62f930ecc6c97bb08898c71e49edc7232f6/cookbooks/getsentry/attributes/default.rb#L643
docker run \
--name sentry_kafka \
-d --network host \
-e KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:2181 \
-e KAFKA_LISTENERS=INTERNAL:https://0.0.0.0:9093,EXTERNAL:https://0.0.0.0:9092 \
-e KAFKA_ADVERTISED_LISTENERS=INTERNAL:https://127.0.0.1:9093,EXTERNAL:https://127.0.0.1:9092 \
-e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT \
-e KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL \
-e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
confluentinc/cp-kafka:5.1.2 \
&
fi
wait
docker ps -a
./$WORKDIR/scripts/devservices-healthcheck.sh