mirror of
https://github.com/ansible-collections/community.routeros.git
synced 2025-07-18 01:44:38 +02:00
[stable-1] Use import galaxy workflow from ansible-collections/community.docker#754 (#250)
* Use import galaxy workflow from https://github.com/ansible-collections/community.docker/pull/754. (#249)
(cherry picked from commit 3777b283b2
)
* Install collection requirements.
This commit is contained in:
parent
37bd2c8f14
commit
e920e800eb
2 changed files with 65 additions and 23 deletions
7
.github/workflows/extra-tests.yml
vendored
7
.github/workflows/extra-tests.yml
vendored
|
@ -34,9 +34,12 @@ jobs:
|
||||||
run: pip install https://github.com/ansible/ansible/archive/stable-2.12.tar.gz --disable-pip-version-check
|
run: pip install https://github.com/ansible/ansible/archive/stable-2.12.tar.gz --disable-pip-version-check
|
||||||
|
|
||||||
- name: Install collection dependencies
|
- name: Install collection dependencies
|
||||||
run: git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ./ansible_collections/community/internal_test_tools
|
run: |
|
||||||
|
git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ./ansible_collections/community/internal_test_tools
|
||||||
|
git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.netcommon.git ./ansible_collections/ansible/netcommon
|
||||||
|
git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.utils.git ./ansible_collections/ansible/utils
|
||||||
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429)
|
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429)
|
||||||
# run: ansible-galaxy collection install community.internal_test_tools -p .
|
# run: ansible-galaxy collection install community.internal_test_tools ansible.netcommon -p .
|
||||||
|
|
||||||
- name: Run sanity tests
|
- name: Run sanity tests
|
||||||
run: ../../community/internal_test_tools/tools/run.py --color
|
run: ../../community/internal_test_tools/tools/run.py --color
|
||||||
|
|
79
.github/workflows/import-galaxy.yml
vendored
79
.github/workflows/import-galaxy.yml
vendored
|
@ -1,5 +1,5 @@
|
||||||
name: import-galaxy
|
name: import-galaxy
|
||||||
on:
|
'on':
|
||||||
# Run CI against all pushes (direct commits, also merged PRs) to main, and all Pull Requests
|
# Run CI against all pushes (direct commits, also merged PRs) to main, and all Pull Requests
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
@ -7,11 +7,6 @@ on:
|
||||||
- stable-*
|
- stable-*
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
env:
|
|
||||||
# Adjust this to your collection
|
|
||||||
NAMESPACE: community
|
|
||||||
COLLECTION_NAME: routeros
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-collection:
|
build-collection:
|
||||||
name: Build collection artifact
|
name: Build collection artifact
|
||||||
|
@ -31,17 +26,40 @@ jobs:
|
||||||
run: pip install https://github.com/ansible/ansible/archive/stable-2.12.tar.gz --disable-pip-version-check
|
run: pip install https://github.com/ansible/ansible/archive/stable-2.12.tar.gz --disable-pip-version-check
|
||||||
|
|
||||||
- name: Make sure galaxy.yml has version entry
|
- name: Make sure galaxy.yml has version entry
|
||||||
run: >-
|
shell: python
|
||||||
python -c
|
id: collection-metadata
|
||||||
'import yaml ;
|
run: |
|
||||||
f = open("galaxy.yml", "rb") ;
|
import os
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
def set_output(name, value):
|
||||||
|
with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as f:
|
||||||
|
f.write(f'{name}={value}{os.linesep}')
|
||||||
|
|
||||||
|
# Make sure galaxy.yml contains a version
|
||||||
|
with open('galaxy.yml', 'rb') as f:
|
||||||
data = yaml.safe_load(f) ;
|
data = yaml.safe_load(f) ;
|
||||||
f.close() ;
|
data['version'] = data.get('version') or '0.0.1'
|
||||||
data["version"] = data.get("version") or "0.0.1" ;
|
with open('galaxy.yml', 'w', encoding='utf-8') as f:
|
||||||
f = open("galaxy.yml", "wb") ;
|
f.write(yaml.dump(data))
|
||||||
f.write(yaml.dump(data).encode("utf-8")) ;
|
|
||||||
f.close() ;
|
# Create Galaxy requirements file
|
||||||
'
|
if data.get('dependencies'):
|
||||||
|
reqs = dict(collections=[])
|
||||||
|
for collection, version in sorted(data['dependencies'].items()):
|
||||||
|
reqs['collections'].append(dict(
|
||||||
|
name=collection,
|
||||||
|
source='https://galaxy.ansible.com',
|
||||||
|
version=version,
|
||||||
|
))
|
||||||
|
with open('../requirements.yml', 'w', encoding='utf-8') as f:
|
||||||
|
f.write(yaml.dump(reqs))
|
||||||
|
|
||||||
|
# Extract namespace and collection name
|
||||||
|
set_output('name', data['name'])
|
||||||
|
set_output('namespace', data['namespace'])
|
||||||
|
set_output('version', data['version'])
|
||||||
|
set_output('filename', f"{data['namespace']}-{data['name']}-{data['version']}.tar.gz")
|
||||||
working-directory: ./checkout
|
working-directory: ./checkout
|
||||||
|
|
||||||
- name: Build collection
|
- name: Build collection
|
||||||
|
@ -49,12 +67,19 @@ jobs:
|
||||||
working-directory: ./checkout
|
working-directory: ./checkout
|
||||||
|
|
||||||
- name: Copy artifact into subdirectory
|
- name: Copy artifact into subdirectory
|
||||||
run: mkdir ./artifact && mv ./checkout/${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-*.tar.gz ./artifact
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
mkdir artifact
|
||||||
|
mv checkout/${{ steps.collection-metadata.outputs.filename }} artifact/
|
||||||
|
if [ -f requirements.yml ]; then
|
||||||
|
mv requirements.yml artifact/
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-${{ github.sha }}
|
name: collection-build-${{ github.sha }}
|
||||||
path: ./artifact/
|
path: ./artifact/
|
||||||
|
|
||||||
import-galaxy:
|
import-galaxy:
|
||||||
|
@ -77,7 +102,21 @@ jobs:
|
||||||
- name: Download artifact
|
- name: Download artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-${{ github.sha }}
|
name: collection-build-${{ github.sha }}
|
||||||
|
|
||||||
|
- name: List files
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
ls -la
|
||||||
|
|
||||||
|
- name: Install collection dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ -f requirements.yml ]; then
|
||||||
|
ansible-galaxy collection install --pre --requirements-file requirements.yml
|
||||||
|
else
|
||||||
|
echo "Collection has no dependencies."
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Run Galaxy importer
|
- name: Run Galaxy importer
|
||||||
run: python -m galaxy_importer.main ${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-*.tar.gz
|
run: python -m galaxy_importer.main *-*-*.tar.gz
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue