Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into issues/326-project-name
Browse files Browse the repository at this point in the history
  • Loading branch information
mamercad committed Jan 1, 2024
2 parents 76baec7 + fb2e040 commit 0405332
Show file tree
Hide file tree
Showing 21 changed files with 209 additions and 87 deletions.
72 changes: 62 additions & 10 deletions .github/workflows/ansible-test-integration.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,75 @@
name: integration

name: Integration tests
on:
push:
branches: [main]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
cancel-in-progress: false

env:
# NOTE: Yes, the origination is not from a PR :smile: but we do have
# integration tests on PR and we want the cloud resources uniquely named
PR_NUMBER: 0

jobs:
integration:
runs-on: ubuntu-22.04
timeout-minutes: 90
environment: main
timeout-minutes: 60
name: Integration (Ⓐ${{ matrix.versions.ansible }} on ${{ matrix.versions.python }} / ${{ matrix.module }})
strategy:
fail-fast: false
max-parallel: 1
matrix:
ansible:
- stable-2.14
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html
versions:
- ansible: stable-2.14
python: "3.9"
module:
- digital_ocean_account_info
- digital_ocean_balance_info
- digital_ocean_block_storage
- digital_ocean_cdn_endpoints
- digital_ocean_cdn_endpoints_info
- digital_ocean_certificate
- digital_ocean_certificate_info
- digital_ocean_database
- digital_ocean_database_info
- digital_ocean_domain
- digital_ocean_domain_info
# - digital_ocean_domain_record # No test
- digital_ocean_domain_record_info
- digital_ocean_droplet
- digital_ocean_droplet_info
- digital_ocean_firewall
- digital_ocean_firewall_info
- digital_ocean_floating_ip
- digital_ocean_floating_ip_info
- digital_ocean_image_info
- digital_ocean_kubernetes
- digital_ocean_kubernetes_info
- digital_ocean_load_balancer
- digital_ocean_load_balancer_info
- digital_ocean_monitoring_alerts
# - digital_ocean_monitoring_alerts_info # No test
- digital_ocean_project
- digital_ocean_project_info
- digital_ocean_project_resource_info
- digital_ocean_region_info
- digital_ocean_size_info
- digital_ocean_snapshot
- digital_ocean_snapshot_info
- digital_ocean_spaces
- digital_ocean_spaces_info
- digital_ocean_sshkey
- digital_ocean_sshkey_info
- digital_ocean_tag
- digital_ocean_tag_info
- digital_ocean_volume_info
- digital_ocean_vpc
- digital_ocean_vpc_info
steps:
- name: Perform testing
uses: ansible-community/ansible-test-gh-action@release/v1
Expand All @@ -29,8 +81,8 @@ jobs:
./tests/utils/render.sh
tests/integration/integration_config.yml.template
> tests/integration/integration_config.yml
ansible-core-version: ${{ matrix.ansible }}
origin-python-version: 3.9
target-python-version: 3.9
ansible-core-version: ${{ matrix.versions.ansible }}
origin-python-version: ${{ matrix.versions.python }}
target: ${{ matrix.module }}
target-python-version: ${{ matrix.versions.python }}
testing-type: integration
test-deps: community.general
91 changes: 74 additions & 17 deletions .github/workflows/pull-request-integration.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,87 @@
name: pull-request-integration
name: Pull request integration tests

on:
pull_request:
types: [opened, synchronize, reopened]
pull_request_target:
branches:
- main
paths:
- plugins/module_utils/**
- plugins/modules/**
- poetry.lock
- pyproject.toml
- 'plugins/module_utils/**'
- 'plugins/modules/**'
- 'tests/integration/**'

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

env:
PR_NUMBER: ${{ github.event.pull_request.number }}

jobs:
integration:
environment: integration
test-integration:
runs-on: ubuntu-22.04
timeout-minutes: 40
# MUST keep this environment set if using pull_request_target
environment: integration
timeout-minutes: 60
strategy:
fail-fast: false
max-parallel: 1
matrix:
ansible:
- stable-2.14
versions:
- ansible: stable-2.14
python: "3.9"
module:
- digital_ocean_account_info
- digital_ocean_balance_info
- digital_ocean_block_storage
- digital_ocean_cdn_endpoints
- digital_ocean_cdn_endpoints_info
- digital_ocean_certificate
- digital_ocean_certificate_info
- digital_ocean_database
- digital_ocean_database_info
- digital_ocean_domain
- digital_ocean_domain_info
# - digital_ocean_domain_record # No test
- digital_ocean_domain_record_info
- digital_ocean_droplet
- digital_ocean_droplet_info
- digital_ocean_firewall
- digital_ocean_firewall_info
- digital_ocean_floating_ip
- digital_ocean_floating_ip_info
- digital_ocean_image_info
- digital_ocean_kubernetes
- digital_ocean_kubernetes_info
- digital_ocean_load_balancer
- digital_ocean_load_balancer_info
- digital_ocean_monitoring_alerts
# - digital_ocean_monitoring_alerts_info # No test
- digital_ocean_project
- digital_ocean_project_info
- digital_ocean_project_resource_info
- digital_ocean_region_info
- digital_ocean_size_info
- digital_ocean_snapshot
- digital_ocean_snapshot_info
- digital_ocean_spaces
- digital_ocean_spaces_info
- digital_ocean_sshkey
- digital_ocean_sshkey_info
- digital_ocean_tag
- digital_ocean_tag_info
- digital_ocean_volume_info
- digital_ocean_vpc
- digital_ocean_vpc_info
steps:
- name: Perform testing
- name: Perform integration testing
uses: ansible-community/ansible-test-gh-action@release/v1
with:
# MUST set 'git-checkout-ref' if using pull_request_target
# MUST use an Environment if using pull_request_target
# 'github.event.pull_request.head.sha' checks out the
# PR source repo's code, which should be considered untrusted
git-checkout-ref: ${{ github.event.pull_request.head.sha }}
pre-test-cmd: >-
DO_API_KEY=${{ secrets.DO_API_KEY }}
Expand All @@ -33,8 +90,8 @@ jobs:
./tests/utils/render.sh
tests/integration/integration_config.yml.template
> tests/integration/integration_config.yml
ansible-core-version: ${{ matrix.ansible }}
origin-python-version: 3.9
target-python-version: 3.9
ansible-core-version: ${{ matrix.versions.ansible }}
origin-python-version: ${{ matrix.versions.python }}
target: ${{ matrix.module }}
target-python-version: ${{ matrix.versions.python }}
testing-type: integration
test-deps: community.general
5 changes: 5 additions & 0 deletions changelogs/fragments/322-k8s-module-kubeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bugfixes:
- digital_ocean_kubernetes - module didn't return kubeconfig properly, return documentation was
invalid. Fixed version returns data with the same structure all the time, also it is aligned
with M(community.digitalocean.digital_ocean_kubernetes_info) documentation return data now.
(https://github.com/ansible-collections/community.digitalocean/issues/322).
2 changes: 2 additions & 0 deletions changelogs/fragments/337-refactor-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trivial:
- ci - refactor integration test workflows (https://github.com/ansible-collections/community.digitalocean/pull/337).
2 changes: 2 additions & 0 deletions changelogs/fragments/338-refactor-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trivial:
- ci - refactor integration test workflows (https://github.com/ansible-collections/community.digitalocean/pull/338).
83 changes: 42 additions & 41 deletions plugins/modules/digital_ocean_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,51 +212,50 @@
- name: do-nyc1-hacktoberfest-admin
user:
token: REDACTED
kubernetes_cluster:
auto_upgrade: false
cluster_subnet: 10.244.0.0/16
created_at: '2020-09-27T00:55:37Z'
endpoint: https://REDACTED.k8s.ondigitalocean.com
auto_upgrade: false
cluster_subnet: 10.244.0.0/16
created_at: '2020-09-27T00:55:37Z'
endpoint: https://REDACTED.k8s.ondigitalocean.com
id: REDACTED
ipv4: REDACTED
maintenance_policy:
day: any
duration: 4h0m0s
start_time: '15:00'
name: hacktoberfest
node_pools:
- auto_scale: false
count: 1
id: REDACTED
ipv4: REDACTED
maintenance_policy:
day: any
duration: 4h0m0s
start_time: '15:00'
name: hacktoberfest
node_pools:
- auto_scale: false
count: 1
labels: null
max_nodes: 0
min_nodes: 0
name: hacktoberfest-workers
nodes:
- created_at: '2020-09-27T00:55:37Z'
droplet_id: '209555245'
id: REDACTED
labels: null
max_nodes: 0
min_nodes: 0
name: hacktoberfest-workers
nodes:
- created_at: '2020-09-27T00:55:37Z'
droplet_id: '209555245'
id: REDACTED
name: hacktoberfest-workers-3tdq1
status:
state: running
updated_at: '2020-09-27T00:58:36Z'
size: s-1vcpu-2gb
tags:
- k8s
- k8s:REDACTED
- k8s:worker
taints: []
region: nyc1
service_subnet: 10.245.0.0/16
status:
state: running
surge_upgrade: false
name: hacktoberfest-workers-3tdq1
status:
state: running
updated_at: '2020-09-27T00:58:36Z'
size: s-1vcpu-2gb
tags:
- k8s
- k8s:REDACTED
updated_at: '2020-09-27T01:00:37Z'
version: 1.18.8-do.1
vpc_uuid: REDACTED
- k8s:worker
taints: []
region: nyc1
service_subnet: 10.245.0.0/16
status:
state: running
surge_upgrade: false
tags:
- k8s
- k8s:REDACTED
updated_at: '2020-09-27T01:00:37Z'
version: 1.18.8-do.1
vpc_uuid: REDACTED
"""


Expand Down Expand Up @@ -396,7 +395,9 @@ def create(self):
json_data = self.ensure_running()
# Add the kubeconfig to the return
if self.return_kubeconfig:
json_data["kubeconfig"] = self.get_kubernetes_kubeconfig()
json_data["kubernetes_cluster"][
"kubeconfig"
] = self.get_kubernetes_kubeconfig()
self.module.exit_json(changed=True, data=json_data["kubernetes_cluster"])

def delete(self):
Expand Down
1 change: 1 addition & 0 deletions tests/integration/integration_config.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
do_api_key: ${DO_API_KEY}
aws_access_key_id: ${AWS_ACCESS_KEY_ID}
aws_secret_access_key: ${AWS_SECRET_ACCESS_KEY}
pr_number: ${PR_NUMBER}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
do_region: nyc1
volume_name: gh-ci-volume
volume_name: gh-ci-volume-0-{{ pr_number }}
volume_size: 15
volume_down_size: 10
volume_up_size: 20
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
unsupported
disabled
Original file line number Diff line number Diff line change
@@ -1 +1 @@
unsupported
disabled
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
do_region: nyc1
droplet_name: gh-ci-droplet
droplet_name: gh-ci-droplet-0-{{ pr_number }}
droplet_image: ubuntu-22-04-x64
droplet_size: s-1vcpu-1gb
droplet_new_size: s-1vcpu-2gb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
do_region: nyc1
droplet_name: gh-ci-droplet
droplet_name: gh-ci-droplet-1-{{ pr_number }}
droplet_image: ubuntu-22-04-x64
droplet_size: s-1vcpu-1gb
project_name: gh-ci-project
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
do_region: nyc1

cluster_name: gh-ci-k8s
cluster_name: gh-ci-k8s-0-{{ pr_number }}
cluster_version: latest
cluster_node_pools:
- name: gh-ci-k8s-workers
- name: gh-ci-k8s-workers-0-{{ pr_number }}
size: s-1vcpu-2gb
count: 1

cluster_ha_name: gh-ci-ha-k8s
cluster_ha_name: gh-ci-ha-k8s-1-{{ pr_number }}
cluster_ha_version: latest
cluster_ha_node_pools:
- name: gh-ci-k8s-ha-workers
- name: gh-ci-k8s-ha-workers-1-{{ pr_number }}
size: s-1vcpu-2gb
count: 3
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
version: "{{ cluster_version }}"
region: "{{ do_region }}"
node_pools: "{{ cluster_node_pools }}"
return_kubeconfig: false
return_kubeconfig: true
wait_timeout: 600
register: result

Expand All @@ -74,6 +74,8 @@
that:
- result.changed
- result.data.name == cluster_name
- result.data.kubeconfig is defined
- result.data.kubeconfig | length > 0

- name: Gather information about the Kubernetes cluster
community.digitalocean.digital_ocean_kubernetes_info:
Expand Down
Loading

0 comments on commit 0405332

Please sign in to comment.