Skip to content

Merge pull request #1580 from ImageMarkup/disable-registration #4009

Merge pull request #1580 from ImageMarkup/disable-registration

Merge pull request #1580 from ImageMarkup/disable-registration #4009

Workflow file for this run

name: ci
on:
pull_request:
push:
branches:
- master
permissions:
contents: read
concurrency:
# Only run the latest workflow per-branch
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-24.04
services:
postgres:
image: pgvector/pgvector:0.8.6-pg18
env:
POSTGRES_DB: django
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd "pg_isready --username postgres"
--health-start-period 30s
--health-start-interval 2s
ports:
- 5432:5432
elasticsearch:
image: elasticsearch:9.4.4
env:
ES_JAVA_OPTS: "-Xms250m -Xmx750m"
discovery.type: single-node
xpack.security.enabled: "true"
ELASTIC_PASSWORD: elastic
options: >-
--health-cmd "curl --fail --user elastic:elastic http://localhost:9200/"
--health-start-period 30s
--health-start-interval 2s
ports:
- 9200:9200
rabbitmq:
image: rabbitmq:4.3-management-alpine
options: >-
--health-cmd "rabbitmq-diagnostics ping"
--health-start-period 30s
--health-start-interval 2s
ports:
- 5672:5672
minio:
# This image does not require any command arguments (which GitHub Actions don't support)
image: bitnamilegacy/minio:latest
env:
MINIO_ROOT_USER: minioAccessKey
MINIO_ROOT_PASSWORD: minioSecretKey
options: >-
--health-cmd "mc ready local"
--health-timeout 1s
--health-start-period 30s
--health-start-interval 2s
ports:
- 9000:9000
redis:
image: redis:alpine
options: >-
--health-cmd "redis-cli ping"
--health-start-period 30s
--health-start-interval 2s
ports:
- 6379:6379
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
- name: Install Node.js
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: 24
- name: Increase maintenance_work_mem for pgvector
# The imageembedding IVFFlat index (lists=1000, dimensions=3584) requires
# ~350 MB to rebuild. This happens during test TRUNCATE, greenmask restores,
# and any bulk reindex. The default maintenance_work_mem (64 MB) is too low.
# GH Actions service containers don't support custom commands, so we use
# ALTER SYSTEM instead (docker-compose.yml uses a command-line flag).
# Use multiple -c flags to avoid a transaction block, which "ALTER SYSTEM" doesn't support.
run: psql -c "ALTER SYSTEM SET maintenance_work_mem = '512MB'" -c "SELECT pg_reload_conf();"
env:
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
PGDATABASE: django
- name: Build frontend assets
run: |
npm ci
npm run build
- name: Run tests
run: |
uv run --locked tox
env:
DJANGO_DATABASE_URL: postgres://postgres:postgres@localhost:5432/django
DJANGO_ISIC_ELASTICSEARCH_URL: http://elastic:elastic@localhost:9200
DJANGO_CELERY_BROKER_URL: amqp://localhost:5672/
DJANGO_MINIO_STORAGE_URL: http://minioAccessKey:minioSecretKey@localhost:9000/django-storage
DJANGO_CACHE_URL: redis://localhost:6379/0
- name: Validate greenmask config against the schema
# Catch changes that can no longer legally run against our schema (a
# renamed/dropped column, a broken subset condition, etc.) by
# validating and dumping against a freshly-migrated database. Any
# change to models or migrations can invalidate the greenmask config,
# so this runs on every PR. greenmask only exits non-zero on fatal
# errors (e.g. a transformer pointed at a column that no longer
# exists), not on softer warnings; --dump-only exercises the subset
# conditions and transformers as real SQL/dump operations without
# Heroku or the restore step.
run: |
# Install greenmask directly from the GitHub release rather than the
# greenmask.io install script, which rate-limits CI runners (HTTP 429).
curl -fsSL https://github.com/GreenmaskIO/greenmask/releases/download/v0.2.22/greenmask-linux-amd64.tar.gz \
| sudo tar xz -C /usr/local/bin greenmask
# The runner's default postgres client is older than the pg18 service
# container, and pg_dump aborts on a server version mismatch. The
# Ubuntu repos don't carry 18, so add the PGDG repo first.
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -fsSL -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update && sudo apt-get install --yes --no-install-recommends postgresql-client-18
# The runner image also ships an older postgres server, and Ubuntu's
# /usr/bin/pg_dump wrapper resolves to that cluster's version, so put
# the real 18 binaries ahead of the wrapper.
export PATH="/usr/lib/postgresql/18/bin:$PATH"
./manage.py migrate
greenmask validate --warnings --strict
dev/greenmask-dump.sh --dump-only
env:
GREENMASK_CONFIG: .greenmask/config.yml
# Used by .greenmask/config.yml's dump dbname and Django's database.
DATABASE_URL: postgres://postgres:postgres@localhost:5432/django
DJANGO_DATABASE_URL: postgres://postgres:postgres@localhost:5432/django
DJANGO_SETTINGS_MODULE: isic.settings.testing
DJANGO_ISIC_ELASTICSEARCH_URL: http://elastic:elastic@localhost:9200
DJANGO_CELERY_BROKER_URL: amqp://localhost:5672/
DJANGO_MINIO_STORAGE_URL: http://minioAccessKey:minioSecretKey@localhost:9000/django-storage
DJANGO_CACHE_URL: redis://localhost:6379/0
# The transformer templates reference env "SALT"; any value works here.
SALT: ci-test-salt