From 1ad461ef23f8b751db6a0e5c67fb3158ad3cd295 Mon Sep 17 00:00:00 2001 From: David Mayer Date: Fri, 9 May 2025 11:54:09 -0600 Subject: [PATCH 1/8] prep for automatic pkgdown builds --- .Rbuildignore | 3 ++- .github/.gitignore | 1 + .github/workflows/pkgdown.yaml | 49 ++++++++++++++++++++++++++++++++++ DESCRIPTION | 1 + _pkgdown.yml | 3 ++- 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 .github/.gitignore create mode 100644 .github/workflows/pkgdown.yaml diff --git a/.Rbuildignore b/.Rbuildignore index 5f55aee..4e74795 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,4 +5,5 @@ ^docs$ ^pkgdown$ ^.lintr$ -.vscode/ \ No newline at end of file +.vscode/ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..bfc9f4d --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,49 @@ +# 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: + release: + types: [published] + workflow_dispatch: + +name: pkgdown.yaml + +permissions: read-all + +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@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - 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 diff --git a/DESCRIPTION b/DESCRIPTION index c7a55d8..d71f0ee 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,3 +22,4 @@ Suggests: DT, shiny VignetteBuilder: quarto +URL: https://seandavi.github.io/programets/ diff --git a/_pkgdown.yml b/_pkgdown.yml index 0d83f0f..54328ab 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,6 +1,7 @@ -url: ~ +url: https://seandavi.github.io/programets/ template: bootstrap: 5 bslib: bootswatch: materia pkgdown-nav-height: 100px + From 10c27792796d181329bc16d05c60acda7dc23939 Mon Sep 17 00:00:00 2001 From: David Mayer Date: Fri, 9 May 2025 12:41:42 -0600 Subject: [PATCH 2/8] add quarto to gha env, pin to current 'latest' tag --- .github/workflows/pkgdown.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index bfc9f4d..0630afd 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -30,6 +30,12 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true + + - name: Install Quarto (v1.7.30) + run: | + QUARTO_VERSION=1.7.30 + curl -LO https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb + sudo dpkg -i quarto-${QUARTO_VERSION}-linux-amd64.deb - uses: r-lib/actions/setup-r-dependencies@v2 with: From 0c2fdf861f0ba9c09ca847f584875cb2e9a15f15 Mon Sep 17 00:00:00 2001 From: David Mayer Date: Sun, 18 May 2025 07:21:00 -0600 Subject: [PATCH 3/8] make programets available to build site --- .github/workflows/pkgdown.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 0630afd..ed9ff76 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -41,6 +41,9 @@ jobs: with: extra-packages: any::pkgdown, local::. needs: website + + - name: Install dev version of the package + run: R CMD INSTALL . - name: Build site run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) From a84621e526d815b8d43b8f44896c7a4b322660ac Mon Sep 17 00:00:00 2001 From: David Mayer Date: Sun, 18 May 2025 07:28:03 -0600 Subject: [PATCH 4/8] different approach --- .github/workflows/pkgdown.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index ed9ff76..5f9fe57 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -41,12 +41,9 @@ jobs: with: extra-packages: any::pkgdown, local::. needs: website - - - name: Install dev version of the package - run: R CMD INSTALL . - name: Build site - run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + run: pkgdown::build_site_github_pages(new_process = FALSE, install = TRUE) shell: Rscript {0} - name: Deploy to GitHub pages 🚀 From f295e04aecef83b0bbaae9731be43cf27db512fa Mon Sep 17 00:00:00 2001 From: David Mayer Date: Sun, 18 May 2025 09:39:12 -0600 Subject: [PATCH 5/8] cleanup: - workflow should already install quarto, let's prefer the actions version - use native R pipe, avoiding a suggests or depends on magrittr. This will hopefully allow automated builds to complete successfully --- .github/workflows/pkgdown.yaml | 6 ------ vignettes/googleanalytics.qmd | 14 +++++++------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 5f9fe57..dda4b15 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -30,12 +30,6 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true - - - name: Install Quarto (v1.7.30) - run: | - QUARTO_VERSION=1.7.30 - curl -LO https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb - sudo dpkg -i quarto-${QUARTO_VERSION}-linux-amd64.deb - uses: r-lib/actions/setup-r-dependencies@v2 with: diff --git a/vignettes/googleanalytics.qmd b/vignettes/googleanalytics.qmd index 78dbc97..97c5107 100644 --- a/vignettes/googleanalytics.qmd +++ b/vignettes/googleanalytics.qmd @@ -91,22 +91,22 @@ library(zoo) library(dplyr) # Group by user type and country, then calculate rolling average -moving_avg_data <- daily_user_country_data %>% - arrange(date) %>% - group_by(newVsReturning, country) %>% +moving_avg_data <- daily_user_country_data |> + arrange(date) |> + group_by(newVsReturning, country) |> mutate( activeUsers_7day_avg = rollmean(activeUsers, k = 7, fill = NA, align = "right"), sessions_7day_avg = rollmean(sessions, k = 7, fill = NA, align = "right") - ) %>% + ) |> ungroup() # Let's see the results head(moving_avg_data) # Plot the moving average for active users -moving_avg_data %>% - group_by(date, newVsReturning) %>% - summarise(activeUsers_7day_avg = sum(activeUsers_7day_avg, na.rm = TRUE)) %>% +moving_avg_data |> + group_by(date, newVsReturning) |> + summarise(activeUsers_7day_avg = sum(activeUsers_7day_avg, na.rm = TRUE)) |> ggplot(aes(x = date, y = activeUsers_7day_avg, color = newVsReturning)) + geom_line() + labs( From 141b0c9b3d2373c6856e6d9e8e3c747e32f5e9ec Mon Sep 17 00:00:00 2001 From: David Mayer Date: Mon, 19 May 2025 14:30:58 -0600 Subject: [PATCH 6/8] use quarto chunk options and labels --- vignettes/googleanalytics.qmd | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/vignettes/googleanalytics.qmd b/vignettes/googleanalytics.qmd index 97c5107..3b14c9f 100644 --- a/vignettes/googleanalytics.qmd +++ b/vignettes/googleanalytics.qmd @@ -21,19 +21,21 @@ The package provides functions to authenticate with your Google account, retriev # Getting started with `googleAnalyticsR` - ```{r} -## setup +#| label: setup library(googleAnalyticsR) library(programets) ``` -```{r eval=FALSE} -## authenticate +```{r} +#| eval: false +#| label: authenticate ga_auth(email = "seandavi@gmail.com") ``` -```{r echo=FALSE} +```{r} +#| echo: false +#| label: service_account json_file <- gargle::secret_decrypt_json( path = system.file( "secret", @@ -49,25 +51,21 @@ ga_auth(email = "seandavi@gmail.com") ``` ```{r} -## get your accounts +#| label: get-accounts account_list <- ga_account_list("ga4") -## account_list will have a column called "viewId" -account_list$viewId +## account_list will have a column called "propertyId" +account_list$propertyId ## View account_list and pick the one that you want to use ## In this case, we will use Bioconductor ga_id <- 388188354 - ``` The resulting `res` object will contain the data for the specified date range, metrics, and dimensions. You can view the first few rows of the data using the `head()` function. - - - ```{r} -library(googleAnalyticsR) +#| label: get-data library(lubridate) start_date <- Sys.Date() - 365 @@ -85,7 +83,6 @@ daily_user_country_data <- ga_data( ```{r} #| label: moving-average - library(ggplot2) library(zoo) library(dplyr) From 299e6d163cbdebd15a039f8c6ceea6eef706772a Mon Sep 17 00:00:00 2001 From: David Mayer Date: Fri, 23 May 2025 07:58:44 -0600 Subject: [PATCH 7/8] update workflow --- .github/workflows/pkgdown.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index dda4b15..919767a 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -20,6 +20,7 @@ jobs: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + GARGLE_ENCRYPTION_KEY: ${{ secrets.GARGLE_ENCRYPTION_KEY }} permissions: contents: write steps: From d79cd7d80ce3b25eca3a0ee0c453d4ebe04ff487 Mon Sep 17 00:00:00 2001 From: David Mayer Date: Tue, 28 Oct 2025 10:13:16 -0400 Subject: [PATCH 8/8] update DESCRIPTION --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7a47e77..61d7bc0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,5 +40,6 @@ Suggests: testthat (>= 3.0.0), zoo VignetteBuilder: quarto -URL: https://seandavi.github.io/programets/ +URL: https://nih-cfde.github.io/programets/ +BugReports: https://github.com/nih-cfde/programets/issues Config/testthat/edition: 3