Skip to content

Commit

Permalink
update github actions and move sodium to suggests
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulC91 committed Mar 4, 2024
1 parent 480b83f commit 1eea807
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 144 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
86 changes: 0 additions & 86 deletions .github/workflows/check-standard.yaml

This file was deleted.

35 changes: 24 additions & 11 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:
Expand All @@ -12,24 +14,35 @@ name: pkgdown
jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: pkgdown
extra-packages: any::pkgdown, local::.
needs: website

- name: Deploy package
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
folder: docs
76 changes: 31 additions & 45 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,64 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- main
- master
branches: [main, master]
pull_request:
branches:
- main
- master
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: macOS-latest
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1

- uses: r-lib/actions/setup-pandoc@v1
steps:
- 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}
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Restore R package cache
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v2
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-
extra-packages: any::covr
needs: coverage

- name: Install dependencies
run: |
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("covr")
shell: Rscript {0}

- name: Find PhantomJS path
id: phantomjs
- name: Test coverage
run: |
echo "::set-output name=path::$(Rscript -e 'cat(shinytest:::phantom_paths()[[1]])')"
- name: Cache PhantomJS
uses: actions/cache@v1
with:
path: ${{ steps.phantomjs.outputs.path }}
key: ${{ runner.os }}-phantomjs
restore-keys: ${{ runner.os }}-phantomjs
- name: Install PhantomJS
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
options(install.packages.check.source = "no")
if (!shinytest::dependenciesInstalled()) shinytest::installDependencies()
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Imports:
shinyjs,
dplyr,
rlang,
sodium,
glue
Suggests:
sodium,
DBI,
RSQLite,
lubridate,
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# shinyauthr 1.0.1

* `loginServer` now accepts reactive data courtesy of #62
* Updated r-lib github actions to v2
* Moved the 'sodium' package to suggests

# shinyauthr 1.0.0

* New `loginServer` and `logoutServer` functions added. `login` and `logout` are now deprecated, full details in README.
Expand Down
6 changes: 6 additions & 0 deletions R/login.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ loginServer <- function(id,
row_password <- dplyr::filter(data_reactive(), dplyr::row_number() == row_username)
row_password <- dplyr::pull(row_password, {{pwd_col}})
if (sodium_hashed) {
if (!rlang::is_installed("sodium")) {
rlang::check_installed("sodium", reason = "to decrypt passwords hashed by sodium.")
}
password_match <- sodium::password_verify(row_password, input$password)
} else {
password_match <- identical(row_password, input$password)
Expand Down Expand Up @@ -416,6 +419,9 @@ login <- function(input,
row_password <- dplyr::filter(data, dplyr::row_number() == row_username)
row_password <- dplyr::pull(row_password, !!pwds)
if (sodium_hashed) {
if (!rlang::is_installed("sodium")) {
rlang::check_installed("sodium", reason = "to decrypt passwords hashed by sodium.")
}
password_match <- sodium::password_verify(row_password, input$password)
} else {
password_match <- identical(row_password, input$password)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

[![CRAN status](https://www.r-pkg.org/badges/version/shinyauthr)](https://CRAN.R-project.org/package=shinyauthr)
[![](https://cranlogs.r-pkg.org/badges/shinyauthr)](https://cran.r-project.org/package=shinyauthr)
[![R-CMD-check](https://github.com/PaulC91/shinyauthr/workflows/R-CMD-check/badge.svg)](https://github.com/PaulC91/shinyauthr/actions)
[![](https://cranlogs.r-pkg.org/badges/grand-total/shinyauthr)](https://cran.r-project.org/package=shinyauthr)
[![R-CMD-check](https://github.com/PaulC91/shinyauthr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/PaulC91/shinyauthr/actions/workflows/R-CMD-check.yaml)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![Codecov test coverage](https://codecov.io/gh/PaulC91/shinyauthr/branch/master/graph/badge.svg)](https://codecov.io/gh/PaulC91/shinyauthr?branch=master)

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-login.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ test_that("incorrect credentials does not log in", {
})

test_that("sodium decrypts password", {
skip_if_not_installed("sodium")
user_base <- dplyr::tibble(
user = "user1",
password = sodium::password_store("pass1")
Expand Down

0 comments on commit 1eea807

Please sign in to comment.