From 302ede94309d7cc10192bb2c7c66fb4e8d5a3d12 Mon Sep 17 00:00:00 2001 From: Laure-di Date: Tue, 15 Oct 2024 14:35:02 +0200 Subject: [PATCH 1/2] fix(workflow): tests integration --- .github/workflows/ansible-test-integration.yml | 11 ++++------- .../scaleway_registry_namespace/tasks/main.yml | 18 +++++++++--------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ansible-test-integration.yml b/.github/workflows/ansible-test-integration.yml index 5fd71c6..53d4651 100644 --- a/.github/workflows/ansible-test-integration.yml +++ b/.github/workflows/ansible-test-integration.yml @@ -82,14 +82,11 @@ jobs: - name: Perform testing uses: ansible-community/ansible-test-gh-action@release/v1 with: - pre-test-cmd: >- - SCW_ACCESS_KEY=${{ secrets.SCW_ACCESS_KEY }} - SCW_SECRET_KEY=${{ secrets.SCW_SECRET_KEY }} - SCW_DEFAULT_PROJECT_ID=${{ secrets.SCW_DEFAULT_PROJECT_ID }} - eval - "echo \"$(cat "tests/integration/integration_config.yml.template")\"" - > tests/integration/integration_config.yml target-python-version: 3.9 controller-python-version: auto target: ${{ matrix.module }} testing-type: integration + env: + SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }} + SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }} + SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }} diff --git a/tests/integration/targets/scaleway_registry_namespace/tasks/main.yml b/tests/integration/targets/scaleway_registry_namespace/tasks/main.yml index 42042e0..ecc58d1 100644 --- a/tests/integration/targets/scaleway_registry_namespace/tasks/main.yml +++ b/tests/integration/targets/scaleway_registry_namespace/tasks/main.yml @@ -25,9 +25,9 @@ scaleway.scaleway.scaleway_registry_namespace: name: "{{ resource_name }}" region: "{{ resource_region }}" - project_id: "{{ scw_default_project_id }}" - access_key: "{{ scw_access_key }}" - secret_key: "{{ scw_secret_key }}" + project_id: "{{ lookup('env', 'SCW_DEFAULT_PROJECT_ID') }}" + access_key: "{{ lookup('env', 'SCW_ACCESS_KEY') }}" + secret_key: "{{ lookup('env', 'SCW_SECRET_KEY') }}" state: present description: "{{ resource_description }}" is_public: "{{ resource_is_public }}" @@ -37,9 +37,9 @@ scaleway.scaleway.scaleway_registry_namespace: name: "{{ resource_name }}" region: "{{ resource_region }}" - project_id: "{{ scw_default_project_id }}" - access_key: "{{ scw_access_key }}" - secret_key: "{{ scw_secret_key }}" + project_id: "{{ lookup('env', 'SCW_DEFAULT_PROJECT_ID') }}" + access_key: "{{ lookup('env', 'SCW_ACCESS_KEY') }}" + secret_key: "{{ lookup('env', 'SCW_SECRET_KEY') }}" state: absent description: "{{ resource_description }}" is_public: "{{ resource_is_public }}" @@ -50,9 +50,9 @@ scaleway.scaleway.scaleway_registry_namespace: name: "{{ resource_name }}" region: "{{ resource_region }}" - project_id: "{{ scw_default_project_id }}" - access_key: "{{ scw_access_key }}" - secret_key: "{{ scw_secret_key }}" + project_id: "{{ lookup('env', 'SCW_DEFAULT_PROJECT_ID') }}" + access_key: "{{ lookup('env', 'SCW_ACCESS_KEY') }}" + secret_key: "{{ lookup('env', 'SCW_SECRET_KEY') }}" state: present description: "{{ resource_description }}" is_public: "{{ resource_is_public }}" From 9c9aaa5a9b55a155b1b5626d2f65dda932cd16a1 Mon Sep 17 00:00:00 2001 From: Laure-di Date: Thu, 17 Oct 2024 11:17:06 +0200 Subject: [PATCH 2/2] fixing workflow --- .../workflows/ansible-test-integration.yml | 67 ++----------- .../tasks/main.yml | 95 ++++++++----------- 2 files changed, 48 insertions(+), 114 deletions(-) diff --git a/.github/workflows/ansible-test-integration.yml b/.github/workflows/ansible-test-integration.yml index 53d4651..495a49f 100644 --- a/.github/workflows/ansible-test-integration.yml +++ b/.github/workflows/ansible-test-integration.yml @@ -1,12 +1,12 @@ -name: integration +name: Integration on: pull_request: + branches: + - main push: branches: - main - # schedule: - # - cron: "0 6 * * *" workflow_dispatch: jobs: @@ -18,67 +18,12 @@ jobs: max-parallel: 1 matrix: module: - # - scaleway_account_project - # - scaleway_applesilicon_server - # - scaleway_baremetal_server - # - scaleway_container - # - scaleway_container_cron - # - scaleway_container_domain - # - scaleway_container_namespace - # - scaleway_container_token - # - scaleway_domain_ssl_certificate - # - scaleway_flexibleip_flexible_ip - # - scaleway_function - # - scaleway_function_cron - # - scaleway_function_domain - # - scaleway_function_namespace - # - scaleway_function_token - # - scaleway_function_trigger - # - scaleway_iam_api_key - # - scaleway_iam_application - # - scaleway_iam_group - # - scaleway_iam_policy - # - scaleway_iam_ssh_key - # - scaleway_instance_image - # - scaleway_instance_ip - # - scaleway_instance_placement_group - # - scaleway_instance_private_nic - # - scaleway_instance_security_group - # - scaleway_instance_security_group_rule - # - scaleway_instance_snapshot - # - scaleway_instance_volume - # - scaleway_iot_device - # - scaleway_iot_hub - # - scaleway_iot_network - # - scaleway_iot_route - # - scaleway_k8s_cluster - # - scaleway_k8s_pool - # - scaleway_lb - # - scaleway_lb_acl - # - scaleway_lb_backend - # - scaleway_lb_certificate - # - scaleway_lb_frontend - # - scaleway_lb_route - # - scaleway_lb_subscriber - # - scaleway_mnq_credential - # - scaleway_mnq_namespace - # - scaleway_rdb_database_backup - # - scaleway_rdb_endpoint - # - scaleway_rdb_instance - # - scaleway_rdb_read_replica - # - scaleway_rdb_snapshot - # - scaleway_redis_cluster - scaleway_registry_namespace - # - scaleway_secret - # - scaleway_vpc_private_network - # - scaleway_vpcgw_dhcp - # - scaleway_vpcgw_dhcp_entry - # - scaleway_vpcgw_gateway - # - scaleway_vpcgw_gateway_network - # - scaleway_vpcgw_ip - # - scaleway_vpcgw_pat_rule steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Perform testing uses: ansible-community/ansible-test-gh-action@release/v1 with: diff --git a/tests/integration/targets/scaleway_registry_namespace/tasks/main.yml b/tests/integration/targets/scaleway_registry_namespace/tasks/main.yml index ecc58d1..52a2567 100644 --- a/tests/integration/targets/scaleway_registry_namespace/tasks/main.yml +++ b/tests/integration/targets/scaleway_registry_namespace/tasks/main.yml @@ -1,59 +1,48 @@ --- - block: - - name: Ensure Access Key is provided - ansible.builtin.fail: - msg: scw_access_key should be defined in tests/integration/integration_config.yml - when: - - scw_access_key is not defined - - scw_access_key | length == 0 + - name: Ensure required keys are provided + ansible.builtin.fail: + msg: "{{ item }} should be defined in you env" + when: item is not defined or item | length == 0 + loop: + - scw_access_key + - scw_secret_key + - scw_default_project_id - - name: Ensure Secret Key is provided - ansible.builtin.fail: - msg: scw_secret_key should be defined in tests/integration/integration_config.yml - when: - - scw_secret_key is not defined - - scw_secret_key | length == 0 + - name: Create registry_namespace + scaleway.scaleway.scaleway_registry_namespace: + name: "{{ resource_name }}" + region: "{{ resource_region }}" + project_id: "{{ lookup('env', 'SCW_DEFAULT_PROJECT_ID') }}" + access_key: "{{ lookup('env', 'SCW_ACCESS_KEY') }}" + secret_key: "{{ lookup('env', 'SCW_SECRET_KEY') }}" + state: present + description: "{{ resource_description }}" + is_public: "{{ resource_is_public }}" + register: integration_registry_namespace_creation - - name: Ensure Default Project ID is provided - ansible.builtin.fail: - msg: scw_default_project_id should be defined in tests/integration/integration_config.yml - when: - - scw_default_project_id is not defined - - scw_default_project_id | length == 0 + - name: Delete registry_namespace + scaleway.scaleway.scaleway_registry_namespace: + name: "{{ resource_name }}" + region: "{{ resource_region }}" + project_id: "{{ lookup('env', 'SCW_DEFAULT_PROJECT_ID') }}" + access_key: "{{ lookup('env', 'SCW_ACCESS_KEY') }}" + secret_key: "{{ lookup('env', 'SCW_SECRET_KEY') }}" + state: absent + description: "{{ resource_description }}" + is_public: "{{ resource_is_public }}" + register: integration_registry_namespace_deletion - - name: Create registry_namespace - scaleway.scaleway.scaleway_registry_namespace: - name: "{{ resource_name }}" - region: "{{ resource_region }}" - project_id: "{{ lookup('env', 'SCW_DEFAULT_PROJECT_ID') }}" - access_key: "{{ lookup('env', 'SCW_ACCESS_KEY') }}" - secret_key: "{{ lookup('env', 'SCW_SECRET_KEY') }}" - state: present - description: "{{ resource_description }}" - is_public: "{{ resource_is_public }}" - register: integration_registry_namespace_creation + - name: Create a registry_namespace (Check) + check_mode: yes + scaleway.scaleway.scaleway_registry_namespace: + name: "{{ resource_name }}" + region: "{{ resource_region }}" + project_id: "{{ lookup('env', 'SCW_DEFAULT_PROJECT_ID') }}" + access_key: "{{ lookup('env', 'SCW_ACCESS_KEY') }}" + secret_key: "{{ lookup('env', 'SCW_SECRET_KEY') }}" + state: present + description: "{{ resource_description }}" + is_public: "{{ resource_is_public }}" + register: integration_registry_namespace_creation_check - - name: Delete registry_namespace - scaleway.scaleway.scaleway_registry_namespace: - name: "{{ resource_name }}" - region: "{{ resource_region }}" - project_id: "{{ lookup('env', 'SCW_DEFAULT_PROJECT_ID') }}" - access_key: "{{ lookup('env', 'SCW_ACCESS_KEY') }}" - secret_key: "{{ lookup('env', 'SCW_SECRET_KEY') }}" - state: absent - description: "{{ resource_description }}" - is_public: "{{ resource_is_public }}" - register: integration_registry_namespace_deletion - - - name: Create a registry_namespace (Check) - check_mode: yes - scaleway.scaleway.scaleway_registry_namespace: - name: "{{ resource_name }}" - region: "{{ resource_region }}" - project_id: "{{ lookup('env', 'SCW_DEFAULT_PROJECT_ID') }}" - access_key: "{{ lookup('env', 'SCW_ACCESS_KEY') }}" - secret_key: "{{ lookup('env', 'SCW_SECRET_KEY') }}" - state: present - description: "{{ resource_description }}" - is_public: "{{ resource_is_public }}" - register: integration_registry_namespace_creation_check