Skip to content

Commit

Permalink
Merge branch 'dev' into zhiwei/region-info
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-akamai authored Oct 1, 2024
2 parents dcefef4 + 9aa32d9 commit ed87c0c
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 11 deletions.
70 changes: 68 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- dev

jobs:
run-tests:
integration-tests:
runs-on: ubuntu-latest
env:
EXIT_STATUS: 0
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
process-upload-report:
runs-on: ubuntu-latest
needs: [run-tests]
if: always() # Run even if previous job fails
if: always() && github.repository == 'linode/ansible_linode'

steps:
- name: Checkout code
Expand Down Expand Up @@ -127,3 +127,69 @@ jobs:
env:
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}

notify-slack:
runs-on: ubuntu-latest
needs: [integration-tests]
if: always() && github.repository == 'linode/ansible_linode' # Run even if integration tests fail and only on main repository

steps:
- name: Notify Slack
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:"
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Build Result:*\n${{ needs.integration-tests.result == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}"
},
{
"type": "mrkdwn",
"text": "*Branch:*\n`${{ github.ref_name }}`"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
},
{
"type": "mrkdwn",
"text": "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>"
}
]
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ deps:
pip install -r requirements.txt -r requirements-dev.txt --upgrade

lint:
pylint plugins
pylint --disable=too-many-positional-arguments plugins

mypy plugins/modules
mypy plugins/inventory
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/linode_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
RETRY_STATUSES = {408, 429, 502}


class LinodeModuleBase:
class LinodeModuleBase: # pylint: disable=too-many-positional-arguments
"""A base for all Linode resource modules."""

## pylint: disable=too-many-positional-arguments
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/linode_common_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class InfoModule(LinodeModuleBase):

# pylint: disable=too-many-positional-arguments
def __init__(
# pylint: disable=too-many-positional-arguments
self,
primary_result: InfoModuleResult,
secondary_results: List[InfoModuleResult] = None,
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/linode_common_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ListModuleParam:

class ListModule(
LinodeModuleBase
): # pylint: disable=too-many-instance-attributes
): # pylint: disable=too-many-instance-attributes,too-many-positional-arguments
"""A common module for listing API resources given a set of filters."""

# pylint: disable=too-many-positional-arguments
Expand Down
20 changes: 14 additions & 6 deletions tests/integration/targets/image_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
- set_fact:
r: "{{ 1000000000 | random }}"

- name: List regions
linode.cloud.region_list: {}
register: all_regions

- set_fact:
capable_regions: '{{ (all_regions.regions | selectattr("capabilities", "search", "Object Storage") | selectattr("site_type", "equalto", "core") | map(attribute="id") | list) }}'

- name: Create an instance to image
linode.cloud.instance:
label: 'ansible-test-{{ r }}'
region: us-east
region: '{{ capable_regions[1] }}'
type: g6-standard-1
image: linode/alpine3.19
state: present
Expand Down Expand Up @@ -83,8 +90,8 @@
tags:
- 'test'
replica_regions:
- 'us-east'
- 'eu-west'
- '{{ capable_regions[0] }}'
- '{{ capable_regions[1] }}'
wait_for_replications: yes
wait_timeout: 1200
state: present
Expand All @@ -96,7 +103,8 @@
- image_replicate.changed
- image_replicate.image.id == image_create.image.id
- image_replicate.image.regions | length == 2
- image_replicate.image.regions[0].region == 'us-east'
- image_replicate.image.regions[0].region == capable_regions[1]
- image_replicate.image.regions[1].region == capable_regions[0]
- image_replicate.image.regions[0].status == 'available'
- image_replicate.image.regions[1].status == 'available'

Expand All @@ -108,7 +116,7 @@
tags:
- 'test'
replica_regions:
- 'eu-west'
- '{{ capable_regions[0] }}'
wait_for_replications: yes
wait_timeout: 1200
state: present
Expand All @@ -119,7 +127,7 @@
that:
- image_replicate.changed
- image_replicate.image.regions | length == 1
- image_replicate.image.regions[0].region == 'eu-west'
- image_replicate.image.regions[0].region == capable_regions[0]
- image_replicate.image.regions[0].status == 'available'

- name: Overwrite the image
Expand Down

0 comments on commit ed87c0c

Please sign in to comment.