Skip to content

Commit 39cb767

Browse files
Merge branch 'main' of github.com:linode/linode_api4-python into proj/nb-udp
2 parents 2d23cef + 93b4faf commit 39cb767

File tree

72 files changed

+2706
-719
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2706
-719
lines changed

.github/workflows/e2e-test-pr.yml

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ on:
22
pull_request:
33
workflow_dispatch:
44
inputs:
5+
run_db_fork_tests:
6+
description: 'Set this parameter to "true" to run fork database related test cases'
7+
required: false
8+
default: 'false'
9+
type: choice
10+
options:
11+
- 'true'
12+
- 'false'
13+
run_db_tests:
14+
description: 'Set this parameter to "true" to run database related test cases'
15+
required: false
16+
default: 'false'
17+
type: choice
18+
options:
19+
- 'true'
20+
- 'false'
521
test_suite:
622
description: 'Enter specific test suite. E.g. domain, linode_client'
723
required: false
@@ -80,7 +96,7 @@ jobs:
8096
run: |
8197
timestamp=$(date +'%Y%m%d%H%M')
8298
report_filename="${timestamp}_sdk_test_report.xml"
83-
make testint TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
99+
make test-int RUN_DB_FORK_TESTS=${{ github.event.inputs.run_db_fork_tests }} RUN_DB_TESTS=${{ github.event.inputs.run_db_tests }} TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
84100
env:
85101
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
86102

.github/workflows/e2e-test.yml

+106-25
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,38 @@ name: Integration Tests
33
on:
44
workflow_dispatch:
55
inputs:
6+
run_db_fork_tests:
7+
description: 'Set this parameter to "true" to run fork database related test cases'
8+
required: false
9+
default: 'false'
10+
type: choice
11+
options:
12+
- 'true'
13+
- 'false'
14+
run_db_tests:
15+
description: 'Set this parameter to "true" to run database related test cases'
16+
required: false
17+
default: 'false'
18+
type: choice
19+
options:
20+
- 'true'
21+
- 'false'
22+
test_suite:
23+
description: 'Enter specific test suite. E.g. domain, linode_client'
24+
required: false
625
use_minimal_test_account:
7-
description: 'Use minimal test account'
26+
description: 'Indicate whether to use a minimal test account with limited resources for testing. Defaults to "false"'
827
required: false
928
default: 'false'
1029
sha:
11-
description: 'The hash value of the commit'
12-
required: false
30+
description: 'Specify commit hash to test. This value is mandatory to ensure the tests run against a specific commit'
31+
required: true
1332
default: ''
1433
python-version:
15-
description: 'Specify Python version to use'
34+
description: 'Specify the Python version to use for running tests. Leave empty to use the default Python version configured in the environment'
1635
required: false
1736
run-eol-python-version:
18-
description: 'Run EOL python version?'
37+
description: 'Indicates whether to run tests using an End-of-Life (EOL) Python version. Defaults to "false". Choose "true" to include tests for deprecated Python versions'
1938
required: false
2039
default: 'false'
2140
type: choice
@@ -28,8 +47,8 @@ on:
2847
- dev
2948

3049
env:
31-
DEFAULT_PYTHON_VERSION: "3.9"
32-
EOL_PYTHON_VERSION: "3.8"
50+
DEFAULT_PYTHON_VERSION: "3.10"
51+
EOL_PYTHON_VERSION: "3.9"
3352
EXIT_STATUS: 0
3453

3554
jobs:
@@ -72,24 +91,18 @@ jobs:
7291
run: |
7392
timestamp=$(date +'%Y%m%d%H%M')
7493
report_filename="${timestamp}_sdk_test_report.xml"
75-
make testint TEST_ARGS="--junitxml=${report_filename}"
94+
make test-int RUN_DB_FORK_TESTS=${{ github.event.inputs.run_db_fork_tests }} RUN_DB_TESTS=${{ github.event.inputs.run_db_tests }} TEST_SUITE="${{ github.event.inputs.test_suite }}" TEST_ARGS="--junitxml=${report_filename}"
7695
env:
7796
LINODE_TOKEN: ${{ env.LINODE_TOKEN }}
7897

79-
- name: Upload test results
98+
- name: Upload Test Report as Artifact
8099
if: always()
81-
run: |
82-
filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
83-
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py \
84-
--branch_name "${GITHUB_REF#refs/*/}" \
85-
--gha_run_id "$GITHUB_RUN_ID" \
86-
--gha_run_number "$GITHUB_RUN_NUMBER" \
87-
--xmlfile "${filename}"
88-
sync
89-
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/xml_to_obj.py "${filename}"
90-
env:
91-
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
92-
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: test-report-file
103+
if-no-files-found: ignore
104+
path: '*.xml'
105+
retention-days: 1
93106

94107
apply-calico-rules:
95108
runs-on: ubuntu-latest
@@ -156,12 +169,69 @@ jobs:
156169
env:
157170
LINODE_CLI_TOKEN: ${{ env.LINODE_TOKEN }}
158171

159-
notify-slack:
172+
process-upload-report:
160173
runs-on: ubuntu-latest
161174
needs: [integration-tests]
162-
if: ${{ (success() || failure()) && github.repository == 'linode/linode_api4-python' }} # Run even if integration tests fail and only on main repository
175+
if: always() && github.repository == 'linode/linode_api4-python' # Run even if integration tests fail and only on main repository
176+
outputs:
177+
summary: ${{ steps.set-test-summary.outputs.summary }}
178+
179+
steps:
180+
- name: Checkout code
181+
uses: actions/checkout@v4
182+
with:
183+
fetch-depth: 0
184+
submodules: 'recursive'
185+
186+
- name: Download test report
187+
uses: actions/download-artifact@v4
188+
with:
189+
name: test-report-file
190+
191+
- name: Set up Python
192+
uses: actions/setup-python@v5
193+
with:
194+
python-version: '3.x'
195+
196+
- name: Install Python dependencies
197+
run: pip3 install requests wheel boto3==1.35.99
198+
199+
- name: Set release version env
200+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
201+
202+
- name: Add variables and upload test results
203+
if: always()
204+
run: |
205+
filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
206+
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py \
207+
--branch_name "${GITHUB_REF#refs/*/}" \
208+
--gha_run_id "$GITHUB_RUN_ID" \
209+
--gha_run_number "$GITHUB_RUN_NUMBER" \
210+
--xmlfile "${filename}"
211+
sync
212+
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/xml_to_obj.py "${filename}"
213+
env:
214+
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
215+
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
216+
217+
- name: Generate test summary and save to output
218+
id: set-test-summary
219+
run: |
220+
filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
221+
test_output=$(python3 e2e_scripts/tod_scripts/generate_test_summary.py "${filename}")
222+
{
223+
echo 'summary<<EOF'
224+
echo "$test_output"
225+
echo EOF
226+
} >> "$GITHUB_OUTPUT"
227+
228+
notify-slack:
229+
runs-on: ubuntu-latest
230+
needs: [integration-tests, process-upload-report]
231+
if: ${{ (success() || failure()) }} # Run even if integration tests fail and only on main repository
163232
steps:
164233
- name: Notify Slack
234+
id: main_message
165235
uses: slackapi/[email protected]
166236
with:
167237
method: chat.postMessage
@@ -172,7 +242,7 @@ jobs:
172242
- type: section
173243
text:
174244
type: mrkdwn
175-
text: ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:"
245+
text: ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* ${{ needs.integration-tests.result == 'success' && ':white_check_mark:' || ':failed:' }}"
176246
- type: divider
177247
- type: section
178248
fields:
@@ -190,4 +260,15 @@ jobs:
190260
- type: context
191261
elements:
192262
- type: mrkdwn
193-
text: "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
263+
text: "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
264+
265+
- name: Test summary thread
266+
if: success()
267+
uses: slackapi/[email protected]
268+
with:
269+
method: chat.postMessage
270+
token: ${{ secrets.SLACK_BOT_TOKEN }}
271+
payload: |
272+
channel: ${{ secrets.SLACK_CHANNEL_ID }}
273+
thread_ts: "${{ steps.main_message.outputs.ts }}"
274+
text: "${{ needs.process-upload-report.outputs.summary }}"

.github/workflows/labeler.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/checkout@v4
2222
-
2323
name: Run Labeler
24-
uses: crazy-max/ghaction-github-labeler@b54af0c25861143e7c8813d7cbbf46d2c341680c
24+
uses: crazy-max/ghaction-github-labeler@24d110aa46a59976b8a7f35518cb7f14f434c916
2525
with:
2626
github-token: ${{ secrets.GITHUB_TOKEN }}
2727
yaml-file: .github/labels.yml

.github/workflows/nightly-smoke-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Run smoke tests
4040
id: smoke_tests
4141
run: |
42-
make smoketest
42+
make test-smoke
4343
env:
4444
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
4545

.github/workflows/publish-pypi.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ on:
55
types: [ published ]
66
jobs:
77
pypi-release:
8+
permissions:
9+
# IMPORTANT: this permission is mandatory for trusted publishing
10+
id-token: write
811
runs-on: ubuntu-latest
12+
environment: pypi-release
913
steps:
1014
- name: Checkout
1115
uses: actions/checkout@v4
@@ -24,6 +28,4 @@ jobs:
2428
LINODE_SDK_VERSION: ${{ github.event.release.tag_name }}
2529

2630
- name: Publish the release artifacts to PyPI
27-
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # pin@release/v1.12.3
28-
with:
29-
password: ${{ secrets.PYPI_API_TOKEN }}
31+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # pin@release/v1.12.4

Makefile

+14-27
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
11
PYTHON ?= python3
22

3-
TEST_CASE_COMMAND :=
4-
TEST_SUITE :=
5-
TEST_ARGS :=
6-
73
LINODE_SDK_VERSION ?= "0.0.0.dev"
84
VERSION_MODULE_DOCSTRING ?= \"\"\"\nThe version of this linode_api4 package.\n\"\"\"\n\n
95
VERSION_FILE := ./linode_api4/version.py
106

11-
ifdef TEST_CASE
12-
TEST_CASE_COMMAND = -k $(TEST_CASE)
13-
endif
14-
15-
ifdef TEST_SUITE
16-
ifneq ($(TEST_SUITE),linode_client)
17-
ifneq ($(TEST_SUITE),login_client)
18-
TEST_COMMAND = models/$(TEST_SUITE)
19-
else
20-
TEST_COMMAND = login_client
21-
endif
22-
else
23-
TEST_COMMAND = linode_client
24-
endif
25-
endif
26-
277
.PHONY: clean
288
clean:
299
mkdir -p dist
@@ -73,14 +53,21 @@ lint: build
7353
$(PYTHON) -m pylint linode_api4
7454
$(PYTHON) -m twine check dist/*
7555

76-
.PHONY: testint
77-
testint:
78-
$(PYTHON) -m pytest test/integration/${TEST_COMMAND} ${TEST_CASE_COMMAND} ${TEST_ARGS}
56+
# Integration Test Arguments
57+
# TEST_SUITE: Optional, specify a test suite (e.g. domain), Default to run everything if not set
58+
# TEST_CASE: Optional, specify a test case (e.g. 'test_image_replication')
59+
# TEST_ARGS: Optional, additional arguments for pytest (e.g. '-v' for verbose mode)
60+
61+
TEST_COMMAND = $(if $(TEST_SUITE),$(if $(filter $(TEST_SUITE),linode_client login_client),$(TEST_SUITE),models/$(TEST_SUITE)))
62+
63+
.PHONY: test-int
64+
test-int:
65+
$(PYTHON) -m pytest test/integration/${TEST_COMMAND} $(if $(TEST_CASE),-k $(TEST_CASE)) ${TEST_ARGS}
7966

80-
.PHONY: testunit
81-
testunit:
67+
.PHONY: test-unit
68+
test-unit:
8269
$(PYTHON) -m pytest test/unit
8370

84-
.PHONY: smoketest
85-
smoketest:
71+
.PHONY: test-smoke
72+
test-smoke:
8673
$(PYTHON) -m pytest -m smoke test/integration

README.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,16 @@ Running the tests
148148
^^^^^^^^^^^^^^^^^
149149
Run the tests locally using the make command. Run the entire test suite using command below::
150150

151-
make testint
151+
make test-int
152152

153153
To run a specific package/suite, use the environment variable `TEST_SUITE` using directory names in `integration/...` folder ::
154154

155-
make TEST_SUITE="account" testint // Runs tests in `integration/models/account` directory
156-
make TEST_SUITE="linode_client" testint // Runs tests in `integration/linode_client` directory
155+
make TEST_SUITE="account" test-int // Runs tests in `integration/models/account` directory
156+
make TEST_SUITE="linode_client" test-int // Runs tests in `integration/linode_client` directory
157157

158-
Lastly to run a specific test case use environment variable `TEST_CASE` with `testint` command::
158+
Lastly to run a specific test case use environment variable `TEST_CASE` with `test-int` command::
159159

160-
make TEST_CASE=test_get_domain_record testint
160+
make TEST_CASE=test_get_domain_record test-int
161161

162162
Documentation
163163
-------------

linode_api4/groups/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from .image import *
99
from .linode import *
1010
from .lke import *
11+
from .lke_tier import *
1112
from .longview import *
1213
from .networking import *
1314
from .nodebalancer import *

linode_api4/groups/account.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def settings(self):
101101
s = AccountSettings(self.client, result["managed"], result)
102102
return s
103103

104-
def invoices(self):
104+
def invoices(self, *filters):
105105
"""
106106
Returns Invoices issued to this account.
107107
@@ -112,9 +112,9 @@ def invoices(self):
112112
:returns: Invoices issued to this account.
113113
:rtype: PaginatedList of Invoice
114114
"""
115-
return self.client._get_and_filter(Invoice)
115+
return self.client._get_and_filter(Invoice, *filters)
116116

117-
def payments(self):
117+
def payments(self, *filters):
118118
"""
119119
Returns a list of Payments made on this account.
120120
@@ -123,7 +123,7 @@ def payments(self):
123123
:returns: A list of payments made on this account.
124124
:rtype: PaginatedList of Payment
125125
"""
126-
return self.client._get_and_filter(Payment)
126+
return self.client._get_and_filter(Payment, *filters)
127127

128128
def oauth_clients(self, *filters):
129129
"""
@@ -337,7 +337,7 @@ def add_promo_code(self, promo_code):
337337
json=resp,
338338
)
339339

340-
def service_transfers(self):
340+
def service_transfers(self, *filters):
341341
"""
342342
Returns a collection of all created and accepted Service Transfers for this account, regardless of the user that created or accepted the transfer.
343343
@@ -347,7 +347,7 @@ def service_transfers(self):
347347
:rtype: PaginatedList of ServiceTransfer
348348
"""
349349

350-
return self.client._get_and_filter(ServiceTransfer)
350+
return self.client._get_and_filter(ServiceTransfer, *filters)
351351

352352
def service_transfer_create(self, entities):
353353
"""

0 commit comments

Comments
 (0)