Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark the job runtime plugin config as nullable #43

Merged
merged 11 commits into from
Dec 9, 2022

Conversation

tuliren
Copy link
Member

@tuliren tuliren commented Dec 9, 2022

Summary

  • Mark job_runtime as nullable.
  • Replace null plugin config with empty objects.
  • This is necessary because on the server side, we merge all runtime into only array. However, if the config is null, deepmerge will only keep the last value.
    • For example, when merging these objects with a null field:
      deepmerge({ a: null }, { a: { runtime: [1] } }, { a: { runtime: [2] } })
      // { a: { runtime: [2] } }
    • In contrast, when the object is empty:
      deepmerge({ a: {} }, { a: { runtime: [1] } }, { a: { runtime: [2] } })
      // { a: { runtime: [1, 2] } }
    • We need to keep all the values. So the conversion is necessary.

This PR resolves #32.

@stoat-app
Copy link

stoat-app bot commented Dec 9, 2022

Easy and customizable dashboards for your build system. Learn more about Stoat ↗︎

Static Hosting

Name Link Commit Status
Documentation Visit 788fa95
Action Test Coverage Visit 788fa95
Action Test Coverage (single file) Visit 788fa95

Job Runtime

debug

@tuliren tuliren requested a review from jrhizor December 9, 2022 21:21
@tuliren tuliren marked this pull request as ready for review December 9, 2022 21:21
Copy link
Contributor

@jrhizor jrhizor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kind of unfortunate that it needs to be wrapped.

@tuliren
Copy link
Member Author

tuliren commented Dec 9, 2022

It's kind of unfortunate that it needs to be wrapped.

The alternative solution is to provide a custom merging function to deepmerge. But I think the current solution is good enough, as long as we have clear comments and test cases.

@tuliren
Copy link
Member Author

tuliren commented Dec 9, 2022

Actually let me just try the custom merging function approach if it is really quick.

This reverts commit 13762df.
@tuliren
Copy link
Member Author

tuliren commented Dec 9, 2022

After a second thought, I think the current approach is better, because deepmerge is performed both on the server side and in the local mode. If we introduce a custom merging logic, we need to ensure that the logic is consistent in both places. With the current approach, that's not a concern.

@tuliren tuliren merged commit 5314ac0 into main Dec 9, 2022
@tuliren tuliren deleted the liren/nullable-job-runtime-plugin-config branch December 9, 2022 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow job_runtime plugin config to be null
2 participants