Clark Boylan 4c5160641f Run the Gerritlib Jeepyb Gerrit integration job on Noble
Noble has python 3.12 which is what we're trying to move our Gerrit
container images to. Update testing here to ensure we're covering this
python runtime before we update production.

We need to change how we install jeepyb and gerritlib in testing to
accomodate restrictions on global pip installs with newer python.

Change-Id: I21053ee8f646d1ab4abdfd606ac935d94bcf4923
2025-03-14 10:06:43 -07:00

108 lines
4.2 KiB
YAML

- hosts: all
roles:
- name: ensure-docker
tasks:
# Configure Jeepyb and Gerritlib
- name: Create jeepyb git directory
file:
state: directory
path: "/tmp/jeepyb-git"
- name: Create jeepyb cache directory
file:
state: directory
path: "/tmp/jeepyb-cache"
- name: Install jeepyb
pip:
name: /home/zuul/src/opendev.org/opendev/jeepyb
virtualenv: /home/zuul/venv
virtualenv_command: "python3 -m venv"
- name: Install gerritlib
# Install after Jeepyb so that we don't use gerritlib from pypi
pip:
name: /home/zuul/src/opendev.org/opendev/gerritlib
virtualenv: /home/zuul/venv
virtualenv_command: "python3 -m venv"
# Run a gerrit
- name: Install docker compose
package:
name: docker-compose-plugin
become: true
- name: Run docker compose up
shell:
cmd: docker compose up -d
chdir: src/opendev.org/opendev/gerritlib/tools/
- name: Wait for Gerrit Admin user to be created
uri:
url: http://localhost:8080/a/accounts/admin/sshkeys
method: GET
user: admin
password: secret
register: result
until: result.status == 200 and result.redirected == false
delay: 1
retries: 120
- name: fetch ssh host keys from gerrit
shell: ssh-keyscan -p 29418 127.0.0.1 >> ~/.ssh/known_hosts
- name: Set perms on new ssh private key
become: true
file:
path: src/opendev.org/opendev/gerritlib/tools/sshkey/admin
owner: zuul
group: zuul
- name: Set perms on new ssh public key
become: true
file:
path: src/opendev.org/opendev/gerritlib/tools/sshkey/admin.pub
owner: zuul
group: zuul
# Configure git
- name: Set git user name
command: git config --global user.name Zuul
- name: Set git user email
command: git config --global user.email admin@example.com
# Test jeepyb and gerritlib
- name: Manage single gerrit project
shell:
cmd: PROJECTS_INI=tools/projects.ini PROJECTS_YAML=tools/projects.yaml /home/zuul/venv/bin/manage-projects -d test/test-repo-1
chdir: src/opendev.org/opendev/gerritlib
- name: Manage all gerrit projects
shell:
cmd: PROJECTS_INI=tools/projects.ini PROJECTS_YAML=tools/projects.yaml /home/zuul/venv/bin/manage-projects -d
chdir: src/opendev.org/opendev/gerritlib
- name: Change test-repo-2 acls but don't change groups
# Lineinfile only replaces the last match so we do this twice
lineinfile:
path: src/opendev.org/opendev/gerritlib/tools/projects.yaml
regexp: '^ acl-config: tools/acls/test/test.config'
line: ' acl-config: tools/acls/test/test2.config'
- name: Change test-repo-1 acls but don't change groups
# Lineinfile only replaces the last match so we do this twice
lineinfile:
path: src/opendev.org/opendev/gerritlib/tools/projects.yaml
regexp: '^ acl-config: tools/acls/test/test.config'
line: ' acl-config: tools/acls/test/test2.config'
- name: Update single gerrit project with new acl
shell:
cmd: PROJECTS_INI=tools/projects.ini PROJECTS_YAML=tools/projects.yaml /home/zuul/venv/bin/manage-projects -d test/test-repo-1
chdir: src/opendev.org/opendev/gerritlib
- name: Manage all gerrit projects again after acl update
shell:
cmd: PROJECTS_INI=tools/projects.ini PROJECTS_YAML=tools/projects.yaml /home/zuul/venv/bin/manage-projects -d
chdir: src/opendev.org/opendev/gerritlib
- name: Check test-repo-1 exists
shell:
cmd: ssh -i tools/sshkey/admin -p 29418 admin@127.0.0.1 gerrit ls-projects | grep test-repo-1
chdir: src/opendev.org/opendev/gerritlib
- name: Check test-repo-2 exists
shell:
cmd: ssh -i tools/sshkey/admin -p 29418 admin@127.0.0.1 gerrit ls-projects | grep test-repo-2
chdir: src/opendev.org/opendev/gerritlib
- name: Check test-repo-3 does not exist
shell:
cmd: ssh -i tools/sshkey/admin -p 29418 admin@127.0.0.1 gerrit ls-projects | grep -v test-repo-3
chdir: src/opendev.org/opendev/gerritlib