@@ -25,20 +25,41 @@ jobs:
25
25
echo "USER_TAGS=pull_request_number:${{ github.event.issue.number }},repository:OpenSearch" >> $GITHUB_ENV
26
26
- name : Check comment format
27
27
id : check_comment
28
- run : |
29
- comment='${{ github.event.comment.body }}'
30
- if echo "$comment" | jq -e 'has("run-benchmark-test")'; then
31
- echo "Valid comment format detected, check if valid config id is provided"
32
- config_id=$(echo $comment | jq -r '.["run-benchmark-test"]')
33
- benchmark_configs=$(cat .github/benchmark-configs.json)
34
- if echo $benchmark_configs | jq -e --arg id "$config_id" 'has($id)' && echo "$benchmark_configs" | jq -e --arg version "$OPENSEARCH_MAJOR_VERSION" --arg id "$config_id" '.[$id].supported_major_versions | index($version) != null' > /dev/null; then
35
- echo $benchmark_configs | jq -r --arg id "$config_id" '.[$id]."cluster-benchmark-configs" | to_entries[] | "\(.key)=\(.value)"' >> $GITHUB_ENV
36
- else
37
- echo "invalid=true" >> $GITHUB_OUTPUT
38
- fi
39
- else
40
- echo "invalid=true" >> $GITHUB_OUTPUT
41
- fi
28
+ uses : actions/github-script@v6
29
+ with :
30
+ script : |
31
+ const fs = require('fs');
32
+ const comment = context.payload.comment.body;
33
+ let commentJson;
34
+ try {
35
+ commentJson = JSON.parse(comment);
36
+ } catch (error) {
37
+ core.setOutput('invalid', 'true');
38
+ return;
39
+ }
40
+ if (!commentJson.hasOwnProperty('run-benchmark-test')) {
41
+ core.setOutput('invalid', 'true');
42
+ return;
43
+ }
44
+ const configId = commentJson['run-benchmark-test'];
45
+ let benchmarkConfigs;
46
+ try {
47
+ benchmarkConfigs = JSON.parse(fs.readFileSync('.github/benchmark-configs.json', 'utf8'));
48
+ } catch (error) {
49
+ core.setFailed('Failed to read benchmark-configs.json');
50
+ return;
51
+ }
52
+ const openSearchMajorVersion = process.env.OPENSEARCH_MAJOR_VERSION;
53
+ console.log('MAJOR_VERSION', openSearchMajorVersion)
54
+ if (!benchmarkConfigs.hasOwnProperty(configId) ||
55
+ !benchmarkConfigs[configId].supported_major_versions.includes(openSearchMajorVersion)) {
56
+ core.setOutput('invalid', 'true');
57
+ return;
58
+ }
59
+ const clusterBenchmarkConfigs = benchmarkConfigs[configId]['cluster-benchmark-configs'];
60
+ for (const [key, value] of Object.entries(clusterBenchmarkConfigs)) {
61
+ core.exportVariable(key, value);
62
+ }
42
63
- name : Post invalid format comment
43
64
if : steps.check_comment.outputs.invalid == 'true'
44
65
uses : actions/github-script@v6
0 commit comments