From 7903995257f77ac387d460355dccf13a2ba678bb Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Mon, 15 Apr 2024 18:11:29 +0200 Subject: [PATCH 01/12] Initialize revdepcheck action --- .github/workflows/revdepcheck.yaml | 93 ++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .github/workflows/revdepcheck.yaml diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml new file mode 100644 index 00000000..7701d829 --- /dev/null +++ b/.github/workflows/revdepcheck.yaml @@ -0,0 +1,93 @@ +--- +name: revdepcheck ⏪ + +on: + workflow_dispatch: + workflow_call: + secrets: + REPO_GITHUB_TOKEN: + description: | + Github token with read access to repositories, required for dependencies installation + required: false + GCHAT_WEBHOOK: + description: | + Google Chat webhook to send failure notifications + required: false + inputs: + additional-env-vars: + description: | + Extra environment variables, as a 'key=value' pair, with each pair on a new line. + Example usage: + additional-env-vars: | + ABC=123 + XYZ=456 + required: false + default: "" + type: string + +jobs: + dependency-test: + name: revdepcheck ⏪ + runs-on: ubuntu-latest + if: > + !contains(github.event.commits[0].message, '[skip revdepcheck]') + && github.event.pull_request.draft == false + container: + image: ghcr.io/insightsengineering/rstudio:latest + + steps: + - name: Setup token 🔑 + id: github-token + run: | + if [ "${{ secrets.REPO_GITHUB_TOKEN }}" == "" ]; then + echo "REPO_GITHUB_TOKEN is empty. Substituting it with GITHUB_TOKEN." + echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT + else + echo "Using REPO_GITHUB_TOKEN." + echo "token=${{ secrets.REPO_GITHUB_TOKEN }}" >> $GITHUB_OUTPUT + fi + shell: bash + + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo 🛎 + uses: actions/checkout@v4 + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + fetch-depth: 1 + + - name: Check commit message 💬 + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + exit 1 + fi + shell: bash + env: + SKIP_INSTRUCTION: "[skip revdepcheck]" + + - name: Normalize variables 📏 + run: | + echo "gchat_webhook=${{ secrets.GCHAT_WEBHOOK }}" >> $GITHUB_ENV + shell: bash + + - name: revdepcheck 🔄 + id: revdepcheck + # TODO update branch to main + uses: insightsengineering/r-revdepcheck-action@initialize-action + with: + github-token: ${{ steps.github-token.outputs.token }} + additional-env-vars: ${{ inputs.additional-env-vars }} + + - name: GChat notification 🔔 + if: (failure() || cancelled()) && steps.revdepcheck.outcome != 'success' && env.gchat_webhook != '' + uses: insightsengineering/google-chat-notification@master + with: + name: ${{ github.event.repository.name }} - revdepcheck - ${{ env.strategy }} + url: ${{ secrets.GCHAT_WEBHOOK }} + status: ${{ job.status }} From faf8026f4b940dc87122f44075a5d4cb2e8d8e5d Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Mon, 15 Apr 2024 18:22:12 +0200 Subject: [PATCH 02/12] Update --- .github/workflows/revdepcheck.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index 7701d829..7feba7e2 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -31,7 +31,8 @@ jobs: runs-on: ubuntu-latest if: > !contains(github.event.commits[0].message, '[skip revdepcheck]') - && github.event.pull_request.draft == false + # Restore this in the if condition + # && github.event.pull_request.draft == false container: image: ghcr.io/insightsengineering/rstudio:latest From fddc5b46f611c89c72baaa56f1eca1b1712a51e6 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 17 Apr 2024 15:12:00 +0200 Subject: [PATCH 03/12] List revdep directory --- .github/workflows/revdepcheck.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index 7feba7e2..fea37fb8 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -92,3 +92,9 @@ jobs: name: ${{ github.event.repository.name }} - revdepcheck - ${{ env.strategy }} url: ${{ secrets.GCHAT_WEBHOOK }} status: ${{ job.status }} + + - name: List revdep directory + run: | + ls -la revdep + du -sh ./revdep + shell: bash From 1e0f2c5cce3218f3d9392f9835334d2cd9fb5602 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 17 Apr 2024 16:22:01 +0200 Subject: [PATCH 04/12] Upload artifact --- .github/workflows/revdepcheck.yaml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index fea37fb8..38c815d6 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -77,6 +77,11 @@ jobs: echo "gchat_webhook=${{ secrets.GCHAT_WEBHOOK }}" >> $GITHUB_ENV shell: bash + - name: List CPU info + run: | + cat /proc/cpuinfo + shell: bash + - name: revdepcheck 🔄 id: revdepcheck # TODO update branch to main @@ -93,8 +98,14 @@ jobs: url: ${{ secrets.GCHAT_WEBHOOK }} status: ${{ job.status }} - - name: List revdep directory + - name: Prepare revdep artifact run: | - ls -la revdep - du -sh ./revdep + rm -rf revdep/library.noindex + zip -r9 revdep.zip revdep/ shell: bash + + - name: Upload artifact ⬆ + uses: actions/upload-artifact@v4 + with: + name: revdep + path: revdep.zip From add60e7456181acfe3fb4421aab724fa1ac55464 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 17 Apr 2024 18:05:46 +0200 Subject: [PATCH 05/12] Update --- .github/workflows/revdepcheck.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index 38c815d6..e2737a1f 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -77,11 +77,6 @@ jobs: echo "gchat_webhook=${{ secrets.GCHAT_WEBHOOK }}" >> $GITHUB_ENV shell: bash - - name: List CPU info - run: | - cat /proc/cpuinfo - shell: bash - - name: revdepcheck 🔄 id: revdepcheck # TODO update branch to main @@ -101,11 +96,10 @@ jobs: - name: Prepare revdep artifact run: | rm -rf revdep/library.noindex - zip -r9 revdep.zip revdep/ shell: bash - name: Upload artifact ⬆ uses: actions/upload-artifact@v4 with: name: revdep - path: revdep.zip + path: revdep/ From 81988a10ddc51a5c4434ba38a8bd96451517954c Mon Sep 17 00:00:00 2001 From: walkowif <59475134+walkowif@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:24:49 +0200 Subject: [PATCH 06/12] Update .github/workflows/revdepcheck.yaml Co-authored-by: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Signed-off-by: walkowif <59475134+walkowif@users.noreply.github.com> --- .github/workflows/revdepcheck.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index e2737a1f..abdeab65 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -96,6 +96,7 @@ jobs: - name: Prepare revdep artifact run: | rm -rf revdep/library.noindex + rm -rf revdep/library shell: bash - name: Upload artifact ⬆ From aa155f992071fb81ec1d04c5cfd7817cde1f7c0d Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Fri, 19 Apr 2024 12:34:34 +0200 Subject: [PATCH 07/12] List cache directories --- .github/workflows/revdepcheck.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index abdeab65..9f0dd5ea 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -85,6 +85,18 @@ jobs: github-token: ${{ steps.github-token.outputs.token }} additional-env-vars: ${{ inputs.additional-env-vars }} + - name: Get cache + run : | + crancache_path="$(R -q -e 'cat(crancache::get_cache_dir(), "\n")' 2>/dev/null | head -2 | tail -1 | tr -d ' ')" + pkgcache_path="$(R -q -e 'cat(pkgcache::pkg_cache_summary()$cachepath, "\n")' 2>/dev/null | head -2 | tail -1 | tr -d ' ')" + echo "crancache_path = $crancache_path" + echo "pkgcache_path = $pkgcache_path" + echo "crancache size:" + du -sh "$crancache_path" || true + echo "pkgcache size:" + du -sh "$pkgcache_path" || true + shell: bash + - name: GChat notification 🔔 if: (failure() || cancelled()) && steps.revdepcheck.outcome != 'success' && env.gchat_webhook != '' uses: insightsengineering/google-chat-notification@master From da5a77dd2a2fcbd204163d322facbcb81ae83be8 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Fri, 19 Apr 2024 12:38:22 +0200 Subject: [PATCH 08/12] Update --- .github/workflows/revdepcheck.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index 9f0dd5ea..2bac617e 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -86,6 +86,7 @@ jobs: additional-env-vars: ${{ inputs.additional-env-vars }} - name: Get cache + if: always() run : | crancache_path="$(R -q -e 'cat(crancache::get_cache_dir(), "\n")' 2>/dev/null | head -2 | tail -1 | tr -d ' ')" pkgcache_path="$(R -q -e 'cat(pkgcache::pkg_cache_summary()$cachepath, "\n")' 2>/dev/null | head -2 | tail -1 | tr -d ' ')" From 4524a0383d1a2504e0581ffa4e2bdffab71e7e30 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Fri, 19 Apr 2024 14:58:47 +0200 Subject: [PATCH 09/12] Debug cache --- .github/workflows/revdepcheck.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index 2bac617e..ca0e829b 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -59,6 +59,16 @@ jobs: ref: ${{ steps.branch-name.outputs.head_ref_branch }} fetch-depth: 1 + - name: Debug + run: | + echo "Home is at: $(echo ~)" + + - name: Restore cache 💰 + uses: actions/cache@v4 + with: + key: revdepcheck-${{ runner.os }}-${{ github.event.repository.name }} + path: /github/home/.cache/R/pkgcache/pkg + - name: Check commit message 💬 run: | git config --global --add safe.directory $(pwd) @@ -88,7 +98,7 @@ jobs: - name: Get cache if: always() run : | - crancache_path="$(R -q -e 'cat(crancache::get_cache_dir(), "\n")' 2>/dev/null | head -2 | tail -1 | tr -d ' ')" + crancache_path="$(R -q -e 'cat(normalizePath(crancache::get_cache_dir()), "\n")' 2>/dev/null | head -2 | tail -1 | tr -d ' ')" pkgcache_path="$(R -q -e 'cat(pkgcache::pkg_cache_summary()$cachepath, "\n")' 2>/dev/null | head -2 | tail -1 | tr -d ' ')" echo "crancache_path = $crancache_path" echo "pkgcache_path = $pkgcache_path" @@ -96,6 +106,9 @@ jobs: du -sh "$crancache_path" || true echo "pkgcache size:" du -sh "$pkgcache_path" || true + apt-get update && apt-get install -yq tree + echo "listing cache directory" + tree ~/.cache shell: bash - name: GChat notification 🔔 From e2a03c5a8927d8132253af231af170278065c4cc Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Fri, 19 Apr 2024 16:12:06 +0200 Subject: [PATCH 10/12] Also cache crancache --- .github/workflows/revdepcheck.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index ca0e829b..0e5a3ecf 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -67,7 +67,9 @@ jobs: uses: actions/cache@v4 with: key: revdepcheck-${{ runner.os }}-${{ github.event.repository.name }} - path: /github/home/.cache/R/pkgcache/pkg + path: | + /github/home/.cache/R/pkgcache/pkg + /github/home/.cache/R-crancache - name: Check commit message 💬 run: | From 4ebc21731dd02d3f902eb083dc45aaaa6209e476 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Thu, 25 Apr 2024 13:35:20 +0200 Subject: [PATCH 11/12] Cleanup --- .github/workflows/revdepcheck.yaml | 34 ++++++------------------------ 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index 0e5a3ecf..e89464a6 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -26,13 +26,12 @@ on: type: string jobs: - dependency-test: + revdepcheck: name: revdepcheck ⏪ runs-on: ubuntu-latest if: > !contains(github.event.commits[0].message, '[skip revdepcheck]') - # Restore this in the if condition - # && github.event.pull_request.draft == false + && github.event.pull_request.draft == false container: image: ghcr.io/insightsengineering/rstudio:latest @@ -54,22 +53,18 @@ jobs: uses: tj-actions/branch-names@v7 - name: Checkout repo 🛎 - uses: actions/checkout@v4 + uses: actions/checkout@v4.1.1 with: ref: ${{ steps.branch-name.outputs.head_ref_branch }} fetch-depth: 1 - - name: Debug - run: | - echo "Home is at: $(echo ~)" - - name: Restore cache 💰 uses: actions/cache@v4 with: key: revdepcheck-${{ runner.os }}-${{ github.event.repository.name }} path: | - /github/home/.cache/R/pkgcache/pkg - /github/home/.cache/R-crancache + ~/.cache/R/pkgcache/pkg + ~/.cache/R-crancache - name: Check commit message 💬 run: | @@ -91,28 +86,11 @@ jobs: - name: revdepcheck 🔄 id: revdepcheck - # TODO update branch to main uses: insightsengineering/r-revdepcheck-action@initialize-action with: github-token: ${{ steps.github-token.outputs.token }} additional-env-vars: ${{ inputs.additional-env-vars }} - - name: Get cache - if: always() - run : | - crancache_path="$(R -q -e 'cat(normalizePath(crancache::get_cache_dir()), "\n")' 2>/dev/null | head -2 | tail -1 | tr -d ' ')" - pkgcache_path="$(R -q -e 'cat(pkgcache::pkg_cache_summary()$cachepath, "\n")' 2>/dev/null | head -2 | tail -1 | tr -d ' ')" - echo "crancache_path = $crancache_path" - echo "pkgcache_path = $pkgcache_path" - echo "crancache size:" - du -sh "$crancache_path" || true - echo "pkgcache size:" - du -sh "$pkgcache_path" || true - apt-get update && apt-get install -yq tree - echo "listing cache directory" - tree ~/.cache - shell: bash - - name: GChat notification 🔔 if: (failure() || cancelled()) && steps.revdepcheck.outcome != 'success' && env.gchat_webhook != '' uses: insightsengineering/google-chat-notification@master @@ -121,7 +99,7 @@ jobs: url: ${{ secrets.GCHAT_WEBHOOK }} status: ${{ job.status }} - - name: Prepare revdep artifact + - name: Prepare revdep artifact 🎁 run: | rm -rf revdep/library.noindex rm -rf revdep/library From b66f8dc4b16a62c2f50d128eeb07cc08dafee2d5 Mon Sep 17 00:00:00 2001 From: walkowif <59475134+walkowif@users.noreply.github.com> Date: Thu, 25 Apr 2024 17:31:17 +0200 Subject: [PATCH 12/12] Update .github/workflows/revdepcheck.yaml Signed-off-by: walkowif <59475134+walkowif@users.noreply.github.com> --- .github/workflows/revdepcheck.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml index e89464a6..73f6eacb 100644 --- a/.github/workflows/revdepcheck.yaml +++ b/.github/workflows/revdepcheck.yaml @@ -86,7 +86,7 @@ jobs: - name: revdepcheck 🔄 id: revdepcheck - uses: insightsengineering/r-revdepcheck-action@initialize-action + uses: insightsengineering/r-revdepcheck-action@main with: github-token: ${{ steps.github-token.outputs.token }} additional-env-vars: ${{ inputs.additional-env-vars }}