From b7676adce416ac944c9bd3e5473f12cd80cdc031 Mon Sep 17 00:00:00 2001 From: ykim-1 Date: Mon, 27 Jan 2025 10:20:55 -0800 Subject: [PATCH 1/6] gha test 1 --- .github/workflows/e2e-test.yml | 64 +++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 51eda09bf..14aab6531 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -76,20 +76,14 @@ jobs: env: LINODE_TOKEN: ${{ env.LINODE_TOKEN }} - - name: Upload test results + - name: Upload Test Report as Artifact if: always() - run: | - filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$') - python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py \ - --branch_name "${GITHUB_REF#refs/*/}" \ - --gha_run_id "$GITHUB_RUN_ID" \ - --gha_run_number "$GITHUB_RUN_NUMBER" \ - --xmlfile "${filename}" - sync - python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/xml_to_obj.py "${filename}" - env: - LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }} - LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }} + uses: actions/upload-artifact@v4 + with: + name: test-report-file + if-no-files-found: ignore + path: '*.xml' + retention-days: 1 apply-calico-rules: runs-on: ubuntu-latest @@ -156,6 +150,50 @@ jobs: env: LINODE_CLI_TOKEN: ${{ env.LINODE_TOKEN }} + process-upload-report: + runs-on: ubuntu-latest + needs: [integration_tests] + if: always() #&& github.repository == 'linode/linode_api4-python' # Run even if integration tests fail and only on main repository + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: 'recursive' + + - name: Download test report + uses: actions/download-artifact@v4 + with: + name: test-report-file + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install Python dependencies + run: pip3 install requests wheel boto3==1.35.99 + + - name: Set release version env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + + - name: Add variables and upload test results + if: always() + run: | + filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$') + python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py \ + --branch_name "${GITHUB_REF#refs/*/}" \ + --gha_run_id "$GITHUB_RUN_ID" \ + --gha_run_number "$GITHUB_RUN_NUMBER" \ + --xmlfile "${filename}" + sync + python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/xml_to_obj.py "${filename}" + 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] From 463f00481d2ee6da5b9aed77d0bb2074e3fe57c7 Mon Sep 17 00:00:00 2001 From: ykim-1 Date: Mon, 27 Jan 2025 10:35:41 -0800 Subject: [PATCH 2/6] roll back boto3 version for test upload --- .github/workflows/e2e-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 14aab6531..bcbcae216 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -152,7 +152,7 @@ jobs: process-upload-report: runs-on: ubuntu-latest - needs: [integration_tests] + needs: [integration-tests] if: always() #&& github.repository == 'linode/linode_api4-python' # Run even if integration tests fail and only on main repository steps: From 31ee0c06afb8e253997e0c2dd45cc72ada968f79 Mon Sep 17 00:00:00 2001 From: ykim-1 Date: Mon, 27 Jan 2025 11:19:39 -0800 Subject: [PATCH 3/6] roll back boto3 version for test upload --- .github/workflows/e2e-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index bcbcae216..e80102c26 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -153,7 +153,7 @@ jobs: process-upload-report: runs-on: ubuntu-latest needs: [integration-tests] - if: always() #&& github.repository == 'linode/linode_api4-python' # Run even if integration tests fail and only on main repository + if: always() && github.repository == 'linode/linode_api4-python' # Run even if integration tests fail and only on main repository steps: - name: Checkout code From 8eaa296e4b620e81a2b3053e62fa60db708b04a0 Mon Sep 17 00:00:00 2001 From: ykim-1 Date: Mon, 27 Jan 2025 12:11:23 -0800 Subject: [PATCH 4/6] address codeQL warnings --- test/unit/objects/database_test.py | 37 ++++++++++++++---------------- test/unit/objects/vpc_test.py | 2 +- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/test/unit/objects/database_test.py b/test/unit/objects/database_test.py index d5b84cebb..d3546562d 100644 --- a/test/unit/objects/database_test.py +++ b/test/unit/objects/database_test.py @@ -1,3 +1,4 @@ +import logging from test.unit.base import ClientBaseCase from linode_api4 import PostgreSQLDatabase @@ -106,19 +107,18 @@ def test_create(self): Test that MySQL databases can be created """ + logger = logging.getLogger(__name__) + with self.mock_post("/databases/mysql/instances") as m: # We don't care about errors here; we just want to # validate the request. - try: - self.client.database.mysql_create( - "cool", - "us-southeast", - "mysql/8.0.26", - "g6-standard-1", - cluster_size=3, - ) - except Exception: - pass + self.client.database.mysql_create( + "cool", + "us-southeast", + "mysql/8.0.26", + "g6-standard-1", + cluster_size=3, + ) self.assertEqual(m.method, "post") self.assertEqual(m.call_url, "/databases/mysql/instances") @@ -292,16 +292,13 @@ def test_create(self): with self.mock_post("/databases/postgresql/instances") as m: # We don't care about errors here; we just want to # validate the request. - try: - self.client.database.postgresql_create( - "cool", - "us-southeast", - "postgresql/13.2", - "g6-standard-1", - cluster_size=3, - ) - except Exception: - pass + self.client.database.mysql_create( + "cool", + "us-southeast", + "mysql/8.0.26", + "g6-standard-1", + cluster_size=3, + ) self.assertEqual(m.method, "post") self.assertEqual(m.call_url, "/databases/postgresql/instances") diff --git a/test/unit/objects/vpc_test.py b/test/unit/objects/vpc_test.py index 4d80716d4..20d36139b 100644 --- a/test/unit/objects/vpc_test.py +++ b/test/unit/objects/vpc_test.py @@ -138,7 +138,7 @@ def test_list_ips(self): ip = result[0] assert ip.address == "10.0.0.2" - assert ip.address_range == None + assert ip.address_range is None assert ip.vpc_id == 123 assert ip.subnet_id == 456 assert ip.region == "us-mia" From 8be1d5f731197fd3aa289dbde43a4c857e5a6304 Mon Sep 17 00:00:00 2001 From: ykim-1 Date: Mon, 27 Jan 2025 12:14:59 -0800 Subject: [PATCH 5/6] address codeQL warnings --- test/unit/objects/database_test.py | 34 ++++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/test/unit/objects/database_test.py b/test/unit/objects/database_test.py index d3546562d..150113c06 100644 --- a/test/unit/objects/database_test.py +++ b/test/unit/objects/database_test.py @@ -112,13 +112,16 @@ def test_create(self): with self.mock_post("/databases/mysql/instances") as m: # We don't care about errors here; we just want to # validate the request. - self.client.database.mysql_create( - "cool", - "us-southeast", - "mysql/8.0.26", - "g6-standard-1", - cluster_size=3, - ) + try: + self.client.database.mysql_create( + "cool", + "us-southeast", + "mysql/8.0.26", + "g6-standard-1", + cluster_size=3, + ) + except Exception as e: + logger.warning("An error occurred while validating the request: %s", e) self.assertEqual(m.method, "post") self.assertEqual(m.call_url, "/databases/mysql/instances") @@ -292,13 +295,16 @@ def test_create(self): with self.mock_post("/databases/postgresql/instances") as m: # We don't care about errors here; we just want to # validate the request. - self.client.database.mysql_create( - "cool", - "us-southeast", - "mysql/8.0.26", - "g6-standard-1", - cluster_size=3, - ) + try: + self.client.database.postgresql_create( + "cool", + "us-southeast", + "postgresql/13.2", + "g6-standard-1", + cluster_size=3, + ) + except Exception: + pass self.assertEqual(m.method, "post") self.assertEqual(m.call_url, "/databases/postgresql/instances") From 270399a7423341af4b289e1bc911e3279721d06d Mon Sep 17 00:00:00 2001 From: ykim-1 Date: Mon, 27 Jan 2025 13:40:03 -0800 Subject: [PATCH 6/6] make format --- test/unit/objects/database_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/unit/objects/database_test.py b/test/unit/objects/database_test.py index 150113c06..26250b7b2 100644 --- a/test/unit/objects/database_test.py +++ b/test/unit/objects/database_test.py @@ -121,7 +121,9 @@ def test_create(self): cluster_size=3, ) except Exception as e: - logger.warning("An error occurred while validating the request: %s", e) + logger.warning( + "An error occurred while validating the request: %s", e + ) self.assertEqual(m.method, "post") self.assertEqual(m.call_url, "/databases/mysql/instances")