Skip to content
Martin Hradil edited this page Dec 23, 2023 · 20 revisions

guidelines
project wiki
Devel setup

Prelude

First set up your github account to

And remember to sign any commits pushed to the galaxy_ng repo.

Install

Fork backend and the UI, and clone...

GITHUB_USER=himdel # update accordingly

git clone git@github.com:$GITHUB_USER/galaxy_ng.git
git clone git@github.com:$GITHUB_USER/ansible-hub-ui.git

cd galaxy_ng
git remote add upstream https://github.com/ansible/galaxy_ng

cd ../ansible-hub-ui
git remote add upstream https://github.com/ansible/ansible-hub-ui

Set up..

# copy the example env
cd galaxy_ng
cp .compose.env.example .compose.env

# build, run migrations, import initial data
make docker/all

# change admin password if needed
./compose run --rm api manage reset-admin-password --password admin

./compose down

Get more than initial data

https://github.com/himdel/ansible-hub-ui/wiki/Getting-Data

Rebuild after update

cd galaxy_ng
./compose down # if running
./compose build
make docker/migrate
./compose down

Run

The backend...

cd galaxy_ng
./compose up

Just ^C to stop (foreground), or ./compose down when running ./compose up -d (background).

...And the UI:

cd ansible-hub-ui
npm run start-standalone

Run integration tests

tests readme

Create ansible-hub-ui/test/cypress.env.json:

{
    "prefix": "/api/automation-hub/",
    "username": "admin",
    "password": "admin"
}

(Don't forget the trailing slash ;).)

Run

# while backend & ui are running
cd ansible-hub-ui/test # test/
npm ci
npm run cypress:chrome # or cypress:chromium or cypress:firefox

Run python console

cd galaxy_ng
./compose run --rm api manage shell # skip shell to see more tasks

Run database console, dump database

cd galaxy_ng
# compose up must be running already
./compose exec postgres psql -U galaxy_ng galaxy_ng

the credentials come from galaxy_ng/dev/common/postgres.env.

For pg_dump:

cd galaxy_ng
# compose up must be running already
./compose exec postgres pg_dump -U galaxy_ng galaxy_ng -Fc > pg.dump

Ang pg_restore:

cd galaxy_ng
# compose must be down
./compose up -d postgres redis
./compose exec -T postgres pg_restore -U galaxy_ng -d galaxy_ng -cC /dev/stdin < pg.dump
./compose run --rm api manage migrate
./compose down

FIXME: does this ^ work yet? needs pg superuser?

Also, since https://github.com/ansible/galaxy_ng/pull/1281:

# create a database dump and save it to db_snapshots/{$NAME:-galaxy}.backup
make docker/db_snapshot
# restore the database from db_snapshots/${NAME:-galaxy}.backup
make docker/db_restore

oci-env db snapshot/restore:

oci-env db snapshot
oci-env db restore -f insights-fixture
oci-env pulpcore-manager migrate
oci-env poll

Run a second/third environment

PR

cd galaxy_ng
./compose down  # can't run both at the same time
export DEV_IMAGE_SUFFIX=any_unique_string
./compose build
# see "load initial data"..
./compose up
unset DEV_IMAGE_SUFFIX

Cleanup

cd galaxy_ng
./compose down -v # stop and drop data
# see "load initial data" above

or

docker system prune -v # remove all built containers and data
# see "build" and "load initial data" above

Debugging pulp workers

http://localhost:5001/pulp/api/v3/status/

Debugging SQL

diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml
index 83ce328..962a67b 100644
--- a/dev/docker-compose.yml
+++ b/dev/docker-compose.yml
@@ -111,6 +111,7 @@ services:
       - "5432:5432"
     env_file:
       - './common/postgres.env'
+    command: 'postgres -c log_destination=stderr -c log_min_duration_statement=0 -c log_statement=all'
     volumes:
       - "pg_data:/var/lib/postgresql/data"
 

Common errors

VersionConflict during ./compose up: `pkg_resources.VersionConflict: (pulp-ansible 0.7.0 (/venv/lib/python3.6/site-packages), Requirement.parse('pulp-ansible==0.7.1')) Solution: rebuild

Hang during ./compose build (but not the ~10 minutes on chown): check the firewall is allowing connections betweeen docker containers, or disable firewall

Merge locale updates

UI:

git checkout upstream/stable-4.6 -- locale/ # or wherever from
npm run gettext:extract
npm run gettext:compile

API:

git checkout upstream/stable-4.6 -- galaxy_ng/locale/ # or wherever from
make docker/translations

Update cloud menus

See https://github.com/RedHatInsights/chrome-service-backend/pull/66/files. Each dir corresponds to a different stage/prod, stable/beta combination.

(Used to be https://github.com/RedHatInsights/cloud-services-config/pull/863/ , with branches per combination.)