Skip to content

Commit

Permalink
Update run_benchmarks.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmesamster committed Aug 8, 2024
1 parent e73432a commit a16d5ff
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
40 changes: 24 additions & 16 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install pre-requisite dependencies
run: |
sudo apt-get update && sudo apt-get install -y gconf-service libgbm-dev libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release xdg-utils wget ca-certificates
sudo apt-get install -y libudev-dev cargo npm imagemagick libmagickwand-dev cmake
sudo apt-get install -y libudev-dev cargo npm imagemagick libmagickwand-dev cmake jq
- name: install node
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -74,21 +74,25 @@ jobs:
- name: Get PR details
if: github.event_name == 'workflow_dispatch'
id: pr_details
uses: actions/github-script@v6
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const pr_id = parseInt(core.getInput('pr_id'));
const { data: pr } = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr_id,
return github.rest.pulls.get({
owner: 'esrlabs',
repo: 'chipmunk',
pull_number: ${{ github.event.inputs.pr_id }}
});
return {
owner: pr.head.repo.owner.login,
repo: pr.head.repo.name
};
- name: Set PR details
if: github.event_name == 'workflow_dispatch'
run: |
PR_OWNER=$(echo '${{ steps.pr_details.outputs.result }}' | jq -r .data.head.repo.owner.login);
PR_REPO=$(echo '${{ steps.pr_details.outputs.result }}' | jq -r .data.head.repo.name);
echo "owner is $PR_OWNER";
echo "repo is $PR_REPO";
echo "PR_OWNER=$PR_OWNER" >> $GITHUB_ENV
echo "PR_REPO=$PR_REPO" >> $GITHUB_ENV
- name: Run Jasmine performance tests for the latest release
if: github.event_name != 'workflow_dispatch'
run: |
Expand All @@ -103,16 +107,20 @@ jobs:
- name: Run Jasmine performance tests for the latest pull request
if: github.event_name == 'workflow_dispatch'
run: |
echo "owner is ${{ env.PR_OWNER }}";
echo "repo is ${{ env.PR_REPO }}";
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
export PATH="/root/.cargo/bin:$PATH"
. "/root/.cargo/env"
source ~/.bashrc
echo "PR head repo: ${{ steps.pr_details.outputs.owner }}"
echo "PR head owner: ${{ steps.pr_details.outputs.repo }}"
echo "PR head repo: ${{ env.PR_OWNER }}"
echo "PR head owner: ${{ env.PR_REPO }}"
pwd
ls -la
ruby scripts/tools/run_benchmarks.rb PR~${{ github.event.inputs.pr_id }}
env:
REPO_NAME: ${{ steps.pr_details.outputs.repo }}
REPO_OWNER: ${{ steps.pr_details.outputs.owner }}
REPO_NAME: ${{ env.PR_REPO }}
REPO_OWNER: ${{ env.PR_OWNER }}
- name: List files in the results folder
run: |
echo "Event is: ${{ github.event_name }}"
Expand Down Expand Up @@ -151,4 +159,4 @@ jobs:
git remote set-url origin "https://esrlabs:${{secrets.DOCS_PUSH_TOKEN}}@github.com/esrlabs/chipmunk-docs"
git add ./jekyll/benchmarks/data/pull_request/Benchmark_PR_${{ github.event.inputs.pr_id }}.json
git commit -m "Adding PR benchmark results for chipmunk PR # ${{ github.event.inputs.pr_id }}"
git push origin master
git push origin master
10 changes: 5 additions & 5 deletions scripts/tools/run_benchmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def set_environment_vars
'JASMIN_TEST_CONFIGURATION' => './spec/benchmarks.json',
'PERFORMANCE_RESULTS_FOLDER' => 'chipmunk_performance_results',
'PERFORMANCE_RESULTS' => '',
'SH_HOME_DIR' => "/chipmunk"
# 'SH_HOME_DIR' => "/Users/sameer.g.srivastava"
# 'SH_HOME_DIR' => "/chipmunk"
'SH_HOME_DIR' => "/Users/sameer.g.srivastava"
}
end

Expand Down Expand Up @@ -177,9 +177,9 @@ def update_performance_data(data, data_file_path)
benchmark_data = collect_latest_benchmark_data("#{env_vars['SH_HOME_DIR']}/#{env_vars['PERFORMANCE_RESULTS_FOLDER']}")

DATA_JSON_PATH = "#{env_vars['SH_HOME_DIR']}/#{env_vars['PERFORMANCE_RESULTS_FOLDER']}/data.json"
if !File.exist?(DATA_JSON_PATH) || benchmark_data.any? { |file| File.mtime(DATA_JSON_PATH) < File.mtime("#{env_vars['SH_HOME_DIR']}/#{env_vars['PERFORMANCE_RESULTS_FOLDER']}/#{file[:file_name]}") && !file[:file_name].start_with?('Benchmark_PR') }
update_performance_data(benchmark_data, DATA_JSON_PATH)
elsif parsed_arg[:type] == :pr
if parsed_arg[:type] == :pr
pr_data_filepath = "#{env_vars['SH_HOME_DIR']}/#{env_vars['PERFORMANCE_RESULTS_FOLDER']}/Benchmark_PR_#{pr_number}.json"
update_performance_data([read_benchmark_data(pr_data_filepath)], pr_data_filepath)
elsif !File.exist?(DATA_JSON_PATH) || benchmark_data.any? { |file| File.mtime(DATA_JSON_PATH) < File.mtime("#{env_vars['SH_HOME_DIR']}/#{env_vars['PERFORMANCE_RESULTS_FOLDER']}/#{file[:file_name]}") && !file[:file_name].start_with?('Benchmark_PR') }
update_performance_data(benchmark_data, DATA_JSON_PATH)
end

0 comments on commit a16d5ff

Please sign in to comment.