Skip to content

Commit 9cd272f

Browse files
feat(automations): add before_snapshot trigger type
1 parent 8718015 commit 9cd272f

File tree

7 files changed

+25
-4
lines changed

7 files changed

+25
-4
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 167
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-041f3ba8dd0f5670e5fe37a61d725bd162d53c10c768bd3aa9b95ddc6d43926a.yml
3-
openapi_spec_hash: 770ce1f0289034006cbe5279535dbbf3
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-a7829781a00de0869ad8536dcd67bdbbf224a42f5f3f922065a44e73b0534bbf.yml
3+
openapi_spec_hash: 59381e16e5de8d6de09f92abc0433e02
44
config_hash: 21bab2a4731f1e55c0a2c62588576282

src/gitpod/types/runner_capability.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
"RUNNER_CAPABILITY_ALLOW_ENV_TOKEN_POPULATION",
1313
"RUNNER_CAPABILITY_DEFAULT_DEV_CONTAINER_IMAGE",
1414
"RUNNER_CAPABILITY_ENVIRONMENT_SNAPSHOT",
15+
"RUNNER_CAPABILITY_PREBUILDS_BEFORE_SNAPSHOT_TRIGGER",
1516
]

src/gitpod/types/shared/automation_trigger.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ class AutomationTrigger(BaseModel):
1818
The `post_environment_start` field indicates that the automation should be triggered after the environment has started (devcontainer ready).
1919
The `post_devcontainer_start` field indicates that the automation should be triggered after the dev container has started.
2020
The `prebuild` field starts the automation during a prebuild of an environment. This phase does not have user secrets available.
21-
Note: The prebuild trigger can only be used with tasks, not services.
21+
The `before_snapshot` field triggers the automation after all prebuild tasks complete but before the snapshot is taken.
22+
This is used for tasks that need to run last during prebuilds, such as IDE warmup.
23+
Note: The prebuild and before_snapshot triggers can only be used with tasks, not services.
2224
"""
2325

26+
before_snapshot: Optional[bool] = FieldInfo(alias="beforeSnapshot", default=None)
27+
2428
manual: Optional[bool] = None
2529

2630
post_devcontainer_start: Optional[bool] = FieldInfo(alias="postDevcontainerStart", default=None)

src/gitpod/types/shared_params/automation_trigger.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ class AutomationTrigger(TypedDict, total=False):
1818
The `post_environment_start` field indicates that the automation should be triggered after the environment has started (devcontainer ready).
1919
The `post_devcontainer_start` field indicates that the automation should be triggered after the dev container has started.
2020
The `prebuild` field starts the automation during a prebuild of an environment. This phase does not have user secrets available.
21-
Note: The prebuild trigger can only be used with tasks, not services.
21+
The `before_snapshot` field triggers the automation after all prebuild tasks complete but before the snapshot is taken.
22+
This is used for tasks that need to run last during prebuilds, such as IDE warmup.
23+
Note: The prebuild and before_snapshot triggers can only be used with tasks, not services.
2224
"""
2325

26+
before_snapshot: Annotated[bool, PropertyInfo(alias="beforeSnapshot")]
27+
2428
manual: bool
2529

2630
post_devcontainer_start: Annotated[bool, PropertyInfo(alias="postDevcontainerStart")]

tests/api_resources/environments/automations/test_services.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def test_method_create_with_all_params(self, client: Gitpod) -> None:
4646
"role": "SERVICE_ROLE_UNSPECIFIED",
4747
"triggered_by": [
4848
{
49+
"before_snapshot": True,
4950
"manual": True,
5051
"post_devcontainer_start": True,
5152
"post_environment_start": True,
@@ -157,6 +158,7 @@ def test_method_update_with_all_params(self, client: Gitpod) -> None:
157158
"triggered_by": {
158159
"trigger": [
159160
{
161+
"before_snapshot": True,
160162
"manual": True,
161163
"post_devcontainer_start": True,
162164
"post_environment_start": True,
@@ -404,6 +406,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncGitpod) ->
404406
"role": "SERVICE_ROLE_UNSPECIFIED",
405407
"triggered_by": [
406408
{
409+
"before_snapshot": True,
407410
"manual": True,
408411
"post_devcontainer_start": True,
409412
"post_environment_start": True,
@@ -515,6 +518,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGitpod) ->
515518
"triggered_by": {
516519
"trigger": [
517520
{
521+
"before_snapshot": True,
518522
"manual": True,
519523
"post_devcontainer_start": True,
520524
"post_environment_start": True,

tests/api_resources/environments/automations/test_tasks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def test_method_create_with_all_params(self, client: Gitpod) -> None:
4747
"reference": "build",
4848
"triggered_by": [
4949
{
50+
"before_snapshot": True,
5051
"manual": True,
5152
"post_devcontainer_start": True,
5253
"post_environment_start": True,
@@ -151,6 +152,7 @@ def test_method_update_with_all_params(self, client: Gitpod) -> None:
151152
"triggered_by": {
152153
"trigger": [
153154
{
155+
"before_snapshot": True,
154156
"manual": True,
155157
"post_devcontainer_start": True,
156158
"post_environment_start": True,
@@ -349,6 +351,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncGitpod) ->
349351
"reference": "build",
350352
"triggered_by": [
351353
{
354+
"before_snapshot": True,
352355
"manual": True,
353356
"post_devcontainer_start": True,
354357
"post_environment_start": True,
@@ -453,6 +456,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGitpod) ->
453456
"triggered_by": {
454457
"trigger": [
455458
{
459+
"before_snapshot": True,
456460
"manual": True,
457461
"post_devcontainer_start": True,
458462
"post_environment_start": True,

tests/api_resources/test_environments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def test_method_create_with_all_params(self, client: Gitpod) -> None:
4343
"session": "session",
4444
"trigger_filter": [
4545
{
46+
"before_snapshot": True,
4647
"manual": True,
4748
"post_devcontainer_start": True,
4849
"post_environment_start": True,
@@ -394,6 +395,7 @@ def test_method_create_from_project_with_all_params(self, client: Gitpod) -> Non
394395
"session": "session",
395396
"trigger_filter": [
396397
{
398+
"before_snapshot": True,
397399
"manual": True,
398400
"post_devcontainer_start": True,
399401
"post_environment_start": True,
@@ -697,6 +699,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncGitpod) ->
697699
"session": "session",
698700
"trigger_filter": [
699701
{
702+
"before_snapshot": True,
700703
"manual": True,
701704
"post_devcontainer_start": True,
702705
"post_environment_start": True,
@@ -1048,6 +1051,7 @@ async def test_method_create_from_project_with_all_params(self, async_client: As
10481051
"session": "session",
10491052
"trigger_filter": [
10501053
{
1054+
"before_snapshot": True,
10511055
"manual": True,
10521056
"post_devcontainer_start": True,
10531057
"post_environment_start": True,

0 commit comments

Comments
 (0)