Skip to content

Commit

Permalink
[ci] add linting and autoformatting for shell scripts (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb authored Jan 12, 2025
1 parent dd76a06 commit 54d3500
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 164 deletions.
8 changes: 4 additions & 4 deletions .ci/install.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

# failure is a natural part of life
set -e
set -e -u -o pipefail

if [[ "$TASK" == "rpkg" ]]; then
R CMD INSTALL \
--clean \
$(pwd)/r-pkg
R CMD INSTALL \
--clean \
./r-pkg
fi
4 changes: 2 additions & 2 deletions .ci/report_to_covr.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

# failure is a natural part of life
set -e
set -e -u -o pipefail

if [[ "$TASK" == "rpkg" ]]; then
Rscript -e " \
Rscript -e " \
Sys.setenv(NOT_CRAN = 'true'); \
covr::codecov('r-pkg/') \
"
Expand Down
24 changes: 12 additions & 12 deletions .ci/setup.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#!/bin/bash

# failure is a natural part of life
set -e
set -e -u -o pipefail

# If language: r,
# install these testing packages we need
if [[ "$TASK" == "rpkg" ]];
then
if [[ "$TASK" == "rpkg" ]]; then

# `devscripts` is required for 'checkbashisms' (https://github.com/r-lib/actions/issues/111)
sudo apt-get update
sudo apt-get install \
--no-install-recommends \
-y \
--allow-downgrades \
libcurl4-openssl-dev \
curl \
devscripts \
texinfo \
texlive-latex-recommended \
texlive-fonts-recommended \
texlive-fonts-extra \
qpdf \
|| exit -1
libcurl4-openssl-dev \
curl \
devscripts \
texinfo \
texlive-latex-recommended \
texlive-fonts-recommended \
texlive-fonts-extra \
qpdf

Rscript -e "install.packages(c('assertthat', 'covr', 'data.table', 'futile.logger', 'httr', 'jsonlite', 'knitr', 'lintr', 'purrr', 'rmarkdown', 'stringr', 'testthat', 'uuid'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())"
cp test-data/* r-pkg/inst/testdata/
Expand Down
14 changes: 7 additions & 7 deletions .ci/test.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

# failure is a natural part of life
set -e
set -e -u -o pipefail

if [[ "$TASK" == "rpkg" ]]; then
Rscript .ci/lint_r_code.R $(pwd)
R CMD build $(pwd)/r-pkg
export _R_CHECK_CRAN_INCOMING_=false
R CMD check \
--as-cran \
*.tar.gz
Rscript .ci/lint_r_code.R "$(pwd)"
R CMD build ./r-pkg
export _R_CHECK_CRAN_INCOMING_=false
R CMD check \
--as-cran \
./*.tar.gz
fi
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
exclude: |
(?x)^(
test-data/.*
)$
repos:
- repo: https://github.com/maxwinterstein/shfmt-py
rev: v3.7.0.1
hooks:
- id: shfmt
args: ["--indent=4", "--space-redirects", "--write"]
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
args: ["--exclude=SC2002"]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
# additional_dependencies: [tomli]
# args: ["--toml", "pyproject.toml"]
6 changes: 3 additions & 3 deletions cleanup_local.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

set -e
set -e -u -o pipefail

# Remove testing directory
echo "removing testing directory"
rm -r $(pwd)/sandbox
rm -r ./sandbox

# Kill the running container
echo "killing running container"
docker kill $(docker ps -ql)
docker kill "$(docker ps -ql)"

echo "done cleaning up test environment"
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* One NOTE from `checking CRAN incoming feasibility ...` can be safely ignored since it's a note that notifies CRAN that this is a new maintainer/submission.

### CRAN Response
* Automatic checking upon CRAN submission yielded two notes. One was the "incoming feasbility..." item we mentioned above, which is not an issue.
* Automatic checking upon CRAN submission yielded two notes. One was the "incoming feasibility..." item we mentioned above, which is not an issue.
* The other note said that `Author field differs from that derived from Authors@R`. This did not arise when running `R CMD check --as-cran` locally, but it looks like "fnd" is not a supported tag for an author. Removed that tag.

## v0.0.2 - Submission 2 - (July 17, 2017)
Expand Down Expand Up @@ -127,7 +127,7 @@ In this submission, we changed maintainer from `[email protected]` to `jayla
## v0.4.0 - Submission 1 - (September 11, 2019)

### `R CMD check` results
* No isses
* No issues

### CRAN Response
* No issues. v0.4.0 released to CRAN!
2 changes: 1 addition & 1 deletion r-pkg/R/es_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ es_search <- function(es_host
log_info(sprintf("uptasticsearch thinks you are running Elasticsearch %s", version))

# Parse out just the major version. We can adjust this if we find
# API differences that occured at the minor version level
# API differences that occurred at the minor version level
major_version <- .major_version(version)
return(major_version)
}
Expand Down
4 changes: 2 additions & 2 deletions r-pkg/tests/testthat/test-integration.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ futile.logger::flog.threshold(0)
, ignore.order = TRUE
)

# ther stuff we might as well test
# the stuff we might as well test
expect_true(data.table::is.data.table(outDT))
expect_true(is.numeric(outDT[, doc_count]))
expect_true(is.character(outDT[, name_i_picked]))
Expand Down Expand Up @@ -200,7 +200,7 @@ futile.logger::flog.threshold(0)

# Decided to check that it's coercible to an integer instead of
# hard-coding known Elasticsearch versions so this test won't require
# attention or break builds if/when Elasticsearch 7 or whatever the next major verison
# attention or break builds if/when Elasticsearch 7 or whatever the next major version
# is comes out
expect_true(!is.na(as.integer(ver)), info = paste0("returned version: ", ver))
})
Expand Down
Loading

0 comments on commit 54d3500

Please sign in to comment.