Skip to content

Commit a114faa

Browse files
committed
Merge remote-tracking branch 'origin/master' into handle_spec_playing
2 parents bdacf9d + 240d20e commit a114faa

File tree

6 files changed

+61
-35
lines changed

6 files changed

+61
-35
lines changed

.github/actions/add_pr_to_smackore_board/action.yml

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'Add PR to Smackore board, if author is from community'
2-
description: '(disabled due to github-side bug) Adds PR to "New issues by community" column in Smackore project board, if PR author is from outside Membrane Team.'
2+
description: 'Adds PR to "New issues by community" column in Smackore project board, if PR author is from outside Membrane Team.'
33
inputs:
44
GITHUB_TOKEN:
55
description: 'GitHub token'
@@ -19,23 +19,23 @@ runs:
1919
repository: membraneframework/membrane_core
2020
- name: Maybe add PR to board and set ticket status
2121
run: |
22-
# currently this causes github action crash, more info here: https://github.com/membraneframework/membrane_core/issues/749
23-
24-
# export PROJECT_NUMBER=19
25-
# export PROJECT_ID=PVT_kwDOAYE_z84AWEIB
26-
# export STATUS_FIELD_ID=PVTSSF_lADOAYE_z84AWEIBzgOGd1k
27-
# export TARGET_COLUMN_ID=e6b1ee10
22+
# currently this may cause github action crash, more info here: https://github.com/membraneframework/membrane_core/issues/749
23+
24+
export PROJECT_NUMBER=19
25+
export PROJECT_ID=PVT_kwDOAYE_z84AWEIB
26+
export STATUS_FIELD_ID=PVTSSF_lADOAYE_z84AWEIBzgOGd1k
27+
export TARGET_COLUMN_ID=e6b1ee10
2828
29-
# export AUTHOR_ORIGIN=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /orgs/membraneframework/teams/membraneteam/members | python scripts/python/get_author_origin.py $AUTHOR_LOGIN)
29+
export AUTHOR_ORIGIN=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /orgs/membraneframework/teams/membraneteam/members | python scripts/python/get_author_origin.py $AUTHOR_LOGIN)
3030
31-
# if [ "$AUTHOR_ORIGIN" == "COMMUNITY" ]
32-
# then
33-
# gh pr edit "$PR_URL" --add-project Smackore
34-
# sleep 10
31+
if [ "$AUTHOR_ORIGIN" == "COMMUNITY" ]
32+
then
33+
gh pr edit "$PR_URL" --add-project Smackore
34+
sleep 10
3535
36-
# export TICKET_ID=$(gh project item-list $PROJECT_NUMBER --owner membraneframework --format json --limit 10000000 | python scripts/python/get_ticket_id.py "$PR_URL")
37-
# gh project item-edit --id $TICKET_ID --field-id $STATUS_FIELD_ID --project-id $PROJECT_ID --single-select-option-id $TARGET_COLUMN_ID
38-
# fi
36+
export TICKET_ID=$(gh project item-list $PROJECT_NUMBER --owner membraneframework --format json --limit 10000000 | python scripts/python/get_ticket_id.py "$PR_URL")
37+
gh project item-edit --id $TICKET_ID --field-id $STATUS_FIELD_ID --project-id $PROJECT_ID --single-select-option-id $TARGET_COLUMN_ID
38+
fi
3939
4040
env:
4141
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}

lib/membrane/core/callback_handler.ex

+21
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ defmodule Membrane.Core.CallbackHandler do
185185
Error handling actions returned by callback #{inspect(state.module)}.#{callback}
186186
""")
187187

188+
log_debug_orginal_error(actions, e, __STACKTRACE__)
189+
188190
reraise e, __STACKTRACE__
189191
end
190192

@@ -198,10 +200,29 @@ defmodule Membrane.Core.CallbackHandler do
198200
Error handling action #{inspect(action)} returned by callback #{inspect(state.module)}.#{callback}
199201
""")
200202

203+
log_debug_orginal_error(action, e, __STACKTRACE__)
204+
201205
reraise e, __STACKTRACE__
202206
end
203207
end)
204208

205209
handler_module.handle_end_of_actions(state)
206210
end
211+
212+
# We log it, because sometimes, for some reason, crashing process doesn't cause
213+
# printing error logs on stderr, so this debug log allows us to get some info
214+
# about what happened in case of process crash
215+
defp log_debug_orginal_error(action_or_actions, error, stacktrace) do
216+
action_or_actions =
217+
if(is_list(action_or_actions), do: "actions ", else: "action ") <>
218+
inspect(action_or_actions, limit: :infinity)
219+
220+
Membrane.Logger.debug("""
221+
Error while handling #{action_or_actions}
222+
223+
Orginal error:
224+
#{inspect(error, pretty: true, limit: :infinity)}
225+
#{Exception.format_stacktrace(stacktrace)}
226+
""")
227+
end
207228
end

lib/membrane/core/parent/child_life_controller/crash_group_utils.ex

+6-8
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ defmodule Membrane.Core.Parent.ChildLifeController.CrashGroupUtils do
1616
def add_crash_group(group_name, mode, children, state)
1717
when not is_map_key(state.crash_groups, group_name) do
1818
put_in(
19-
state,
20-
[:crash_groups, group_name],
19+
state.crash_groups[group_name],
2120
%CrashGroup{
2221
name: group_name,
2322
mode: mode,
@@ -28,7 +27,7 @@ defmodule Membrane.Core.Parent.ChildLifeController.CrashGroupUtils do
2827

2928
@spec extend_crash_group(Child.group(), [Child.name()], Parent.state()) :: Parent.state()
3029
def extend_crash_group(group_name, children, state) do
31-
update_in(state, [:crash_groups, group_name, :members], &(children ++ &1))
30+
update_in(state.crash_groups[group_name].members, &(children ++ &1))
3231
end
3332

3433
@spec get_child_crash_group(Child.name(), Parent.state()) :: {:ok, CrashGroup.t()} | :error
@@ -44,7 +43,7 @@ defmodule Membrane.Core.Parent.ChildLifeController.CrashGroupUtils do
4443
# and we will not want to have it in :crash_group_members in the callback context in handle_crash_group_down/3,
4544
# so this child is removed from :members in crash group struct
4645
members = List.delete(group.members, child_name)
47-
state = put_in(state, [:crash_groups, group.name, :members], members)
46+
state = put_in(state.crash_groups[group.name].members, members)
4847

4948
if group.detonating? and Enum.all?(members, &(not Map.has_key?(state.children, &1))) do
5049
cleanup_crash_group(group.name, state)
@@ -83,8 +82,7 @@ defmodule Membrane.Core.Parent.ChildLifeController.CrashGroupUtils do
8382
end)
8483

8584
update_in(
86-
state,
87-
[:crash_groups, group.name],
85+
state.crash_groups[group.name],
8886
&%CrashGroup{
8987
&1
9088
| detonating?: true,
@@ -96,15 +94,15 @@ defmodule Membrane.Core.Parent.ChildLifeController.CrashGroupUtils do
9694

9795
defp cleanup_crash_group(group_name, state) do
9896
state = exec_handle_crash_group_down(group_name, state)
99-
{_group, state} = pop_in(state, [:crash_groups, group_name])
97+
{_group, state} = pop_in(state.crash_groups[group_name])
10098
state
10199
end
102100

103101
defp exec_handle_crash_group_down(
104102
group_name,
105103
state
106104
) do
107-
crash_group = get_in(state, [:crash_groups, group_name])
105+
crash_group = state.crash_groups[group_name]
108106

109107
context_generator =
110108
&Component.context_from_state(&1,

lib/membrane/element/with_input_pads.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ defmodule Membrane.Element.WithInputPads do
3232
| Membrane.Element.Action.forward()
3333
], Element.state()}
3434
@doc """
35-
Callback invoked when element receives `Membrane.Event.StartOfStream` event.
35+
Callback invoked when element receives the first buffer from the specific pad, before `c:#{__MODULE__}.handle_buffer/4`.
3636
"""
3737
@callback handle_start_of_stream(
3838
pad :: Pad.ref(),

scripts/python/get_author_origin.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
print("COMMUNITY")
1717
except:
18-
print("An exception occurred, provided JSON:")
19-
print(membrane_team)
20-
print("provided PR_AUTHOR:", pr_author)
18+
print("An exception occurred in get_author_origin.py, provided JSON: ", membrane_team)
19+
print("Provided PR_AUTHOR: ", pr_author)
20+
sys.exit(1)

scripts/python/get_ticket_id.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
full_json = json.load(sys.stdin)
44
pr_url = sys.argv[1]
55

6-
try:
7-
project_items = full_json["items"]
8-
[id] = [item["id"] for item in project_items if ("url" in item["content"] and item["content"]["url"] == pr_url)]
9-
print(id)
10-
except:
11-
print("An exception occurred, provided JSON:")
12-
print(full_json)
13-
print("provided PR_URL:", pr_url)
6+
project_items = full_json["items"]
7+
8+
item_id = None
9+
for item in project_items:
10+
if "content" in item and "url" in item["content"]:
11+
if item["content"]["url"] == pr_url:
12+
item_id = item["id"]
13+
break
14+
15+
if item_id == None:
16+
print("Error occurred in get_ticket.py: ID of ticket related to PR", pr_url, "not found in the provided JSON")
17+
print("Provided JSON:", full_json)
18+
sys.exit(1)
19+
else:
20+
print(item_id)

0 commit comments

Comments
 (0)