Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install awx collection from branch for operator ci #15616

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ jobs:
working-directory: awx-operator
run: |
python3 -m pip install -r molecule/requirements.txt
python3 -m pip install PyYAML # for awx/tools/scripts/rewrite-awx-operator-requirements.py
$(realpath ../awx/tools/scripts/rewrite-awx-operator-requirements.py) molecule/requirements.yml $(realpath ../awx)
ansible-galaxy collection install -r molecule/requirements.yml
sudo rm -f $(which kustomize)
make kustomize
Expand Down
40 changes: 40 additions & 0 deletions tools/scripts/rewrite-awx-operator-requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3

import yaml
import sys


AWX_ENTRY = 'https://github.com/ansible/awx.git#/awx_collection/'


def load_yaml_file(fname):
with open(fname, 'r') as file:
data = yaml.safe_load(file)
return data


def write_yaml_file(fname, data):
with open(fname, 'w') as file:
yaml.dump(data, file)


def replace_awx(data, path):
for entry in data['collections']:
if entry['name'] == AWX_ENTRY or entry['name'] == 'awx.awx':
chrismeyersfsu marked this conversation as resolved.
Show resolved Hide resolved
entry['name'] = f'file://{path}#/awx_collection/'
chrismeyersfsu marked this conversation as resolved.
Show resolved Hide resolved
entry['type'] = 'git'
entry.pop('version', None)
return data

raise ValueError(f"Failed to find {AWX_ENTRY} in {data}")


def run(fname, awx_path):
write_yaml_file(fname, replace_awx(load_yaml_file(fname), awx_path))


if __name__ == "__main__":
if len(sys.argv) == 3:
run(sys.argv[1], sys.argv[2])
else:
print(f"Usage: {sys.argv[0]} <awx-operator-molecule-requirements.yml> <awx-git-path>", file=sys.stderr)
Loading