forked from CCCHH/ansible-infra
159 lines
5.3 KiB
YAML
159 lines
5.3 KiB
YAML
---
|
|
name: GitHub Release
|
|
|
|
# yamllint disable-line rule:truthy
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'Version number to release'
|
|
required: true
|
|
env:
|
|
NAMESPACE: grafana
|
|
COLLECTION_NAME: grafana
|
|
|
|
jobs:
|
|
sanity:
|
|
name: Sanity (Ⓐ${{ matrix.ansible }})
|
|
strategy:
|
|
matrix:
|
|
ansible:
|
|
- stable-2.12
|
|
- stable-2.13
|
|
- stable-2.14
|
|
- devel
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
|
|
- name: Check out code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: '3.10'
|
|
|
|
- name: Install ansible-base (${{ matrix.ansible }})
|
|
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
|
|
|
|
- name: Run sanity tests
|
|
run: ansible-test sanity -v --docker --color --coverage
|
|
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
|
|
|
|
integration:
|
|
runs-on: ubuntu-20.04
|
|
name: Integration (Ⓐ${{ matrix.ansible }}-py${{ matrix.python }})
|
|
strategy:
|
|
fail-fast: true
|
|
max-parallel: 1
|
|
matrix:
|
|
ansible:
|
|
- stable-2.13
|
|
python:
|
|
- '3.10'
|
|
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v2
|
|
with:
|
|
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
|
|
|
|
- name: create integration_config
|
|
working-directory: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration
|
|
run: |
|
|
cat <<EOF > integration_config.yml
|
|
org_name: ${{ secrets.ANSIBLE_TEST_ORG_NAME }}
|
|
grafana_cloud_api_key: ${{ secrets.ANSIBLE_TEST_CLOUD_API_KEY }}
|
|
grafana_api_key: ${{ secrets.ANSIBLE_TEST_GRAFANA_API_KEY }}
|
|
grafana_url: ${{ secrets.ANSIBLE_GRAFANA_URL }}
|
|
test_stack_name: ${{ secrets.ANSIBLE_TEST_CI_STACK }}
|
|
EOF
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: ${{ matrix.python }}
|
|
|
|
- name: Install ansible-base (${{ matrix.ansible }})
|
|
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
|
|
|
|
- name: Install Requests
|
|
run: pip install requests
|
|
|
|
- name: Create Test Stack
|
|
run: ansible-test integration -v create_cloud_stack --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --coverage --docker
|
|
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
|
|
|
|
- name: Test Modules
|
|
run: ansible-test integration -v alert_contact_point alert_notification_policy cloud_api_key cloud_plugin dashboard datasource folder --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --coverage --docker
|
|
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
|
|
|
|
- name: Delete Test Stack
|
|
if: success() || failure()
|
|
run: ansible-test integration -v delete_cloud_stack --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --coverage --docker
|
|
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
|
|
|
|
publish:
|
|
name: Publish to Galaxy
|
|
runs-on: ubuntu-latest
|
|
needs: [sanity, integration]
|
|
timeout-minutes: 15
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: '3.10'
|
|
|
|
- name: Install Ansible
|
|
run: pip install ansible-core
|
|
|
|
- name: Install PyYaml
|
|
run: pip install pyyaml
|
|
|
|
- name: Validate version matches
|
|
run: |
|
|
VERSION=$(python -c "import yaml; print(yaml.safe_load(open('galaxy.yml'))['version'])")
|
|
if [ "$VERSION" != "${{ github.event.inputs.version }}" ]; then
|
|
echo "Error: Input version (${{ github.event.inputs.version }}) doesn't match galaxy.yml version ($VERSION)"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Build collection
|
|
id: build
|
|
run: |
|
|
ansible-galaxy collection build
|
|
echo "archive_path=$(ls *.tar.gz)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Publish collection to Galaxy
|
|
env:
|
|
ANSIBLE_GALAXY_API_KEY: ${{ secrets.ANSIBLE_GALAXY_API_KEY }}
|
|
run: ansible-galaxy collection publish --api-key ${{ secrets.ANSIBLE_GALAXY_API_KEY }} ${{ steps.build.outputs.archive_path }}
|
|
|
|
release:
|
|
name: Create GitHub Release
|
|
runs-on: ubuntu-latest
|
|
needs: [publish]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: '3.10'
|
|
|
|
- name: Install PyYaml
|
|
run: pip install pyyaml
|
|
|
|
- name: Validate version is published to Galaxy
|
|
run: curl --head -s -f -o /dev/null https://galaxy.ansible.com/download/grafana-grafana-${{ github.event.inputs.version }}.tar.gz
|
|
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
tag_name: ${{ github.event.inputs.version }}
|