Skip to content

Commit 58f1c5d

Browse files
committed
fix workflow
1 parent 3badbcf commit 58f1c5d

File tree

5 files changed

+47
-30
lines changed

5 files changed

+47
-30
lines changed

.github/workflows/ci_workflow.yml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ jobs:
1515
with:
1616
python-version: '${{ matrix.python-version }}'
1717

18-
- name: Install Poetry
19-
run: |
20-
python -m pip install --upgrade pip
21-
pip install poetry==1.6.*
18+
- name: Install the latest version of uv
19+
uses: astral-sh/setup-uv@v6
20+
2221
- name: Install dependencies
23-
run: |
24-
poetry install
22+
run: uv sync
23+
2524
- name: Run pre-commit
2625
run: |
27-
poetry run pre-commit install
28-
poetry run pre-commit run --all-files
26+
uv run pre-commit install
27+
uv run pre-commit run --all-files
2928
pytest:
3029
runs-on: ubuntu-latest
3130
strategy:
@@ -37,17 +36,21 @@ jobs:
3736
uses: actions/setup-python@v2
3837
with:
3938
python-version: '${{ matrix.python-version }}'
40-
- name: Install Poetry
39+
- name: Install the latest version of uv
40+
uses: astral-sh/setup-uv@v6
41+
- name: Set up Docker Compose
4142
run: |
42-
pip install typing-extensions
43-
python -m pip install --upgrade pip
44-
pip install poetry==1.6.*
43+
sudo curl -L "https://github.com/docker/compose/releases/download/v2.24.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
44+
sudo chmod +x /usr/local/bin/docker-compose
45+
docker-compose --version # Verify installation
46+
shell: bash
4547
- name: Install dependencies
46-
run: |
47-
poetry install
48+
run: uv sync
4849
- name: Test with pytest
4950
run: |
50-
poetry run pytest --capture=no
51+
docker-compose up -d elasticsearch
52+
sleep 30
53+
uv run pytest --capture=no
5154
5255
integration:
5356
runs-on: ubuntu-latest
@@ -63,17 +66,19 @@ jobs:
6366
sudo chmod +x /usr/local/bin/docker-compose
6467
docker-compose --version # Verify installation
6568
shell: bash
66-
6769
- name: Set up Python ${{ matrix.python-version }}
6870
uses: actions/setup-python@v2
6971
with:
7072
python-version: ${{ matrix.python-version }}
73+
- name: Install the latest version of uv
74+
uses: astral-sh/setup-uv@v6
7175
- name: Install dependencies
72-
run: |
73-
python -m pip install --upgrade pip
74-
pip install meltano
75-
meltano install
76+
run: uv tool install meltano
77+
- name: Install Meltano plugins
78+
run: meltano install --clean
7679
- name: smoke-test-tap
80+
env:
81+
ELASTIC_PASSWORD: changeme
7782
run: |
7883
docker-compose up -d elasticsearch
7984
sleep 30

meltano.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ plugins:
2121
namespace: target_elasticsearch
2222
pip_url: -e .
2323
config:
24-
username: $TARGET_ELASTICSEARCH_USERNAME
25-
password: $TARGET_ELASTICSEARCH_PASSWORD
24+
username: elastic
25+
password: changeme
2626
index_format: "ecs-{{ stream_name }}-an-{{ foo }}-{{ current_timestamp_daily }}"
2727
stream_maps: # use stream maps to do more complex base record manipulation
2828
animals:

target_elasticsearch/sinks.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def __init__(
3232
):
3333
super().__init__(target, stream_name, schema, key_properties)
3434
self.client = self._authenticated_client()
35-
self.index_schema_fields = self.config.get("index_schema_fields", {}).get(self.stream_name, {})
35+
self.index_schema_fields = self.config.get("index_schema_fields", {}).get(
36+
self.stream_name, {}
37+
)
3638
self.metadata_fields = self.config.get("metadata_fields", {}).get(self.stream_name, {})
3739
self.index_mappings = self.config.get("index_mappings", {}).get(self.stream_name, {})
3840
self.index_name = None
@@ -97,7 +99,9 @@ def _build_fields(
9799
for k, v in mapping.items():
98100
match = jsonpath_ng.parse(v).find(record)
99101
if len(match) == 0:
100-
self.logger.warning(f"schema key {k} with json path {v} could not be found in record: {record}")
102+
self.logger.warning(
103+
f"schema key {k} with json path {v} could not be found in record: {record}"
104+
)
101105
schemas[k] = v
102106
else:
103107
if len(match) > 1:
@@ -208,7 +212,9 @@ def process_batch(self, context: dict[str, Any]) -> None:
208212
Args:
209213
context: Dictionary containing batch processing context including records.
210214
"""
211-
updated_records, distinct_indices = self.build_request_body_and_distinct_indices(context["records"])
215+
updated_records, distinct_indices = self.build_request_body_and_distinct_indices(
216+
context["records"]
217+
)
212218
for index in distinct_indices:
213219
self.create_index(index)
214220
try:

target_elasticsearch/target.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,17 @@ def __init__(
149149
setup_mapper: bool = True,
150150
) -> None:
151151
super().__init__(
152-
config=config, parse_env_config=parse_env_config, validate_config=validate_config, setup_mapper=setup_mapper
152+
config=config,
153+
parse_env_config=parse_env_config,
154+
validate_config=validate_config,
155+
setup_mapper=setup_mapper,
156+
)
157+
assert bool(self.config.get("username") is None) == bool(
158+
self.config.get("password") is None
159+
)
160+
assert bool(self.config.get("api_key_id") is None) == bool(
161+
self.config.get("api_key") is None
153162
)
154-
assert bool(self.config.get("username") is None) == bool(self.config.get("password") is None)
155-
assert bool(self.config.get("api_key_id") is None) == bool(self.config.get("api_key") is None)
156163

157164
@property
158165
def state(self) -> Dict:

tests/test_core.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pytest
21
import os
32
from typing import Any
43

@@ -7,7 +6,7 @@
76

87
SAMPLE_CONFIG: dict[str, Any] = {
98
"username": "elastic",
10-
"password": os.environ["TARGET_ELASTICSEARCH_PASSWORD"],
9+
"password": os.environ.get("TARGET_ELASTICSEARCH_PASSWORD", "changeme"),
1110
}
1211

1312
# Run standard built-in target tests from the SDK:

0 commit comments

Comments
 (0)