mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
benchmarks: tweak per-PR benchmark regression check based on pr-check
We can't run them all. It's too much. Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
This commit is contained in:
committed by
Stephan Renatus
parent
7fe3066154
commit
68c9de5da0
@@ -15,6 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
go: ${{ steps.changes.outputs.go }}
|
||||
bench: ${{ steps.changes.outputs.bench }}
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
@@ -57,11 +58,14 @@ jobs:
|
||||
'data.policy["pr-check"]' > opa_result.json
|
||||
|
||||
go_result=$(jq -r '.changes.go // false' opa_result.json)
|
||||
bench_result=$(jq -c '.changes.bench // []' opa_result.json)
|
||||
|
||||
echo "go=${go_result}" >> $GITHUB_OUTPUT
|
||||
echo "bench=${bench_result}" >> $GITHUB_OUTPUT
|
||||
|
||||
echo "Final outputs:"
|
||||
echo " go=${go_result}"
|
||||
echo " bench=${bench_result}"
|
||||
|
||||
benchmarks:
|
||||
permissions:
|
||||
@@ -81,7 +85,7 @@ jobs:
|
||||
name: Check for regressions
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [check-changes]
|
||||
if: ${{ needs.check-changes.outputs.go == 'true' }}
|
||||
if: ${{ needs.check-changes.outputs.bench != '' && needs.check-changes.outputs.bench != '[]' }}
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
@@ -104,8 +108,9 @@ jobs:
|
||||
env:
|
||||
BEFORE_SHA: ${{ github.event.before }}
|
||||
AFTER_SHA: ${{ github.event.after }}
|
||||
BENCH_PKGS: ${{ needs.check-changes.outputs.bench }}
|
||||
run: |
|
||||
for pkg in ./v1/rego ./v1/topdown ./v1/ast; do
|
||||
for pkg in $(echo "$BENCH_PKGS" | jq -r '.[]'); do
|
||||
benchlab \
|
||||
-commit "$BEFORE_SHA","$AFTER_SHA" \
|
||||
-pkg "$pkg" \
|
||||
|
||||
@@ -63,7 +63,7 @@ go_root_files := [
|
||||
"main.go",
|
||||
]
|
||||
|
||||
changes["docs"] if {
|
||||
changes.docs if {
|
||||
some changed_file in input
|
||||
startswith(changed_file.filename, "docs/")
|
||||
} else if {
|
||||
@@ -71,7 +71,7 @@ changes["docs"] if {
|
||||
changed_file.filename in docs_root_files
|
||||
}
|
||||
|
||||
changes["go"] if {
|
||||
changes.go if {
|
||||
some changed_file in input
|
||||
endswith(changed_file.filename, ".go")
|
||||
} else if {
|
||||
@@ -83,7 +83,7 @@ changes["go"] if {
|
||||
changed_file.filename in go_root_files
|
||||
}
|
||||
|
||||
changes["wasm"] if {
|
||||
changes.wasm if {
|
||||
some changed_file in input
|
||||
strings.any_prefix_match(changed_file.filename, wasm_change_prefixes)
|
||||
} else if {
|
||||
@@ -91,7 +91,7 @@ changes["wasm"] if {
|
||||
changed_file.filename in rego_and_wasm_change_root_files
|
||||
}
|
||||
|
||||
changes["rego"] if {
|
||||
changes.rego if {
|
||||
some changed_file in input
|
||||
endswith(changed_file.filename, ".rego")
|
||||
} else if {
|
||||
@@ -99,7 +99,25 @@ changes["rego"] if {
|
||||
changed_file.filename in rego_and_wasm_change_root_files
|
||||
}
|
||||
|
||||
changes["yaml"] if {
|
||||
changes.yaml if {
|
||||
some changed_file in input
|
||||
strings.any_suffix_match(changed_file.filename, yaml_change_suffixes)
|
||||
}
|
||||
|
||||
changes.bench contains "./v1/ast" if {
|
||||
some changed_file in input
|
||||
startswith(changed_file.filename, "v1/ast/")
|
||||
endswith(changed_file.filename, ".go")
|
||||
}
|
||||
|
||||
changes.bench contains "./v1/topdown" if {
|
||||
some changed_file in input
|
||||
startswith(changed_file.filename, "v1/topdown/")
|
||||
endswith(changed_file.filename, ".go")
|
||||
}
|
||||
|
||||
changes.bench contains "./v1/rego" if {
|
||||
some changed_file in input
|
||||
startswith(changed_file.filename, "v1/rego/")
|
||||
endswith(changed_file.filename, ".go")
|
||||
}
|
||||
|
||||
@@ -47,6 +47,14 @@ example_gh_actions_changelist := [
|
||||
{"filename": ".github/workflows/pull-request.yaml"},
|
||||
]
|
||||
|
||||
example_bench_ast_changelist := [{"filename": "v1/ast/parser.go"}]
|
||||
|
||||
example_bench_topdown_changelist := [{"filename": "v1/topdown/eval.go"}]
|
||||
|
||||
example_bench_rego_changelist := [{"filename": "v1/rego/rego.go"}]
|
||||
|
||||
example_bench_no_match_changelist := [{"filename": "cmd/build.go"}]
|
||||
|
||||
test_run_docs_check_expect if {
|
||||
pr_check.changes.docs with input as example_docs_changelist
|
||||
}
|
||||
@@ -94,3 +102,20 @@ test_run_all_tests_expect if {
|
||||
pr_check.changes.wasm with input as example_all_checks_root_changelist
|
||||
not pr_check.changes.yaml with input as example_all_checks_root_changelist
|
||||
}
|
||||
|
||||
test_bench_ast_only if {
|
||||
pr_check.changes.bench == {"./v1/ast"} with input as example_bench_ast_changelist
|
||||
}
|
||||
|
||||
test_bench_topdown_only if {
|
||||
pr_check.changes.bench == {"./v1/topdown"} with input as example_bench_topdown_changelist
|
||||
}
|
||||
|
||||
test_bench_rego_only if {
|
||||
pr_check.changes.bench == {"./v1/rego"} with input as example_bench_rego_changelist
|
||||
}
|
||||
|
||||
test_bench_no_match if {
|
||||
pr_check.changes.go with input as example_bench_no_match_changelist
|
||||
pr_check.changes.bench == set() with input as example_bench_no_match_changelist
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user