forked from Rdatatable/data.table
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (80 loc) · 3.38 KB
/
autocomment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Autocomment atime-based performance regression analysis on PRs
on:
pull_request:
branches:
- '*'
types:
- opened
- reopened
- synchronize
jobs:
comment:
runs-on: ubuntu-latest
container: ghcr.io/iterative/cml:0-dvc2-base1
steps:
- name: Start timer
run: echo "START_SETUP_TIME=$(date +%s)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: safe-dir-check
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory '*'
# 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: R Setup
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Set up the required system dependency libgit2
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
run: |
sudo apt-get update -y
sudo apt-get install -y libgit2-dev
- name: Install atime and initiate magic
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
run: |
cp /github/home/.Rprofile .
echo "options(repos = c(CRAN = 'https://cloud.r-project.org'))" >> .Rprofile
Rscript -e 'install.packages("atime", dependencies = TRUE);'
echo "END_SETUP_START_TESTS_TIME=$(date +%s)" >> $GITHUB_ENV
Rscript -e 'atime::atime_pkg(Sys.getenv("GITHUB_WORKSPACE"));'
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: inst/atime/
- name: Push generated plot along with relevant information on the PR thread as a GH-bot comment
env:
repo_token: ${{ secrets.GITHUB_TOKEN }}
run: |
SETUP_DURATION=$((END_SETUP_START_TESTS_TIME - START_SETUP_TIME))
ATIME_TESTS_DURATION=$((END_TESTS_TIME - END_SETUP_START_TESTS_TIME))
formatTime() {
local totalSeconds=$1
if [ $totalSeconds -lt 0 ]; then
echo "Time calculation error: negative duration"
return
fi
local minutes=$((totalSeconds / 60))
local seconds=$((totalSeconds % 60))
echo "${minutes} minutes and ${seconds} seconds"
}
echo "![Comparison Plot](./inst/atime/tests_all_facet.png)" >> report.md
echo "\nGenerated via commit ${{ github.event.pull_request.head.sha }}" >> report.md
echo "\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 "\nTime taken to finish the standard R installation steps: $(formatTime $SETUP_DURATION)" >> report.md
echo "\nTime taken to run \`atime::atime_pkg\` on the tests: $(formatTime $ATIME_TESTS_DURATION)" >> report.md
cml comment update report.md