Skip to content

[WIP] refactor: created separate file with common module parts #1057

[WIP] refactor: created separate file with common module parts

[WIP] refactor: created separate file with common module parts #1057

Workflow file for this run

# vim: ts=2: sw=2: ai: si
# CI workflow
name: CI
on:
workflow_dispatch:
workflow_call:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
paths:
- 'plugins/**/*'
- 'tests/**/*'
- '.github/workflows/CI.yml'
push:
branches: [ master ]
paths:
- 'plugins/**/*'
- 'tests/**/*'
- '.github/workflows/CI.yml'
jobs:
check_runs:
if: github.event.pull_request.draft == false
name: Making sure no other CI is running
env:
# Workflow names that cannot run in parallel with this workflow, separated by spaces
# Example: incompatible_parallel_workflows: 'CI Build Name OtherName Foo Bar FooBar'
incompatible_parallel_workflows: 'CI'
runs-on: ubuntu-latest
outputs:
runs: ${{ steps.get-runs_in_progress.outputs.runs }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python ${{ env.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version }}
- name: Wait for Github API to register this as a running workflow
run: sleep 10s
shell: bash
- name: Checking no other incompatible workflow is running
id: runs_in_progress
run: |
bash .github/scripts/get_in_progress_ci.sh ${{ env.incompatible_parallel_workflows }}
- name: Assert that this is the only running CI
uses: nick-fields/assert-action@v1
with:
expected: false
actual: ${{ steps.runs_in_progress.outputs.is_banned_running }}
cleanup_test_account:
needs: check_runs
name: Cleanup test account
runs-on: ubuntu-latest
env:
IONOS_USERNAME: ${{ secrets.IONOS_USER_V6 }}
IONOS_PASSWORD: ${{ secrets.IONOS_PASSWORD_V6 }}
IONOS_TOKEN: ${{ secrets.IONOS_TOKEN_V6 }}
IONOSCTL_VERSION: 6.7.4
steps:
- name: Checking out module-ansible
uses: actions/checkout@v2
- name: Setup ionosctl
run: |
curl -sL https://github.com/ionos-cloud/ionosctl/releases/download/v${{ env.IONOSCTL_VERSION }}/ionosctl-${{ env.IONOSCTL_VERSION }}-linux-amd64.tar.gz | tar -xzv > /dev/null
mv ionosctl /usr/local/bin
# Temporarily skipped
# - name: Perform cleanup
# working-directory: /home/runner/work/module-ansible/module-ansible/.github/scripts/cleanup
# run: |
# ./delete-all-resources.sh &> output.log || true
# cat output.log
# Upload the output as an artifact
- name: Create an artifact with the output logs file
uses: actions/upload-artifact@v2
if: always()
with:
name: cleanup.log
path: |
/home/runner/work/module-ansible/module-ansible/.github/cleanup/scripts/cleanup/output.log
test:
needs: cleanup_test_account
name: Testing the ${{ matrix.namespace }} modules
strategy:
matrix:
include:
- namespace: application-loadbalancers
keywords: "application_load_balancer, target_group, application-load-balancer, target-group"
- namespace: user-management
keywords: "user, group, s3key, share"
- namespace: managed-backup
keywords: "backupunit"
- namespace: compute-engine
keywords: "datacenter, server, firewall, volume, image, cube, lan, nic, pcc, snapshot, ipblock"
- namespace: dbaas-postgres
keywords: "postgres"
- namespace: dbaas-mongo
keywords: "mongo"
- namespace: managed-kubernetes/cluster
keywords: "k8s"
- namespace: managed-kubernetes/nodepool
keywords: "k8s-cluster-nodepool, k8s_nodepool"
- namespace: natgateway
keywords: "nat"
- namespace: networkloadbalancer
keywords: "network_load_balancer, network"
- namespace: certificate-manager
keywords: "certificate"
- namespace: container-registry
keywords: "registry"
- namespace: dataplatform
keywords: "data_platform, dataplatform"
- namespace: logging
keywords: "pipeline"
- namespace: dns
keywords: "dns, dns_zone, dns_record"
- namespace: vm-autoscaling
keywords: "autoscaling"
env:
python-version: 3.8.15
ANSIBLE_LIBRARY: /home/runner/work/module-ansible/module-ansible/plugins/modules
IONOS_USERNAME: ${{ secrets.IONOS_USER_V6 }}
IONOS_PASSWORD: ${{ secrets.IONOS_PASSWORD_V6 }}
IONOS_TOKEN: ${{ secrets.IONOS_TOKEN_V6 }}
# The type of runner that the job will run on
runs-on: ubuntu-latest
outputs:
python-version: ${{ env.python-version }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python ${{ env.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version }}
- name: Setup pip, virtualenv, ionoscloud
run: |
python3 -m pip install --upgrade pip
python3 -m pip install pydantic
python3 -m pip install ionoscloud
python3 -m pip install ionoscloud-cert-manager
python3 -m pip install ionoscloud-dns
python3 -m pip install ionoscloud-dbaas-postgres
python3 -m pip install ionoscloud-dbaas-mongo
python3 -m pip install ionoscloud-container-registry
python3 -m pip install ionoscloud-dataplatform
python3 -m pip install ionoscloud-logging
python3 -m pip install ionoscloud-vm-autoscaling
- name: Install Ansible and IONOS module
run: |
python3 -m pip install ansible
ansible-galaxy collection build /home/runner/work/module-ansible/module-ansible/
ansible-galaxy collection install ionoscloudsdk-ionoscloud-$(grep version: galaxy.yml | cut -c10-).tar.gz --force
rm ionoscloudsdk-ionoscloud-$(grep version: galaxy.yml | cut -c10-).tar.gz
- name: Debug pip packages
run: |
python3 -m pip list
- id: files
name: Get changed files
uses: jitterbit/get-changed-files@v1
if: github.event_name == 'pull_request'
- name: Run ${{ matrix.namespace }} tests with files diff check
run: |
if [[ $(bash .github/scripts/check_keywords.sh "${{ matrix.keywords }}" ${{ steps.files.outputs.all }}) == true ]]; then
echo "Changed files in ${{ matrix.namespace }}."
ansible-playbook /home/runner/work/module-ansible/module-ansible/tests/${{ matrix.namespace }}/all-tests.yml -vvv
else
echo "no changed ${{ matrix.namespace }} files!"
fi
if: github.event_name == 'pull_request'
- name: Run ${{ matrix.namespace }} tests
run: |
ansible-playbook /home/runner/work/module-ansible/module-ansible/tests/${{ matrix.namespace }}/all-tests.yml
if: github.event_name == 'workflow_dispatch'