Skip to content

Commit c57752e

Browse files
authored
chore(dev): changes for developer ergonomics (pypi#10816)
* chore(dev): set web to depend on db When running `make tests`, the current expectation is that the user has executed `make serve` and the database container is running in already. This brings in all the other runtime dependencies, when all the tests need is a running database instance. Setting the `depends_on` flag tells docker-compose to start the db container first, any time we run a `web` container, and saves us the step of starting it ourselves in another shell. Signed-off-by: Mike Fiedler <[email protected]> * chore(dev): set elasticsearch to single-node The current settings for the elasticsearch container place the started node in "production, single node cluster" mode. This performs boostrap tests, one of which tests for virtual memory via the `sysctl` setting of `vm.max_map_count`. In certain Docker-in-Docker development environments, the end user may not have access to the underlying host settings, and cannot modify this setting. An alternative is to set the `discovery-type` to a single node, placing the service in "development mode", turning any bootstrap checks from errors to warnings. Refs: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/system-config.html#dev-vs-prod Refs: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/bootstrap-checks.html Originally reported in pypi#1511, related to pypi#4370 Signed-off-by: Mike Fiedler <[email protected]> * chore: enable context reporting in coverage coverage.py version 5.0 introduced the notion of measurement contexts. This adds details to the report to show: - how many times a given line was executed - which context executed a given line Enabling dynamic context measurement during the test execution adds test class/function contexts to the coverage data to be displayed on a given report output. Refs: https://coverage.readthedocs.io/en/6.3.2/contexts.html#dynamic-contexts Signed-off-by: Mike Fiedler <[email protected]> * chore(dev): enable web port to be set via env var Creating a port under 1024 often requires superuser privileges. In some environments this is disallowed. By using the built-in behavior from Docker Compose, a user can now set: WEB_PORT=8080 make serve and the web application will be made availabel on port 8080. The default remains port 80. Signed-off-by: Mike Fiedler <[email protected]>
1 parent d2cafdb commit c57752e

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

.coveragerc

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[run]
22
branch = True
3+
dynamic_context = test_function
34

45
source =
56
warehouse

bin/tests

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ set -x
3434

3535
# Actually run our tests.
3636
python -m coverage run -m pytest --strict-markers $COMMAND_ARGS
37-
python -m coverage html
37+
python -m coverage html --show-contexts
3838
python -m coverage report -m --fail-under 100

docker-compose.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ services:
4747
image: elasticsearch:7.10.1
4848
environment:
4949
- xpack.security.enabled=false
50-
- node.name=node-1
51-
- cluster.initial_master_nodes=node-1
50+
- discovery.type=single-node
5251
ulimits:
5352
nofile:
5453
soft: 65536
@@ -90,7 +89,9 @@ services:
9089
- simple:/var/opt/warehouse/simple
9190
- ./bin:/opt/warehouse/src/bin:z
9291
ports:
93-
- "80:8000"
92+
- "${WEB_PORT:-80}:8000"
93+
depends_on:
94+
- db
9495

9596
files:
9697
build:

docs/development/getting-started.rst

+12
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ If the port is in use, the command will produce output, and you will need to
131131
determine what is occupying the port and shut down the corresponding service.
132132
Otherwise, the port is available for Warehouse to use, and you can continue.
133133

134+
Alternately, you may set the ``WEB_HOST`` environment variable for
135+
docker-compose to use instead. An example:
136+
137+
.. code-block:: console
138+
139+
export WEB_HOST=8080
140+
make ...
141+
142+
# or inline:
143+
WEB_HOST=8080 make ...
134144
135145
Building the Warehouse Container
136146
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -265,6 +275,8 @@ At this point all the services are up, and web container is listening on port
265275
`this bug report <https://bugzilla.mozilla.org/show_bug.cgi?id=1262842>`_
266276
for more info).
267277

278+
If you've set a different port via the ``WEB_HOST`` environment variable,
279+
use that port instead.
268280

269281
Logging in to Warehouse
270282
^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)