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

Update signature of compare/diff built-in functions step by step #1052

Merged
merged 7 commits into from
Oct 4, 2024

Conversation

k1LoW
Copy link
Owner

@k1LoW k1LoW commented Oct 2, 2024

ref: #1047

Because variadic arguments like Go cannot be used in expr-lang.

While accepting both arguments, deprecate the variadic argument type.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@k1LoW k1LoW force-pushed the main branch 2 times, most recently from d2e08c7 to 68d8c0f Compare October 2, 2024 08:36
Copy link
Contributor

github-actions bot commented Oct 2, 2024

BenchmarkManyRunbooks-4

main (-) #1052 (f70567e) +/-
Number of iterations 1 1 0
Nanoseconds per iteration 3,870,825,510 ns/op 3,842,553,839 ns/op -28,271,671 ns/op
Bytes allocated per iteration 1,785,405,920 B/op 1,785,331,808 B/op -74,112 B/op
Allocs per iteration 21,132,836 allocs/op 21,132,797 allocs/op -39 allocs/op
Metadata
main (-) #1052 (f70567e)
goos linux linux
goarch amd64 amd64
pkg github.com/k1LoW/runn github.com/k1LoW/runn
cpu AMD EPYC 7763 64-Core Processor AMD EPYC 7763 64-Core Processor

BenchmarkOpenAPI3-4

main (-) #1052 (f70567e) +/-
Number of iterations 1 1 0
Nanoseconds per iteration 4,834,484,769 ns/op 4,869,661,937 ns/op 35,177,168 ns/op
Bytes allocated per iteration 2,218,956,536 B/op 2,219,021,736 B/op 65,200 B/op
Allocs per iteration 30,863,455 allocs/op 30,867,050 allocs/op 3,595 allocs/op
Metadata
main (-) #1052 (f70567e)
goos linux linux
goarch amd64 amd64
pkg github.com/k1LoW/runn github.com/k1LoW/runn
cpu AMD EPYC 7763 64-Core Processor AMD EPYC 7763 64-Core Processor

BenchmarkSingleRunbook-4

main (-) #1052 (f70567e) +/-
Number of iterations 16 16 0
Nanoseconds per iteration 66,733,070 ns/op 66,843,365 ns/op 110,295 ns/op
Bytes allocated per iteration 60,097,767 B/op 60,096,935 B/op -832 B/op
Allocs per iteration 205,365 allocs/op 205,374 allocs/op 9 allocs/op
Metadata
main (-) #1052 (f70567e)
goos linux linux
goarch amd64 amd64
pkg github.com/k1LoW/runn github.com/k1LoW/runn
cpu AMD EPYC 7763 64-Core Processor AMD EPYC 7763 64-Core Processor

Reported by octocov

Copy link
Contributor

github-actions bot commented Oct 2, 2024

Code Metrics Report

main (68d8c0f) #1052 (f70567e) +/-
Coverage 64.4% 64.4% -0.1%
Code to Test Ratio 1:0.7 1:0.7 -0.1
Test Execution Time - 5m38s +5m38s
Details
  |                     | main (68d8c0f) | #1052 (f70567e) |  +/-   |
  |---------------------|----------------|-----------------|--------|
- | Coverage            |          64.4% |           64.4% |  -0.1% |
  |   Files             |             77 |              77 |      0 |
  |   Lines             |           8666 |            8682 |    +16 |
+ |   Covered           |           5589 |            5597 |     +8 |
- | Code to Test Ratio  |          1:0.7 |           1:0.7 |   -0.1 |
  |   Code              |          15941 |           15973 |    +32 |
+ |   Test              |          11663 |           11664 |     +1 |
- | Test Execution Time |              - |           5m38s | +5m38s |

Code coverage of files in pull request scope (75.7% → 75.4%)

Files Coverage +/-
book.go 79.0% 0.0%
builtin/compare.go 75.0% 0.0%
builtin/diff.go 70.5% -2.7%
eval.go 83.0% +0.7%
internal/deprecation/warning.go 59.0% +59.0%
operator.go 80.3% 0.0%
parse.go 73.1% 0.0%
runner_option.go 35.1% 0.0%

Reported by octocov

@k1LoW
Copy link
Owner Author

k1LoW commented Oct 2, 2024

@k2tzumi
I'd be glad to get your feedback on this change.

Copy link
Collaborator

@k2tzumi k2tzumi left a comment

Choose a reason for hiding this comment

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

I have included below a comment expressing my feelings
#1047 (comment)

Comment on lines +18 to +20
if len(ignores) > 1 {
deprecation.AddWarning("diff/compare", "diff/compare(x, y, ignores...string) is deprecated. Use diff/compare(x, y, ignores []string) instead.")
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understood that it would be phased out.

Comment on lines +26 to +33
case []any:
for _, vv := range v {
s, ok := vv.(string)
if !ok {
return "", fmt.Errorf("invalid ignore specifiers: %v", vv)
}
ignoreSpecifiers = append(ignoreSpecifiers, s)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Currently accepting ANY for compatibility, so it needs to be checked.

@@ -25,7 +52,7 @@ func Diff(x, y any, ignorePaths ...string) (string, error) {
return "", err
}

jqIgnorePaths, cmpIgnoreKeys := impl.splitIgnoreSpecifiers(ignorePaths)
jqIgnorePaths, cmpIgnoreKeys := impl.splitIgnoreSpecifiers(ignoreSpecifiers)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This process will also be unnecessary in the future.

Comment on lines +3 to +9
merge:
test: |
compare(
{"a": 1, "b": 3, "c": 5},
{"a": 1, "b": 2, "c": 4},
"b", "c"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test here will fail in the future.

@k1LoW k1LoW merged commit 90686ed into main Oct 4, 2024
8 checks passed
@k1LoW k1LoW deleted the fix-compare-sig branch October 4, 2024 01:57
@github-actions github-actions bot mentioned this pull request Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants