Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
description: perform a spell check with spelling::spell_check_files()
entry: inst/bin/spell-check
language: script
exclude: '(\.[rR]$|\.py$|/?\.gitignore$|^\.pre-commit|^NAMESPACE$|^inst/WORDLIST$)'
exclude: '(\.[rR]$|\.py$|/?\.gitignore$|^\.pre-commit|^NAMESPACE$|^inst/WORDLIST$|^\.travis.yml$)'
require_serial: true
- id: deps-in-desc
name: deps-in-desc
Expand Down
37 changes: 27 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@ before_install:
- R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")'
- R -q -e 'remotes::install_github("ropenscilabs/tic"); print(tic::dsl_load()); tic::prepare_all_stages()'
- R -q -e 'tic::before_install()'
install:
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- rm miniconda.sh
- R -q -e 'tic::install()'
after_install: R -q -e 'tic::after_install()'
install: R -q -e 'tic::install()'
before_script: R -q -e 'tic::before_script()'
script: R -q -e 'tic::script()'
after_success: R -q -e 'tic::after_success()'
Expand All @@ -34,6 +25,32 @@ after_script: R -q -e 'tic::after_script()'
# DO NOT CHANGE THE CODE ABOVE

# Custom parts:
jobs:
include:
- name: r_linux # install pre-commit from R
stage: before_script
script:
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- rm miniconda.sh
- R -q -e 'tic::before_script()'
- name: r_macOs
os: osx
stage: before_script
script:
- R -q -e 'if (!requireNamespace("reticulate")) install.packages("reticulate"); reticulate::install_miniconda()'
- R -q -e 'tic::before_script()'
- name: external_linux # install pre-commit outside
env:
- EXTERNAL_INSTALLATION="TRUE"
stage: before_script
script:
- pip install pre-commit --user
- R -q -e 'tic::before_script()'

language: r
sudo: false
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- Unify vignettes on available hooks and arguments (#109).
- Fail fast when repo is not a git repo (#111).
- default config file has spell-check activated (#118).
- also test on macOS (#120).
- test if pre-commit was installed via pip (#120).

# precommit 0.0.0.9017

Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ json
lintr
lorenz
lorenzwalthert
macOS
maxkb
md
parsable
Expand Down
2 changes: 1 addition & 1 deletion inst/pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
description: perform a spell check with spelling::spell_check_files()
entry: inst/bin/spell-check
language: script
exclude: '(\.[rR]$|\.py$|/?\.gitignore$|^\.pre-commit|^NAMESPACE$|^inst/WORDLIST$)'
exclude: '(\.[rR]$|\.py$|/?\.gitignore$|^\.pre-commit|^NAMESPACE$|^inst/WORDLIST$|^\.travis.yml$)'
require_serial: true
- id: deps-in-desc
name: deps-in-desc
Expand Down
37 changes: 24 additions & 13 deletions tests/testthat/test-conda.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
tempdir <- fs::path(tempdir(), "test-precommit")
fs::dir_create(tempdir)
git2r::init(path = tempdir)

test_that("can install pre-commit", {
skip_if(as.logical(Sys.getenv("EXTERNAL_INSTALLATION")))
expect_error(install_precommit(), NA)
})

test_that("can use pre-commit", {
expect_output(
{
git2r::init(path = tempdir)
use_precommit(open = FALSE, force = TRUE, path_root = tempdir)
},
use_precommit(open = FALSE, force = TRUE, path_root = tempdir),
"to get the latest"
)
})
Expand Down Expand Up @@ -71,22 +72,32 @@ test_that("Can uninstall pre-commit (repo scope)", {
})

test_that("Can uninstall (globally)", {
expect_output(
uninstall_precommit(scope = "global", ask = "none"),
"Removed pre-commit from"
)
expect_error(
uninstall_precommit(scope = "global", ask = "none"),
"No installation found."
)
if (isTRUE(as.logical(Sys.getenv("EXTERNAL_INSTALLATION")))) {
expect_error(
uninstall_precommit(scope = "global", ask = "none", path_root = tempdir),
"installed with conda"
)
} else {
expect_output(
uninstall_precommit(scope = "global", ask = "none"),
"Removed pre-commit from"
)
expect_error(
uninstall_precommit(scope = "global", ask = "none"),
"No installation found."
)
}
})

test_that("use_precommit fails when no global installation is found", {
skip_if(as.logical(Sys.getenv("EXTERNAL_INSTALLATION")))
expect_error(use_precommit(path_root = tempdir), "installed on your system")
})

test_that("can install pre-commit with remote config", {
expect_error(install_precommit(), NA)
if (!isTRUE(as.logical(Sys.getenv("EXTERNAL_INSTALLATION")))) {
expect_error(install_precommit(), NA)
}

expect_output(
{
Expand Down