Skip to content

add atime CI

add atime CI #6

Workflow file for this run

name: Autocomment atime-based performance regression analysis on PRs
on:
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
comment:
runs-on: ubuntu-latest
container: ghcr.io/iterative/cml:0-dvc2-base1
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Start timer
run: echo "START_SETUP_TIME=$(date +%s)" >> $GITHUB_ENV
shell: bash
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Safe directory exception
run: |
git config --global --add safe.directory '*'
shell: bash
# To ensure local branch references exist and can be found when using git2r::revparse_single: (for more information, please check https://github.com/Anirban166/Autocomment-atime-results/issues/33#issuecomment-2038431272 and the comments below that)
- name: Retrieve branch references
run: |
git switch "${GITHUB_BASE_REF}"
git switch "${GITHUB_HEAD_REF}"
shell: bash
- name: Set up the required system dependency libgit2
run: |
sudo apt-get update -y && sudo apt-get install -y cmake libssl-dev
git clone --branch v1.6.4 --depth 1 https://github.com/libgit2/libgit2.git
cd libgit2 && mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make && sudo make install
cd ../..
shell: bash
- name: Install R packages (DESCRIPTION-specified deps)
uses: r-lib/actions/setup-r-dependencies@v2
- name: Install required dependencies and initiate atime magic
run: |
Rscript -e 'install.packages(c("atime", "remotes", "ggplot2", "directlabels"))'
Rscript -e 'remotes::install_github("tdhock/atime@poncatime")'
echo "END_SETUP_START_TESTS_TIME=$(date +%s)" >> $GITHUB_ENV
Rscript -e 'atime::atime_pkg(Sys.getenv("GITHUB_WORKSPACE"), tests.dir = ".ci");'
echo "END_TESTS_TIME=$(date +%s)" >> $GITHUB_ENV
shell: bash
- name: Upload results
id: artifact-upload-step
uses: actions/upload-artifact@v4
with:
name: atime-results
path: .ci/atime/
- name: Push generated plot along with relevant information on the PR thread as a GH-bot comment
run: |
R_SETUP_DURATION=$((END_SETUP_START_TESTS_TIME - START_SETUP_TIME))
VERSION_SETUP_DURATION=$(cut -d '.' -f 1 ./.ci/atime/install_seconds.txt)
ATIME_TESTS_DURATION=$((END_TESTS_TIME - END_SETUP_START_TESTS_TIME - VERSION_SETUP_DURATION))
formatTime() {
local totalSeconds=$1
if [ $totalSeconds -lt 0 ]; then
echo "Time calculation error: negative duration"
return
fi
if [ $totalSeconds -lt 60 ]; then
echo "${totalSeconds} seconds"
else
local minutes=$((totalSeconds / 60))
local seconds=$((totalSeconds % 60))
echo "${minutes} minutes and ${seconds} seconds"
fi
}
# Comment contents:
cat .ci/atime/HEAD_issues.md >> report.md
echo -e "\n[![Comparison Plot](./.ci/atime/tests_preview_facet.png)](./.ci/atime/tests_all_facet.png)" >> report.md
echo -e "\nGenerated via commit ${{ github.event.pull_request.head.sha }}" >> report.md
echo -e "\nDownload link for the artifact containing the test results: [↓ atime-results.zip](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }})" >> report.md
echo -e "\n| Task | Duration |" >> report.md
echo -e "|---|---|" >> report.md
echo -e "| R setup and installing dependencies | $(formatTime $R_SETUP_DURATION) |" >> report.md
echo -e "| Installing different package versions | $(formatTime $VERSION_SETUP_DURATION) |" >> report.md
echo -e "| Running and plotting the test cases | $(formatTime $ATIME_TESTS_DURATION) |" >> report.md
cml comment update report.md
shell: bash