Skip to content

Commit cbe2ddd

Browse files
authored
fix: Turn ACTOR_BUILD_TAGS into a comma-separated list env var (#27)
It turns out I need a special env var type for `ACTOR_BUILD_TAGS`, since it's not directly a string variable, but a comma-separated list, and will need to be parsed in the SDK.
1 parent 55a8542 commit cbe2ddd

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22

3-
## [1.2.0](../../releases/tag/v1.2.0) - 2024-12-05
3+
## [1.2.1](../../releases/tag/v1.2.1) - 2024-12-05
4+
5+
### Changed
6+
7+
- Changed `ACTOR_BUILD_TAGS` to be a comma-separated list variable
8+
9+
## [1.2.0](../../releases/tag/v1.2.0) - 2024-12-04
410

511
### Added
612

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "apify_shared"
3-
version = "1.2.0"
3+
version = "1.2.1"
44
description = "Tools and constants shared across Apify projects."
55
readme = "README.md"
66
license = { text = "Apache Software License" }

src/apify_shared/consts.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ class MetaOrigin(str, Enum):
327327
# Actor env vars
328328
ActorEnvVars.BUILD_ID,
329329
ActorEnvVars.BUILD_NUMBER,
330-
ActorEnvVars.BUILD_TAGS,
331330
ActorEnvVars.DEFAULT_DATASET_ID,
332331
ActorEnvVars.DEFAULT_KEY_VALUE_STORE_ID,
333332
ActorEnvVars.DEFAULT_REQUEST_QUEUE_ID,
@@ -373,3 +372,11 @@ class MetaOrigin(str, Enum):
373372
]
374373

375374
STRING_ENV_VARS: list[STRING_ENV_VARS_TYPE] = list(get_args(STRING_ENV_VARS_TYPE))
375+
376+
COMMA_SEPARATED_LIST_ENV_VARS_TYPE = Literal[
377+
ActorEnvVars.BUILD_TAGS,
378+
]
379+
380+
COMMA_SEPARATED_LIST_ENV_VARS: list[COMMA_SEPARATED_LIST_ENV_VARS_TYPE] = list(
381+
get_args(COMMA_SEPARATED_LIST_ENV_VARS_TYPE)
382+
)

tests/unit/test_consts.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from apify_shared.consts import (
77
BOOL_ENV_VARS,
8+
COMMA_SEPARATED_LIST_ENV_VARS,
89
DATETIME_ENV_VARS,
910
FLOAT_ENV_VARS,
1011
INTEGER_ENV_VARS,
@@ -20,14 +21,28 @@
2021
class TestConsts:
2122
def test_env_vars_types_unique(self: TestConsts) -> None:
2223
"""Test that env var types don't contain any item twice."""
23-
for env_var_type in [BOOL_ENV_VARS, DATETIME_ENV_VARS, FLOAT_ENV_VARS, INTEGER_ENV_VARS, STRING_ENV_VARS]:
24+
for env_var_type in [
25+
BOOL_ENV_VARS,
26+
COMMA_SEPARATED_LIST_ENV_VARS,
27+
DATETIME_ENV_VARS,
28+
FLOAT_ENV_VARS,
29+
INTEGER_ENV_VARS,
30+
STRING_ENV_VARS,
31+
]:
2432
assert isinstance(env_var_type, list)
2533
assert len(env_var_type) == len(set(env_var_type))
2634

2735
def test_env_vars_types_do_not_overlap(self: TestConsts) -> None:
2836
"""Test that there is no overlap between env var types."""
2937
for first, second in itertools.combinations(
30-
[BOOL_ENV_VARS, DATETIME_ENV_VARS, FLOAT_ENV_VARS, INTEGER_ENV_VARS, STRING_ENV_VARS],
38+
[
39+
BOOL_ENV_VARS,
40+
COMMA_SEPARATED_LIST_ENV_VARS,
41+
DATETIME_ENV_VARS,
42+
FLOAT_ENV_VARS,
43+
INTEGER_ENV_VARS,
44+
STRING_ENV_VARS,
45+
],
3146
r=2,
3247
):
3348
assert isinstance(first, list)
@@ -38,6 +53,7 @@ def test_env_vars_types_defined_for_all_env_vars(self: TestConsts) -> None:
3853
"""Test that all env vars from `ApifyEnvVars` and `ActorEnvVars` have a defined type."""
3954
env_vars_from_types = set(
4055
list(BOOL_ENV_VARS)
56+
+ list(COMMA_SEPARATED_LIST_ENV_VARS)
4157
+ list(DATETIME_ENV_VARS)
4258
+ list(FLOAT_ENV_VARS)
4359
+ list(INTEGER_ENV_VARS)

0 commit comments

Comments
 (0)