Repository navigation
117 lines (98 loc) · 4.15 KB
/
Copy pathperformance-tests.yml
File metadata and controls
117 lines (98 loc) · 4.15 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: atime performance tests
on:
pull_request:
paths:
- 'R/**'
- 'src/**'
- '.ci/atime/**'
- '.github/workflows/performance-tests.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: Start timer
shell: bash
run: echo "START_SETUP_TIME=$(date +%s)" >> "$GITHUB_ENV"
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Retrieve branch references, necessary for perf testing past versions
shell: bash
run: |
git branch -f "${GITHUB_BASE_REF}" "origin/${GITHUB_BASE_REF}"
HEAD_BRANCH="${GITHUB_HEAD_REF}"
if [ "$HEAD_BRANCH" = "$GITHUB_BASE_REF" ]; then
HEAD_BRANCH="pr-${{ github.event.number }}"
fi
git switch -C "$HEAD_BRANCH"
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
cache-version: ${{ hashFiles('.ci/atime/tests.R') }}
extra-packages: cran::data.table, any::atime, any::ggplot2, any::directlabels
- name: Run atime
shell: bash
run: |
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"
- name: Upload artifact
id: artifact-upload-step
uses: actions/upload-artifact@v7
with:
name: atime-results
path: .ci/atime/
- name: Post or update PR comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
shell: bash
run: |
uploadImage() {
curl --fail --retry 3 -sS -F "file=@$1" -F "visibility=unlisted" https://picrd.com/api/upload | jq -r '.image_url // empty' || true
}
PREVIEW_URL=$(uploadImage .ci/atime/tests_preview_facet.png)
ALL_URL=$(uploadImage .ci/atime/tests_all_facet.png)
if [ -n "$PREVIEW_URL" ] && [ -n "$ALL_URL" ]; then
PLOT_MD="[]($ALL_URL)"
else
PLOT_MD="*(Plot image upload to picrd.com failed; download the artifact below to view plots)*"
fi
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"
elif [ "$totalSeconds" -lt 60 ]; then
echo "${totalSeconds} seconds"
else
echo "$((totalSeconds / 60)) minutes and $((totalSeconds % 60)) seconds"
fi
}
ARTIFACT_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}"
cat <<EOF > comment.md
$(cat .ci/atime/HEAD_issues.md)
$PLOT_MD
Generated via commit ${{ github.event.pull_request.head.sha }}
Download link for the artifact containing the test results: [↓ atime-results.zip]($ARTIFACT_URL)
| Task | Duration |
|---|---|
| R setup and installing dependencies | $(formatTime "$R_SETUP_DURATION") |
| Installing different package versions | $(formatTime "$VERSION_SETUP_DURATION") |
| Running and plotting the test cases | $(formatTime "$ATIME_TESTS_DURATION") |
EOF
cat comment.md >> "$GITHUB_STEP_SUMMARY"
if [ "${{ github.event.pull_request.head.repo.full_name }}" = "$GITHUB_REPOSITORY" ]; then
gh pr comment "$PR_NUMBER" --edit-last --create-if-none -F comment.md
fi