From 78db2855c66213a872e175fed33a1d985c05221d Mon Sep 17 00:00:00 2001 From: Joakim Linde Date: Mon, 19 Aug 2024 17:12:44 +0300 Subject: [PATCH 01/14] Fix cut-and-paste typo Fix cut-and-paste typo introduced when switching to as_duckplyr_tibble() --- R/as_duckplyr_tibble.R | 2 +- man/as_duckplyr_df.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/as_duckplyr_tibble.R b/R/as_duckplyr_tibble.R index 8ebee5a9..dcb30646 100644 --- a/R/as_duckplyr_tibble.R +++ b/R/as_duckplyr_tibble.R @@ -2,7 +2,7 @@ #' #' `as_duckplyr_tibble()` converts the input to a tibble and then to a duckplyr data frame. #' -#' @return For `as_duckplyr_df()`, an object of class +#' @return For `as_duckplyr_tibble()`, an object of class #' `c("duckplyr_df", class(tibble()))` . #' #' @rdname as_duckplyr_df diff --git a/man/as_duckplyr_df.Rd b/man/as_duckplyr_df.Rd index 88a1c29c..d7458df2 100644 --- a/man/as_duckplyr_df.Rd +++ b/man/as_duckplyr_df.Rd @@ -16,7 +16,7 @@ as_duckplyr_tibble(.data) For \code{as_duckplyr_df()}, an object of class \code{"duckplyr_df"}, inheriting from the classes of the \code{.data} argument. -For \code{as_duckplyr_df()}, an object of class +For \code{as_duckplyr_tibble()}, an object of class \code{c("duckplyr_df", class(tibble()))} . } \description{ From 1a9ee4919c9374a5138e540d003dc60d022e2db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 03:07:57 +0200 Subject: [PATCH 02/14] Undoc --- man/as_duckplyr_df.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/as_duckplyr_df.Rd b/man/as_duckplyr_df.Rd index d7458df2..88a1c29c 100644 --- a/man/as_duckplyr_df.Rd +++ b/man/as_duckplyr_df.Rd @@ -16,7 +16,7 @@ as_duckplyr_tibble(.data) For \code{as_duckplyr_df()}, an object of class \code{"duckplyr_df"}, inheriting from the classes of the \code{.data} argument. -For \code{as_duckplyr_tibble()}, an object of class +For \code{as_duckplyr_df()}, an object of class \code{c("duckplyr_df", class(tibble()))} . } \description{ From c6030787c99311cf52534a4e622024e8e546e0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 03:12:21 +0200 Subject: [PATCH 03/14] Try roxygenize --- .github/workflows/R-CMD-check.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 6c3c9cd4..eebbb0aa 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -80,13 +80,10 @@ jobs: uses: ./.github/workflows/dep-suggests-matrix - uses: ./.github/workflows/update-snapshots - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository - uses: ./.github/workflows/style - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository - uses: ./.github/workflows/roxygenize - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository - name: Remove config files from previous iteration run: | From a9e894572f46f1349d861f392c6da1b4d85fc396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 03:18:10 +0200 Subject: [PATCH 04/14] Use environment variable --- .github/workflows/dep-suggests-matrix/action.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dep-suggests-matrix/action.R b/.github/workflows/dep-suggests-matrix/action.R index 9673b704..7ed83923 100644 --- a/.github/workflows/dep-suggests-matrix/action.R +++ b/.github/workflows/dep-suggests-matrix/action.R @@ -21,9 +21,9 @@ get_deps <- function() { if (Sys.getenv("GITHUB_BASE_REF") != "") { print(Sys.getenv("GITHUB_BASE_REF")) - has_diff <- (system("git diff ${{ github.event.pull_request.base.sha }}... | egrep '^[+][^+]' | grep -q ::") == 0) + has_diff <- (system("git diff ${GITHUB_BASE_REF}... | egrep '^[+][^+]' | grep -q ::") == 0) if (has_diff) { - system("git diff ${{ github.event.pull_request.base.sha }}... | egrep '^[+][^+]' | grep -q ::") + system("git diff ${GITHUB_BASE_REF}... | egrep '^[+][^+]' | grep -q ::") packages <- get_deps() } else { writeLines("No changes using :: found, not checking without suggested packages") From 57458563ef2bae601e29a10797b4454f3058dbcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 03:22:01 +0200 Subject: [PATCH 05/14] Fantasy --- .github/workflows/commit/action.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commit/action.yml b/.github/workflows/commit/action.yml index 5b00fe33..413abcdd 100644 --- a/.github/workflows/commit/action.yml +++ b/.github/workflows/commit/action.yml @@ -40,16 +40,26 @@ runs: gh workflow run rcc -f ref=$(git rev-parse HEAD) else git fetch - if [ -n "${GITHUB_HEAD_REF}" ]; then + if [ -n '${{ github.head_ref }}' ]; then + # Find the name of the remote of the PR's source + remote_repo=${{ github.event.pull_request.head.repo.clone_url }} + git remote add pr-source $remote_repo + git fetch pr-source ${{ github.head_ref }} git add . git stash save git switch ${GITHUB_HEAD_REF} git merge origin/${GITHUB_BASE_REF} --no-edit git stash pop + remote=pr-source + else + remote=origin fi git add . git commit -m "chore: Auto-update from GitHub Actions"$'\n'$'\n'"Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" - git push -u origin HEAD + git push -u ${remote} HEAD + if [ "${remote}" = "pr-source" ]; then + git remote remove ${remote} + fi fi # Only set output if changed echo sha=$(git rev-parse HEAD) >> $GITHUB_OUTPUT From df9bc80160d83a2526ea3a5f7aee030287352c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 04:07:53 +0200 Subject: [PATCH 06/14] PR --- .github/workflows/commit/action.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/commit/action.yml b/.github/workflows/commit/action.yml index 413abcdd..7e0ca6f9 100644 --- a/.github/workflows/commit/action.yml +++ b/.github/workflows/commit/action.yml @@ -19,15 +19,14 @@ runs: set -x if [ -n "$(git status --porcelain)" ]; then echo "Changed" - protected=${{ github.ref_protected }} + protected=${{ github.ref_protected || github.event.pull_request.head.repo.full_name != github.repository }} if [ "${protected}" = "true" ]; then current_branch=$(git branch --show-current) - new_branch=gha-commit + new_branch=gha-commit-$(git rev-parse --short HEAD) git checkout -b ${new_branch} git add . git commit -m "chore: Auto-update from GitHub Actions"$'\n'$'\n'"Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" - # Force-push, used in only one place - # Alternative: separate branch names for each usage + # Force-push, collisions are unlikely git push -u origin HEAD -f existing_pr=$(gh pr list --state open --base main --head ${new_branch} --json number --jq '.[] | .number') @@ -37,7 +36,7 @@ runs: gh pr create --base main --head ${new_branch} --title "chore: Auto-update from GitHub Actions" --body "Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" fi - gh workflow run rcc -f ref=$(git rev-parse HEAD) + gh pr merge --merge --auto else git fetch if [ -n '${{ github.head_ref }}' ]; then From c46a0731935bf4ff8e1ebfff4b17b8f1c2733323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 04:20:43 +0200 Subject: [PATCH 07/14] Revert "ci: Restrict commit again to own PRs" This reverts commit f3090a52e71c2900ced7b275cbfdb88a13ac28d5. --- .github/workflows/R-CMD-check.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index eebbb0aa..b622c480 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -91,7 +91,6 @@ jobs: shell: bash - id: commit - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository uses: ./.github/workflows/commit with: token: ${{ secrets.GITHUB_TOKEN }} From 2c7a35b633fb27b11007ec27f60b57c267411c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 04:29:55 +0200 Subject: [PATCH 08/14] Add remote --- .github/workflows/dep-suggests-matrix/action.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dep-suggests-matrix/action.R b/.github/workflows/dep-suggests-matrix/action.R index 7ed83923..b9a86e3b 100644 --- a/.github/workflows/dep-suggests-matrix/action.R +++ b/.github/workflows/dep-suggests-matrix/action.R @@ -21,9 +21,9 @@ get_deps <- function() { if (Sys.getenv("GITHUB_BASE_REF") != "") { print(Sys.getenv("GITHUB_BASE_REF")) - has_diff <- (system("git diff ${GITHUB_BASE_REF}... | egrep '^[+][^+]' | grep -q ::") == 0) + has_diff <- (system("git diff origin/${GITHUB_BASE_REF}... | egrep '^[+][^+]' | grep -q ::") == 0) if (has_diff) { - system("git diff ${GITHUB_BASE_REF}... | egrep '^[+][^+]' | grep -q ::") + system("git diff origin/${GITHUB_BASE_REF}... | egrep '^[+][^+]' | grep -q ::") packages <- get_deps() } else { writeLines("No changes using :: found, not checking without suggested packages") From e2ef19c23c184f611f63ae0122216febabcbd7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 04:44:28 +0200 Subject: [PATCH 09/14] Distinguish foreign and protected branches --- .github/workflows/commit/action.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commit/action.yml b/.github/workflows/commit/action.yml index 7e0ca6f9..b30e190e 100644 --- a/.github/workflows/commit/action.yml +++ b/.github/workflows/commit/action.yml @@ -19,8 +19,12 @@ runs: set -x if [ -n "$(git status --porcelain)" ]; then echo "Changed" - protected=${{ github.ref_protected || github.event.pull_request.head.repo.full_name != github.repository }} - if [ "${protected}" = "true" ]; then + protected=${{ github.ref_protected }} + foreign=${{ github.event.pull_request.head.repo.full_name != github.repository }} + if [ "${foreign}" = "true" ]; then + # https://github.com/krlmlr/actions-sync/issues/44 + echo "Can't push to foreign branch" + else if [ "${protected}" = "true" ]; then current_branch=$(git branch --show-current) new_branch=gha-commit-$(git rev-parse --short HEAD) git checkout -b ${new_branch} From 145908e6879a5562b339274ed3fbdeb3128bf63a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 04:44:49 +0200 Subject: [PATCH 10/14] Comment --- .github/workflows/commit/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/commit/action.yml b/.github/workflows/commit/action.yml index b30e190e..d9f5bace 100644 --- a/.github/workflows/commit/action.yml +++ b/.github/workflows/commit/action.yml @@ -30,7 +30,8 @@ runs: git checkout -b ${new_branch} git add . git commit -m "chore: Auto-update from GitHub Actions"$'\n'$'\n'"Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" - # Force-push, collisions are unlikely + # Force-push, used in only one place + # Alternative: separate branch names for each usage git push -u origin HEAD -f existing_pr=$(gh pr list --state open --base main --head ${new_branch} --json number --jq '.[] | .number') From d913a04720878871a6d0aba2c236ed74a0a7f129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 04:45:02 +0200 Subject: [PATCH 11/14] Roll back, update sha only if on pushable branch --- .github/workflows/commit/action.yml | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/commit/action.yml b/.github/workflows/commit/action.yml index d9f5bace..27f42e65 100644 --- a/.github/workflows/commit/action.yml +++ b/.github/workflows/commit/action.yml @@ -41,31 +41,23 @@ runs: gh pr create --base main --head ${new_branch} --title "chore: Auto-update from GitHub Actions" --body "Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" fi + gh workflow run rcc -f ref=$(git rev-parse HEAD) gh pr merge --merge --auto else git fetch - if [ -n '${{ github.head_ref }}' ]; then - # Find the name of the remote of the PR's source - remote_repo=${{ github.event.pull_request.head.repo.clone_url }} - git remote add pr-source $remote_repo - git fetch pr-source ${{ github.head_ref }} + if [ -n "${GITHUB_HEAD_REF}" ]; then git add . git stash save git switch ${GITHUB_HEAD_REF} git merge origin/${GITHUB_BASE_REF} --no-edit git stash pop - remote=pr-source - else - remote=origin fi git add . git commit -m "chore: Auto-update from GitHub Actions"$'\n'$'\n'"Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" - git push -u ${remote} HEAD - if [ "${remote}" = "pr-source" ]; then - git remote remove ${remote} - fi + git push -u origin HEAD + + # Only set output if changed + echo sha=$(git rev-parse HEAD) >> $GITHUB_OUTPUT fi - # Only set output if changed - echo sha=$(git rev-parse HEAD) >> $GITHUB_OUTPUT fi shell: bash From fb746ed321d38661a619c3d302194a87d41a7c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 04:50:56 +0200 Subject: [PATCH 12/14] Fetch --- .github/workflows/dep-suggests-matrix/action.R | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dep-suggests-matrix/action.R b/.github/workflows/dep-suggests-matrix/action.R index b9a86e3b..34484c9c 100644 --- a/.github/workflows/dep-suggests-matrix/action.R +++ b/.github/workflows/dep-suggests-matrix/action.R @@ -21,6 +21,7 @@ get_deps <- function() { if (Sys.getenv("GITHUB_BASE_REF") != "") { print(Sys.getenv("GITHUB_BASE_REF")) + system("git fetch origin ${GITHUB_BASE_REF}") has_diff <- (system("git diff origin/${GITHUB_BASE_REF}... | egrep '^[+][^+]' | grep -q ::") == 0) if (has_diff) { system("git diff origin/${GITHUB_BASE_REF}... | egrep '^[+][^+]' | grep -q ::") From e76d533ef7d561a6bd33453484295b286f4dde69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 04:54:42 +0200 Subject: [PATCH 13/14] elif --- .github/workflows/commit/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commit/action.yml b/.github/workflows/commit/action.yml index 27f42e65..ed6f9b89 100644 --- a/.github/workflows/commit/action.yml +++ b/.github/workflows/commit/action.yml @@ -24,7 +24,7 @@ runs: if [ "${foreign}" = "true" ]; then # https://github.com/krlmlr/actions-sync/issues/44 echo "Can't push to foreign branch" - else if [ "${protected}" = "true" ]; then + elif [ "${protected}" = "true" ]; then current_branch=$(git branch --show-current) new_branch=gha-commit-$(git rev-parse --short HEAD) git checkout -b ${new_branch} From 4692dc8d7fe24f6985570a2186d3dab41e39a971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Aug 2024 04:58:55 +0200 Subject: [PATCH 14/14] .. --- .github/workflows/dep-suggests-matrix/action.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dep-suggests-matrix/action.R b/.github/workflows/dep-suggests-matrix/action.R index 34484c9c..eff3a502 100644 --- a/.github/workflows/dep-suggests-matrix/action.R +++ b/.github/workflows/dep-suggests-matrix/action.R @@ -22,9 +22,11 @@ get_deps <- function() { if (Sys.getenv("GITHUB_BASE_REF") != "") { print(Sys.getenv("GITHUB_BASE_REF")) system("git fetch origin ${GITHUB_BASE_REF}") - has_diff <- (system("git diff origin/${GITHUB_BASE_REF}... | egrep '^[+][^+]' | grep -q ::") == 0) + # Use .. to avoid having to fetch the entire history + # https://github.com/krlmlr/actions-sync/issues/45 + has_diff <- (system("git diff origin/${GITHUB_BASE_REF}.. | egrep '^[+][^+]' | grep -q ::") == 0) if (has_diff) { - system("git diff origin/${GITHUB_BASE_REF}... | egrep '^[+][^+]' | grep -q ::") + system("git diff origin/${GITHUB_BASE_REF}.. | egrep '^[+][^+]' | grep -q ::") packages <- get_deps() } else { writeLines("No changes using :: found, not checking without suggested packages")