zuul-jobs/test-playbooks/python/upload-pypi.yaml
Ian Wienand e0a2b647a6 test/upload-pypi : install venv
When we added this test I used ensure-pip in the ensure-twine role to
pull in the pip dependency.  But we soon realised that ensure-twine
ran in a rootless context so couldn't install packages, and reverted
it with I2cf4224228860b8a2cddd360636bb8633967b07e.

However, this testing wasn't fixed up.  Use ensure-pip in the test
playbook before we run the test, and add a note to ensure-twine that
it runs without privileges.

Change-Id: I6aef14b188dce8c4de774b09ddad718fec8fbf6c
2022-07-27 10:54:30 +10:00

67 lines
2.0 KiB
YAML

- hosts: all
tasks:
- name: Ensure pip works for ensure-twine
include_role:
name: ensure-pip
- name: Install twine
include_role:
name: ensure-twine
- name: Setup role failure var
set_fact:
_role_failed: false
- name: Wrap arg failure
block:
- name: Check for argument failure
include_role:
name: upload-pypi
vars:
pypi_info:
username: a_user
api_token: a_token
rescue:
- name: Mark role as failed
set_fact:
_role_failed: true
- name: Check role failed
fail:
msg: 'upload-pypi did not fail as it should'
when: _role_failed is not true
# We tag this with the unix timestamp so that the upload always
# has an increasing version number.
- name: Import sandbox project
shell: |
git clone https://opendev.org/opendev/sandbox
pushd sandbox
git tag $(date '+%s')
python3 setup.py bdist_wheel
args:
executable: '/bin/bash'
# This value is restricted to uploading the sandbox package to
# test.pypi.org; it is not kept in plain text to avoid things that
# grep for accidentally committed tokens finding it, but it is not
# particularly secret. OpenDev admins can revoke it from the
# "openstackci" test.pypi.org user if there is an issue.
- name: Set API token
set_fact:
_api_token: |
cHlwaS1BZ0VOZEdWemRDNXdlWEJwTG05eVp3SWtOMk0wTmpBMU9HSXRORGszTVMwME9ERTRMV0kx
Tm1NdFpEUTNNalJsWmpneE16TTRBQUk0ZXlKd1pYSnRhWE56YVc5dWN5STZJSHNpY0hKdmFtVmpk
SE1pT2lCYkluTmhibVJpYjNnaVhYMHNJQ0oyWlhKemFXOXVJam9nTVgwQUFBWWdmTGN1cHNaeWw3
NkI0Ri1Bd3FDR19VZHlNSWVMQzRHWHZTUjhSalEyQlJnCg==
- name: Upload sandbox
include_role:
name: upload-pypi
vars:
pypi_info:
api_token: '{{ _api_token | b64decode }}'
repository: testpypi
pypi_path: '{{ ansible_user_dir }}/sandbox/dist'