Skip to content

Commit d5d4070

Browse files
Add CI/CD and PDM to new indexer worker (#4497)
* Use PDM for idx worker and add to CI/CD * Try to update all snapshots Why did this not work??? * Force snapshot update using lowered diff tolerance The text was such a small portion of the screen that it would only fail _sometimes_ on the default maxPixelDiffRatio but only for the smallest screens, where the text takes up comparatively more of the pixels. On larger screens, it seems to never fail. I will create a follow up issue for this.
1 parent 2a8f665 commit d5d4070

File tree

13 files changed

+1024
-982
lines changed

13 files changed

+1024
-982
lines changed

.github/actions/load-img/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ inputs:
77
required: true
88

99
setup_images:
10-
default: "upstream_db ingestion_server catalog api api_nginx frontend"
10+
default: "upstream_db ingestion_server catalog_indexer_worker catalog api api_nginx frontend"
1111
description: Space-separated list of image names
1212

1313
runs:

.github/filters.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ ingestion_server:
2222
- docker/upstream_db/**
2323
- docker-compose.yml
2424
- load_sample_data.sh
25+
indexer_worker:
26+
- indexer_worker/**
27+
- docker/db/**
28+
- docker/es/**
29+
- docker/upstream_db/**
30+
- docker-compose.yml
31+
- load_sample_data.sh
2532
frontend:
2633
- frontend/**
2734
- packages/js/**

.github/workflows/ci_cd.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
changes: ${{ steps.paths-filter.outputs.changes }}
4141
catalog: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'catalog') }}
4242
ingestion_server: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'ingestion_server') }}
43+
indexer_worker: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'indexer_worker') }}
4344
api: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'api') }}
4445
frontend: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'frontend') }}
4546
documentation: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'documentation') }}
@@ -201,6 +202,7 @@ jobs:
201202
SEMANTIC_VERSION=${{ needs.get-image-tag.outputs.image_tag }}
202203
CATALOG_PY_VERSION=${{ steps.prepare-build-args.outputs.catalog_py_version }}
203204
CATALOG_AIRFLOW_VERSION=${{ steps.prepare-build-args.outputs.catalog_airflow_version }}
205+
INDEXER_WORKER_PY_VERSION=${{ steps.prepare-build-args.outputs.indexer_worker_py_version }}
204206
API_PY_VERSION=${{ steps.prepare-build-args.outputs.api_py_version }}
205207
INGESTION_PY_VERSION=${{ steps.prepare-build-args.outputs.ingestion_py_version }}
206208
FRONTEND_NODE_VERSION=${{ steps.prepare-build-args.outputs.frontend_node_version }}
@@ -316,6 +318,69 @@ jobs:
316318
just catalog/generate-docs dag true
317319
just catalog/generate-docs media-props true
318320
321+
##################
322+
# Indexer worker #
323+
##################
324+
325+
test-indexer-worker:
326+
name: Run tests for indexer worker
327+
if: |
328+
needs.get-changes.outputs.indexer_worker == 'true' ||
329+
needs.get-changes.outputs.ci_cd == 'true'
330+
runs-on: ubuntu-latest
331+
timeout-minutes: 15
332+
needs:
333+
- get-changes
334+
- build-images
335+
336+
steps:
337+
- name: Checkout repository
338+
uses: actions/checkout@v4
339+
340+
- name: Setup CI env
341+
uses: ./.github/actions/setup-env
342+
with:
343+
setup_python: false
344+
# Python is not needed to run the tests.
345+
setup_nodejs: false
346+
# Node.js is not needed to run the tests.
347+
install_recipe: ""
348+
349+
- name: Load Docker images
350+
uses: ./.github/actions/load-img
351+
with:
352+
run_id: ${{ github.run_id }}
353+
setup_images: upstream_db
354+
355+
# Sets build args specifying versions needed to build Docker image.
356+
- name: Prepare build args
357+
id: prepare-build-args
358+
run: |
359+
just versions | tee "$GITHUB_OUTPUT"
360+
361+
- name: Setup Docker Buildx
362+
uses: docker/setup-buildx-action@v3
363+
with:
364+
install: true
365+
366+
- name: Build indexer worker dev image
367+
uses: docker/build-push-action@v5
368+
with:
369+
context: indexer_worker
370+
target: indexer_worker
371+
push: false
372+
load: true
373+
tags: openverse-catalog_indexer_worker
374+
cache-from: type=gha,scope=indexer_worker_dev
375+
cache-to: type=gha,scope=indexer_worker_dev
376+
build-args: |
377+
INDEXER_WORKER_PY_VERSION=${{ steps.prepare-build-args.outputs.indexer_worker_py_version }}
378+
PDM_INSTALL_ARGS=--dev
379+
380+
- name: Run tests
381+
run: |
382+
just indexer_worker/test
383+
319384
####################
320385
# Ingestion server #
321386
####################

automations/python/workflows/set_matrix_images.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ def ser_set(x):
6161
),
6262
"catalog": Include(image="catalog", target="cat"),
6363
"ingestion_server": Include(image="ingestion_server", target="ing"),
64+
"catalog_indexer_worker": Include(
65+
image="catalog_indexer_worker",
66+
target="indexer_worker",
67+
context="indexer_worker",
68+
build_args="PDM_INSTALL_ARGS=--prod",
69+
),
6470
"api": Include(
6571
image="api",
6672
target="api",
@@ -94,6 +100,9 @@ def ser_set(x):
94100
if "ingestion_server" in changes:
95101
build_matrix["image"] |= {"upstream_db", "ingestion_server", "api"}
96102
publish_matrix["image"].add("ingestion_server")
103+
if "indexer_worker" in changes:
104+
build_matrix["image"] |= {"upstream_db", "catalog_indexer_worker", "api"}
105+
publish_matrix["image"].add("catalog_indexer_worker")
97106
if "api" in changes:
98107
build_matrix["image"] |= {"upstream_db", "ingestion_server", "api", "api_nginx"}
99108
publish_matrix["image"] |= {"api", "api_nginx"}

indexer_worker/.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
*
33
!indexer_worker
44
!gunicorn*
5-
!Pipfile*
5+
!pyproject.toml
6+
!pdm.lock

indexer_worker/Dockerfile

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
11
# syntax=docker/dockerfile:1
22

33
# Automatically build image using Python version specified in the `Pipfile`.
4-
ARG CATALOG_PY_VERSION
4+
ARG INDEXER_WORKER_PY_VERSION
55

66
##################
77
# Python builder #
88
##################
99

10-
FROM docker.io/python:${CATALOG_PY_VERSION} as builder
10+
FROM docker.io/python:${INDEXER_WORKER_PY_VERSION} as builder
1111

1212
# Container optimizations
1313
ENV PYTHONUNBUFFERED=1
1414
ENV PIP_NO_CACHE_DIR=1
1515
ENV PIP_NO_COLOR=1
1616

17-
# Activate the virtualenv
18-
ENV PATH="/venv/bin:$PATH"
19-
2017
# - Install system packages needed for building Python dependencies
21-
# - Create a virtualenv inside `/venv`
22-
# - Install Pipenv to install Python dependencies
18+
# - Install PDM to install Python dependencies
2319
RUN apt-get update \
2420
&& apt-get install -y python3-dev \
2521
&& rm -rf /var/lib/apt/lists/* \
26-
&& python -m venv /venv \
27-
&& pip install --upgrade pipenv
22+
&& pip install pdm~=2.14
2823

2924
# Copy the Pipenv files into the container
30-
COPY Pipfile Pipfile.lock ./
25+
COPY pyproject.toml pdm.lock ./
26+
27+
# Pass additional arguments when installing Python packages with PDM
28+
ARG PDM_INSTALL_ARGS='--no-editable'
3129

32-
# Install Python dependencies system-wide (uses the active virtualenv)
33-
RUN pipenv install --system --deploy --dev
30+
# Install Python dependencies into a new virtualenv
31+
RUN pdm install --check --frozen-lockfile $PDM_INSTALL_ARGS
3432

3533
####################
3634
# Indexer worker #
3735
####################
3836

39-
FROM docker.io/python:${CATALOG_PY_VERSION}-slim as ing
37+
FROM docker.io/python:${INDEXER_WORKER_PY_VERSION}-slim as indexer_worker
4038

4139
LABEL org.opencontainers.image.source="https://github.com/WordPress/openverse"
4240

@@ -46,7 +44,7 @@ ENV PIP_NO_CACHE_DIR=1
4644
ENV PIP_NO_COLOR=1
4745

4846
# Activate the virtualenv
49-
ENV PATH="/venv/bin:$PATH"
47+
ENV PATH="/.venv/bin:$PATH"
5048

5149
ENV PYTHONPATH="$PYTHONPATH:/indexer_worker/"
5250
# TLDEXTRACT fails to cache in /home/supervisord, set its cache to /tmp instead
@@ -55,7 +53,7 @@ ENV TLDEXTRACT_CACHE="/tmp/python-tldextract"
5553
WORKDIR /indexer_worker
5654

5755
# Copy virtualenv from the builder image
58-
COPY --from=builder /venv /venv
56+
COPY --from=builder /.venv /.venv
5957

6058
# - Install system packages needed for running Python dependencies
6159
# - libpq-dev: required by `psycopg2`

indexer_worker/Pipfile

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)