Skip to content

Commit 70e764f

Browse files
Merge pull request #898 from lorenzwalthert/toucstone-action
Use {touchstone} GitHub Action
2 parents bfa8309 + 13dab3b commit 70e764f

File tree

5 files changed

+13
-122
lines changed

5 files changed

+13
-122
lines changed
Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Continuous Benchmarks (Comment)
22

3-
concurrency:
4-
group: ${{ github.workflow }}-${{ github.head_ref }}
5-
cancel-in-progress: true
6-
73
# read-write repo token
84
# access to secrets
95
on:
@@ -19,38 +15,4 @@ jobs:
1915
${{ github.event.workflow_run.event == 'pull_request' &&
2016
github.event.workflow_run.conclusion == 'success' }}
2117
steps:
22-
- name: 'Download artifact'
23-
uses: actions/[email protected]
24-
with:
25-
script: |
26-
var artifacts = await github.actions.listWorkflowRunArtifacts({
27-
owner: context.repo.owner,
28-
repo: context.repo.repo,
29-
run_id: ${{github.event.workflow_run.id }},
30-
});
31-
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
32-
return artifact.name == "pr"
33-
})[0];
34-
var download = await github.actions.downloadArtifact({
35-
owner: context.repo.owner,
36-
repo: context.repo.repo,
37-
artifact_id: matchArtifact.id,
38-
archive_format: 'zip',
39-
});
40-
var fs = require('fs');
41-
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
42-
- run: unzip pr.zip
43-
- name: 'Comment on PR'
44-
uses: actions/github-script@v3
45-
with:
46-
github-token: ${{ secrets.GITHUB_TOKEN }}
47-
script: |
48-
var fs = require('fs');
49-
var issue_number = Number(fs.readFileSync('./NR'));
50-
var body = fs.readFileSync('./info.txt').toString();
51-
await github.issues.createComment({
52-
owner: context.repo.owner,
53-
repo: context.repo.repo,
54-
issue_number: issue_number,
55-
body: body
56-
});
18+
- uses: lorenzwalthert/touchstone/actions/comment@main
Lines changed: 5 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
name: Continuous Benchmarks (Receive)
2-
concurrency:
3-
group: ${{ github.workflow }}-${{ github.head_ref }}
4-
cancel-in-progress: true
5-
62
on: pull_request
73
jobs:
84
prepare:
@@ -37,78 +33,9 @@ jobs:
3733
RSPM: ${{ matrix.config.rspm }}
3834
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
3935
steps:
40-
- name: Checkout repo
41-
uses: actions/checkout@v2
42-
with:
43-
fetch-depth: 0
44-
- name: Set up git user
45-
run: |
46-
git config --local user.name "GitHub Actions"
47-
git config --local user.email "[email protected]"
48-
- name: Ensure base branch is fetched
49-
run: |
50-
git checkout -b $GITHUB_HEAD_REF # this is current ref. This is required for naming.
51-
git branch $GITHUB_BASE_REF remotes/origin/$GITHUB_BASE_REF
52-
- name: Setup R
53-
uses: r-lib/actions/setup-r@master
54-
- name: Query dependencies
55-
run: |
56-
install.packages('remotes')
57-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
58-
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
59-
shell: Rscript {0}
60-
- name: Cache R packages
61-
if: runner.os != 'Windows'
62-
uses: actions/cache@v1
63-
with:
64-
path: ${{ env.R_LIBS_USER }}
65-
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-3-${{ hashFiles('.github/depends.Rds') }}
66-
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-3-
67-
- name: Install system dependencies
68-
if: runner.os == 'Linux'
69-
env:
70-
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
71-
run: |
72-
Rscript -e "remotes::install_github('r-hub/sysreqs')"
73-
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
74-
sudo -s eval "$sysreqs"
75-
sudo apt-get install libcurl4-openssl-dev libgit2-dev
76-
- name: Install dependencies
77-
run: |
78-
remotes::install_deps(dependencies = TRUE)
79-
remotes::install_github("lorenzwalthert/touchstone")
80-
remotes::install_cran(c('ggplot2', 'dplyr'))
81-
pkg <- basename(getwd())
82-
if (pkg %in% rownames(installed.packages())) {
83-
remove.packages(pkg)
84-
cat('removed package ', pkg, '.', sep = "")
85-
}
86-
shell: Rscript {0}
87-
- name: Checkout benchmarking repo
88-
uses: actions/checkout@v2
89-
with:
90-
repository: ${{ matrix.config.benchmarking_repo }}
91-
ref: ${{ matrix.config.benchmarking_ref }}
92-
path: ${{ matrix.config.benchmarking_path }}
93-
- name: Run benchmarks
94-
run: Rscript -e 'touchstone::run_script("touchstone/script.R")'
95-
- name: Save PR number
96-
run: |
97-
echo ${{ github.event.number }} > ./touchstone/pr-comment/NR
98-
- uses: actions/upload-artifact@v2
99-
with:
100-
name: visual-benchmarks
101-
path: touchstone/plots/
102-
- uses: actions/upload-artifact@v1
103-
with:
104-
name: results
105-
path: touchstone/pr-comment
106-
- uses: actions/download-artifact@v1
107-
with:
108-
name: results
109-
- name: comment PR
110-
run: cat touchstone/pr-comment/info.txt
111-
- uses: actions/upload-artifact@v2
36+
- uses: lorenzwalthert/touchstone/actions/receive@main
11237
with:
113-
name: pr
114-
path: touchstone/pr-comment/
38+
cache-version: 1
39+
benchmarking_repo: ${{matrix.config.benchmarking_repo}}
40+
benchmarking_ref: ${{matrix.config.benchmarking_ref}}
41+
benchmarking_path: ${{matrix.config.benchmarking_path}}

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
* Enable pre-commit.ci (#843).
5757
* use pre-commit via GitHub Actions (#872).
5858
* terminate running jobs on new push to save resources (#888).
59+
* Use the {touchstone} GitHub Action instead of the literal script (#889).
5960

6061
# styler 1.6.2
6162

tests/testthat/test-cache-with-r-cache.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ test_that("top-level test: Caches top-level expressions efficiently on style_tex
4848

4949
skip_on_cran()
5050
expect_lt(
51-
partially_cached_benchmark["elapsed"] * 2.5,
51+
partially_cached_benchmark["elapsed"] * 2.4,
5252
not_cached_benchmark["elapsed"]
5353
)
54-
expect_lt(full_cached_benchmark["elapsed"] * 50, benchmark["elapsed"])
54+
expect_lt(full_cached_benchmark["elapsed"] * 45, benchmark["elapsed"])
5555
})
5656

5757

touchstone/config.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"os": "ubuntu-18.04",
3-
"r": "4.0.0",
2+
"os": "ubuntu-20.04",
3+
"r": "4.1.1",
4+
"rspm": "https://packagemanager.rstudio.com/all/__linux__/focal/2022-01-07+MTo3NDQwNTcyLDI6NDUyNjIxNTs0QzU3NUZBRQ",
45
"benchmarking_repo": "lorenzwalthert/here",
56
"benchmarking_ref": "bf0167746da7fe4fb156082bad93c9e5cd3386bd",
67
"benchmarking_path": "touchstone/sources/here",
7-
"rspm": "https://packagemanager.rstudio.com/cran/__linux__/bionic/2021-04-30"
8+
89
}

0 commit comments

Comments
 (0)