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

BenchWeb/beta add #11

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Docker relies on lf in bash scripts - force it
*.sh text eol=lf

# treat bw as if shell script
bw text eol=lf
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
Before opening an issue, please make sure you have checked the documentation for help/answers at https://github.com/KhulnaSoft/BenchWeb/wiki

If this is a feature request, please check the project roadmaps first at https://github.com/KhulnaSoft/BenchWeb/projects

If this is a request for a new language/framework, please check the wiki at https://github.com/KhulnaSoft/BenchWeb/wiki/Suggested-Frameworks,-Languages-and-Features and
make sure it's not already there.

If this issue is related to personal benchmarking numbers versus official round results, please make sure you are testing on the same commit that the round was released on and that your machine setup is similar to the specs listed for that round otherwise it will be extremely difficult to reproduce results. Rounds are tagged at https://github.com/KhulnaSoft/BenchWeb/releases

For errors with setup, frameworks, or the benchmarks, please make sure you are on the most current `master` branch. Provide as many logs as possible. For larger logs you can use http://sprunge.us/ then follow the template below:
-->

### OS (Please include kernel version)

### Expected Behavior

### Actual Behavior

### Steps to reproduce behavior

### Other details and logs
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
Thank you for submitting to the KhulnaSoft Framework Benchmarks!

If you are submitting a new framework, please make sure that an appropriate `README.md` is added in your framework directory with information about the framework and a link to its homepage and documentation.

For new frameworks, please do not include source code that isn't required for the benchmarks.

Some examples of files that should not be included:

* Functional tests, such as JUnit tests in a `src/test` directory in Java frameworks.
* Startup scripts for launching the framework's application directly without going through BW.
* Local development configs used on the developer's workstation but not in BW.

If you are editing an existing test, please update the `README.md` for that test where appropriate.
-->
164 changes: 164 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: build
on: [ push, pull_request ]

jobs:
setup:
runs-on: ubuntu-22.04
steps:
- name: Save PR number
if: github.event_name == 'pull_request'
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
- uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: pr
path: pr/

- uses: actions/checkout@v4
with:
fetch-depth: 10

- name: Get commit branch and commit message from push
if: github.event_name == 'push'
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
echo "$(git log --format=%B -n 1 HEAD)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "PREVIOUS_COMMIT=$(git log --format=%H -n 1 HEAD~1)" >> $GITHUB_ENV

- name: Get commit branch and commit message from PR
if: github.event_name == 'pull_request'
run: |
echo "BRANCH_NAME=$GITHUB_HEAD_REF" >> $GITHUB_ENV
echo "TARGET_BRANCH_NAME=$(echo ${GITHUB_BASE_REF##*/})" >> $GITHUB_ENV
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
echo "$(git log --format=%B -n 1 HEAD^2)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "PREVIOUS_COMMIT=$(git log --format=%H -n 1 HEAD^2~1)" >> $GITHUB_ENV

Comment on lines +23 to +41
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix shell script security and reliability issues

The current shell scripts have several potential issues that could affect reliability:

  1. Unquoted variables that could cause word splitting
  2. Inefficient use of echo with command substitution
  3. Multiple redirects that could be combined

Apply these improvements to both push and PR event handlers:

- echo "BRANCH_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
- echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
- echo "$(git log --format=%B -n 1 HEAD)" >> $GITHUB_ENV
- echo "EOF" >> $GITHUB_ENV
+ {
+   echo "BRANCH_NAME=${GITHUB_REF##*/}"
+   echo "COMMIT_MESSAGE<<EOF"
+   git log --format=%B -n 1 HEAD
+   echo "EOF"
+ } >> "$GITHUB_ENV"

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 actionlint

25-25: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


25-25: shellcheck reported issue in this script: SC2116:style:1:19: Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'

(shellcheck)


25-25: shellcheck reported issue in this script: SC2086:info:1:26: Double quote to prevent globbing and word splitting

(shellcheck)


25-25: shellcheck reported issue in this script: SC2086:info:1:49: Double quote to prevent globbing and word splitting

(shellcheck)


25-25: shellcheck reported issue in this script: SC2086:info:2:31: Double quote to prevent globbing and word splitting

(shellcheck)


25-25: shellcheck reported issue in this script: SC2005:style:3:6: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'

(shellcheck)


25-25: shellcheck reported issue in this script: SC2086:info:3:44: Double quote to prevent globbing and word splitting

(shellcheck)


25-25: shellcheck reported issue in this script: SC2086:info:4:15: Double quote to prevent globbing and word splitting

(shellcheck)


25-25: shellcheck reported issue in this script: SC2086:info:5:62: Double quote to prevent globbing and word splitting

(shellcheck)


34-34: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


34-34: shellcheck reported issue in this script: SC2086:info:1:40: Double quote to prevent globbing and word splitting

(shellcheck)


34-34: shellcheck reported issue in this script: SC2116:style:2:26: Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'

(shellcheck)


34-34: shellcheck reported issue in this script: SC2086:info:2:33: Double quote to prevent globbing and word splitting

(shellcheck)


34-34: shellcheck reported issue in this script: SC2086:info:2:61: Double quote to prevent globbing and word splitting

(shellcheck)


34-34: shellcheck reported issue in this script: SC2086:info:3:31: Double quote to prevent globbing and word splitting

(shellcheck)


34-34: shellcheck reported issue in this script: SC2005:style:4:6: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'

(shellcheck)


34-34: shellcheck reported issue in this script: SC2086:info:4:46: Double quote to prevent globbing and word splitting

(shellcheck)


34-34: shellcheck reported issue in this script: SC2086:info:5:15: Double quote to prevent globbing and word splitting

(shellcheck)


34-34: shellcheck reported issue in this script: SC2086:info:6:64: Double quote to prevent globbing and word splitting

(shellcheck)

- uses: actions/setup-python@v5
with:
python-version: '3.10'
architecture: 'x64'

- name: Get all changes vs master
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
echo "DIFF<<EOF" >> $GITHUB_ENV
echo "$(./benchmarks/github_actions/github_actions_diff.py)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Determine which (if any) tests need to be run
run: |
echo "RUN_TESTS<<EOF" >> $GITHUB_ENV
echo "$(grep -oP "github-actions-run-tests \K(.*)" <<< $DIFF || true)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- id: event_out
name: Write event outputs
run: |
delimiter="$(openssl rand -hex 8)"
{
echo "commit_message<<${delimiter}"
echo "$COMMIT_MESSAGE"
echo "${delimiter}"
} >> $GITHUB_OUTPUT
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "target_branch_name=$TARGET_BRANCH_NAME" >> $GITHUB_OUTPUT
echo "previous_commit=$PREVIOUS_COMMIT" >> $GITHUB_OUTPUT

- id: verify_out
name: Write verify job matrix
run: |
VERIFY_MATRIX=$(find frameworks -maxdepth 1 -mindepth 1 -type d -printf '%f\n' | \
jq -Rc --arg tests "$RUN_TESTS" '.+"/" | select(inside($tests)) | rtrimstr("/")' | \
jq -sc '{include: map({TESTLANG: .})}' || echo '{"include": []}')
echo "verify_matrix=$VERIFY_MATRIX" >> $GITHUB_OUTPUT

outputs:
commit_message: ${{ steps.event_out.outputs.commit_message }}
branch_name: ${{ steps.event_out.outputs.branch_name }}
target_branch_name: ${{ steps.event_out.outputs.target_branch_name }}
previous_commit: ${{ steps.event_out.outputs.previous_commit }}
verify_matrix: ${{ steps.verify_out.outputs.verify_matrix }}

verify:
needs: setup
if: ${{ !contains(needs.setup.outputs.commit_message, '[ci skip]') && contains(needs.setup.outputs.verify_matrix, 'TESTLANG') }}
runs-on: ubuntu-22.04
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.verify_matrix) }}
fail-fast: false
env:
TESTLANG: ${{ matrix.TESTLANG }}
TESTDIR: ${{ matrix.TESTDIR }}
COMMIT_MESSAGE: ${{ needs.setup.outputs.commit_message }}
BRANCH_NAME: ${{ needs.setup.outputs.branch_name }}
TARGET_BRANCH_NAME: ${{ needs.setup.outputs.target_branch_name }}
PREVIOUS_COMMIT: ${{ needs.setup.outputs.previous_commit }}
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 10
- uses: actions/setup-python@v5
with:
python-version: '3.10'
architecture: 'x64'

- name: Get all changes vs master
run: |
echo "DIFF<<EOF" >> $GITHUB_ENV
echo "$(./benchmarks/github_actions/github_actions_diff.py)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- id: should_run_tests
name: Determine which (if any) tests need to be run
run: |
echo "RUN_TESTS<<EOF" >> $GITHUB_ENV
echo "$(grep -oP "github-actions-run-tests \K(.*)" <<< $DIFF || true)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Log status
run: |
if [ "$RUN_TESTS" ]; then echo "Proceeding to run tests."; else echo 'Skipping test verification.'; fi

- name: Build bw dockerfile
if: ${{ env.RUN_TESTS }}
uses: mattes/cached-docker-build-action@v1
with:
args: " --file infrastructure/docker/Dockerfile --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --tag khulnasoft/bw ."
cache_key: "${{ hashFiles('infrastructure/docker/Dockerfile') }}"

- name: Stop services
run: |
sudo service mysql stop || true
sudo service postgresql stop || true

- name: Run tests if needed
if: ${{ env.RUN_TESTS }}
run: |
docker network create bw > /dev/null 2>&1 && docker run --network=bw -e USER_ID=$(id -u) -v /var/run/docker.sock:/var/run/docker.sock --mount type=bind,source=`pwd`,target=/BenchWeb khulnasoft/bw --mode verify --test-dir $RUN_TESTS --results-environment Github-Actions;

Comment on lines +143 to +146
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix Docker command security issues

The Docker run command has potential security issues with unquoted paths and insufficient error handling.

- docker network create bw > /dev/null 2>&1 && docker run --network=bw -e USER_ID=$(id -u) -v /var/run/docker.sock:/var/run/docker.sock --mount type=bind,source=`pwd`,target=/BenchWeb khulnasoft/bw --mode verify --test-dir $RUN_TESTS --results-environment Github-Actions;
+ docker network inspect bw >/dev/null 2>&1 || docker network create bw
+ docker run \
+   --network=bw \
+   -e "USER_ID=$(id -u)" \
+   -v /var/run/docker.sock:/var/run/docker.sock \
+   --mount "type=bind,source=$(pwd),target=/BenchWeb" \
+   khulnasoft/bw \
+   --mode verify \
+   --test-dir "$RUN_TESTS" \
+   --results-environment Github-Actions
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if: ${{ env.RUN_TESTS }}
run: |
docker network create bw > /dev/null 2>&1 && docker run --network=bw -e USER_ID=$(id -u) -v /var/run/docker.sock:/var/run/docker.sock --mount type=bind,source=`pwd`,target=/BenchWeb khulnasoft/bw --mode verify --test-dir $RUN_TESTS --results-environment Github-Actions;
if: ${{ env.RUN_TESTS }}
run: |
docker network inspect bw >/dev/null 2>&1 || docker network create bw
docker run \
--network=bw \
-e "USER_ID=$(id -u)" \
-v /var/run/docker.sock:/var/run/docker.sock \
--mount "type=bind,source=$(pwd),target=/BenchWeb" \
khulnasoft/bw \
--mode verify \
--test-dir "$RUN_TESTS" \
--results-environment Github-Actions
🧰 Tools
🪛 actionlint

142-142: shellcheck reported issue in this script: SC2046:warning:1:81: Quote this to prevent word splitting

(shellcheck)


142-142: shellcheck reported issue in this script: SC2046:warning:1:160: Quote this to prevent word splitting

(shellcheck)


142-142: shellcheck reported issue in this script: SC2006:style:1:160: Use $(...) notation instead of legacy backticks ...

(shellcheck)


142-142: shellcheck reported issue in this script: SC2086:info:1:222: Double quote to prevent globbing and word splitting

(shellcheck)

dependabot:
needs: verify
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
37 changes: 37 additions & 0 deletions .github/workflows/get-maintainers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: get-maintainers
on:
pull_request:
types: [opened, reopened]
permissions:
pull-requests: write
jobs:
get_maintainers:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 10
- name: Get commit branch and commit message from PR
run: |
echo "BRANCH_NAME=$GITHUB_HEAD_REF" >> $GITHUB_ENV
echo "TARGET_BRANCH_NAME=$(echo ${GITHUB_BASE_REF##*/})" >> $GITHUB_ENV
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
echo "$(git log --format=%B -n 1 HEAD^2)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "PREVIOUS_COMMIT=$(git log --format=%H -n 1 HEAD^2~1)" >> $GITHUB_ENV
- uses: actions/setup-python@v5
with:
python-version: '3.10'
architecture: 'x64'
- name: Save PR number
run: |
mkdir -p ./maintainers
echo ${{ github.event.number }} > ./maintainers/NR
- name: Get Maintainers
run: |
python ./benchmarks/github_actions/get_maintainers.py > ./maintainers/maintainers.md
- name: Save Maintainers
uses: actions/upload-artifact@v4
with:
name: maintainers
path: maintainers/
46 changes: 46 additions & 0 deletions .github/workflows/label-failing-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Label PR if failed
on:
workflow_run:
workflows: [ "build" ]
types:
- completed
jobs:
apply_label:
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' }}
runs-on: ubuntu-22.04
steps:
- name: 'Download artifact'
uses: actions/github-script@v7
with:
# scripts lightly modified from https://securitylab.github.com/research/github-actions-preventing-pwn-requests
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: Label PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var fs = require('fs');
var issue_number = Number(fs.readFileSync('./NR'));
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
labels: ['PR: Please Update']
});
49 changes: 49 additions & 0 deletions .github/workflows/ping-maintainers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Ping Maintainers
on:
workflow_run:
workflows: [ "get-maintainers"]
types:
- completed
permissions:
pull-requests: write
jobs:
ping_maintainers:
runs-on: ubuntu-22.04
steps:
- name: 'Download maintainers artifact'
uses: actions/github-script@v7
with:
script: |
let artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
let matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "maintainers"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync('${{github.workspace}}/maintainers.zip', Buffer.from(download.data));
- run: unzip maintainers.zip
- name: Ping maintainers
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let fs = require('fs');
let issue_number = Number(fs.readFileSync('./NR'));
let maintainers_comment = fs.readFileSync('./maintainers.md', 'utf8');
if (maintainers_comment) {
await github.rest.issues.createComment({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: maintainers_comment
});
}
Loading
Loading