Skip to content

Commit 9bee759

Browse files
Merge pull request #125 from dynatrace-extensions/feature/separate_build_workflow
Standalone build workflow to be used by publish workflow and on new PRs & linter fixes
2 parents 703e191 + 11e7b75 commit 9bee759

File tree

5 files changed

+46
-28
lines changed

5 files changed

+46
-28
lines changed

.github/workflows/build-package.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build distribution 📦
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
pull_request:
7+
8+
jobs:
9+
build-package:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.10"
18+
19+
- name: Install hatch
20+
run: |
21+
pip install hatch --user
22+
23+
- name: Run tests
24+
run: |
25+
python3 -m hatch run test
26+
27+
- name: Run linting
28+
run: |
29+
python3 -m hatch run lint:all
30+
31+
- name: Build a wheel and a source tarball
32+
run: |
33+
python3 -m hatch build

.github/workflows/publish.yml

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,23 @@ on:
44

55
jobs:
66
build-package:
7-
name: Build distribution 📦
8-
runs-on: ubuntu-latest
7+
uses: ./.github/workflows/build-package.yml
98

9+
check-tag:
10+
runs-on: ubuntu-latest
1011
steps:
1112
- id: check_ref
1213
run: echo "::set-output name=match::$(echo '${{ github.ref }}' | grep -Pq '^refs/tags/v\d+\.\d+\.\d+$' && echo true || echo false)"
1314
shell: bash
14-
1515
- name: Check if tag is valid
1616
if: steps.check_ref.outputs.match != 'true'
1717
run: exit 1
1818

19+
upload-artifact:
20+
needs: build-package
21+
runs-on: ubuntu-latest
22+
steps:
1923
- uses: actions/checkout@v4
20-
21-
- name: Set up Python
22-
uses: actions/setup-python@v5
23-
with:
24-
python-version: "3.10"
25-
26-
- name: Install hatch
27-
run: |
28-
pip install hatch --user
29-
30-
- name: Run tests
31-
run: |
32-
python3 -m hatch run test
33-
34-
- name: Run linting
35-
run: |
36-
python3 -m hatch run lint:all
37-
38-
- name: Build a wheel and a source tarball
39-
run: |
40-
python3 -m hatch build
41-
4224
- name: Store the distribution packages
4325
uses: actions/upload-artifact@v4
4426
with:

dynatrace_extension/sdk/communication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def get_extension_config(self) -> str:
343343
def get_feature_sets(self) -> dict[str, list[str]]:
344344
# This is only called from dt-sdk run, where PyYaml is installed because of dt-cli
345345
# Do NOT move this to the top of the file
346-
import yaml # type: ignore
346+
import yaml # noqa: PLC0415
347347

348348
# Grab the feature sets from the extension.yaml file
349349
extension_yaml = yaml.safe_load(self.extension_config)

dynatrace_extension/sdk/extension.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class Extension:
184184

185185
def __new__(cls, *args, **kwargs): # noqa: ARG004
186186
if Extension._instance is None:
187-
Extension._instance = super(__class__, cls).__new__(cls)
187+
Extension._instance = super().__new__(cls)
188188
return Extension._instance
189189

190190
def __init__(self, name: str = "") -> None:
@@ -683,7 +683,7 @@ def report_dt_event_dict(self, event: dict):
683683
msg = f"Event type must be a DtEventType enum value, got: {value}"
684684
raise ValueError(msg)
685685
if key == "properties":
686-
for prop_key, prop_val in event[key].items():
686+
for prop_key, prop_val in value.items():
687687
if not isinstance(prop_key, str) or not isinstance(prop_val, str):
688688
msg = f'invalid "properties" member: {prop_key}: {prop_val}, required: "str": str'
689689
raise ValueError(msg)

dynatrace_extension/sdk/status.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ def __repr__(self):
114114
def __eq__(self, other):
115115
return isinstance(other, EndpointStatus) and self.__dict__ == other.__dict__
116116

117+
def __hash__(self):
118+
return hash(tuple(sorted(self.__dict__.items())))
119+
117120

118121
class EndpointStatuses:
119122
def __init__(self, total_endpoints_number=None) -> None:

0 commit comments

Comments
 (0)