-
-
Notifications
You must be signed in to change notification settings - Fork 48
110 lines (93 loc) · 3.88 KB
/
end-to-end.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
on:
pull_request:
branches:
- '*'
name: end-2-end
jobs:
end-2-end:
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
- uses: actions/checkout@v4
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- name: Cache R packages
uses: actions/cache@v4
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran('yaml')
shell: Rscript {0}
- name: Install package
run: R CMD INSTALL .
- name: Prepare pre-commit
run: |
config_name_test <- "pre-commit-config.yaml"
config_name <- paste0(".", config_name_test)
ref_config <- file.path("tests", "testthat", "reference-objects", config_name_test)
len_declared <- length(yaml::read_yaml(".pre-commit-hooks.yaml"))
len_testing <- length(yaml::read_yaml(ref_config)$repos[[1]]$hooks)
if (len_declared != len_testing) {
rlang::abort("You don't test all hooks. Add them to `test_path('reference-objects/pre-commit-config.yaml')`")
}
fs::file_delete(config_name)
fs::file_copy(ref_config, config_name)
shell: Rscript {0}
- name: Update Hook revision to current push
run: |
# hacky, maybe can use pre-commit try-repo?
# https://stackoverflow.com/questions/30871868/sed-replace-first-occurence-in-place-with-big-files
sed -i '' -e "1,/rev:.*/{s/rev:.*/rev: $GITHUB_SHA/;}" .pre-commit-config.yaml
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m 'current hash must be head'
- name: Run pre-commit
run: |
brew install pre-commit
pre-commit install --install-hooks
echo 'running R/test.R'
echo "#' some code\n#'\n#' @param here.\n#' @name somethings\nNULL" > R/test.R # overwrite if anything there
pre-commit run --files R/test.R
echo 'running DESCRIPTION'
cp tests/testthat/reference-objects/DESCRIPTION .
sleep 2
echo 'one' >> codemeta.json
pre-commit run --files DESCRIPTION
echo 'running README'
echo 'one' > README.Rmd
sleep 1
echo 'one' > README.md
git add README*
pre-commit run --files README.Rmd
echo 'running _pkgdown.yml'
cp tests/testthat/in/_pkgdown-index-articles.yml _pkgdown.yml
rm -rf man/
mkdir man
cp tests/testthat/in/autoupdate.Rd man/autoudpate.Rd
rm -rf vignettes
mkdir vignettes
cp tests/testthat/in/pkgdown.Rmd vignettes/
pre-commit run --files _pkgdown.yml
echo 'running man/autoupdate.Rd'
git reset HEAD --hard # restore initial state
git clean -f
rm -rf man/
mkdir -p man
cp tests/testthat/in/autoupdate.Rd man/
pre-commit run roxygenize --files man/autoupdate.Rd
git reset HEAD --hard # restore initial state
git clean -f
env:
SKIP: consistent-release-tag