From 537cbd2cf965ddcc6ab89ad4bc4018690fd0edba Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 26 Jun 2024 10:37:25 +0200 Subject: [PATCH 1/5] Update --- .github/workflows/build-check-install.yaml | 17 ++++++--- .github/workflows/pkgdown.yaml | 41 ++++++++++++++++++++-- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 5fc2fe5c2..788ac8e87 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -186,6 +186,15 @@ on: required: false type: boolean default: false + unit-test-report-directory: + description: | + Directory name on gh-pages branch where the unit test report should be uploaded. + For any additional unit test report directories to be retained by the pkgdown workflow + in the gh-pages branch, they have to be added to the additional-unit-test-report-directories + pkgdown workflow input. + required: false + type: string + default: "unit-test-report" concurrency: group: r-cmd-${{ inputs.concurrency-group }}-${{ github.event.pull_request.number || github.ref }} @@ -832,7 +841,7 @@ jobs: with: github_token: ${{ steps.github-token.outputs.token }} publish_dir: ./unit-test-report - destination_dir: ${{ needs.build-install-check.outputs.current-branch-or-tag }}/unit-test-report + destination_dir: ${{ needs.build-install-check.outputs.current-branch-or-tag }}/${{ inputs.unit-test-report-directory }} - name: Upload JUnit HTML report to GitHub pages (latest-tag) ๐Ÿท๏ธ if: > @@ -842,7 +851,7 @@ jobs: with: github_token: ${{ steps.github-token.outputs.token }} publish_dir: ./unit-test-report - destination_dir: ${{ inputs.latest-tag-alt-name }}/unit-test-report + destination_dir: ${{ inputs.latest-tag-alt-name }}/${{ inputs.unit-test-report-directory }} - name: Upload JUnit HTML report to GitHub pages (release-candidate) ๐Ÿท๏ธ if: > @@ -852,7 +861,7 @@ jobs: with: github_token: ${{ steps.github-token.outputs.token }} publish_dir: ./unit-test-report - destination_dir: ${{ inputs.release-candidate-alt-name }}/unit-test-report + destination_dir: ${{ inputs.release-candidate-alt-name }}/${{ inputs.unit-test-report-directory }} - name: Upload JUnit HTML report to GitHub pages (non-multiversion) ๐Ÿ—ž๏ธ if: needs.build-install-check.outputs.multiversion-docs == 'false' @@ -860,7 +869,7 @@ jobs: with: github_token: ${{ steps.github-token.outputs.token }} publish_dir: ./unit-test-report - destination_dir: unit-test-report + destination_dir: ${{ inputs.unit-test-report-directory }} upload-release-assets: name: Upload build tar.gz diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index d2a0142de..c11ce3b41 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -111,6 +111,16 @@ on: required: false type: string default: "." + additional-unit-test-report-directories: + description: | + If there are any additional unit test reports directories generated, they should be listed + as comma-separated directory list. If this input is empty, only coverage-report and + unit-test-report directories will be retained in the generated documentation directory. + Example: + unit-test-report-as-cran,unit-test-report-not-cran + required: false + type: string + default: "" concurrency: group: docs-${{ github.event.pull_request.number || github.ref }} @@ -255,9 +265,34 @@ jobs: GH_PAGES_DIR="gh-pages/${{ steps.current-branch-or-tag.outputs.ref-name }}" mkdir -p $GH_PAGES_DIR ls -l $GH_PAGES_DIR - # Remove contents except coverage-report and unit-test-report directories. - find $GH_PAGES_DIR -mindepth 1 -maxdepth 1 \ - ! -name coverage-report ! -name unit-test-report -exec rm -rf {} + + # Remove any existing documentation for the git tag, but retain + # coverage report and unit test report which might have already been generated + # by the coverage and build-check-install workflows respectively. + if [[ "${{ inputs.additional-unit-test-report-directories }}" != "" ]]; then + directories_to_retain="coverage-report,unit-test-report,${{ inputs.additional-unit-test-report-directories }}" + else + directories_to_retain="coverage-report,unit-test-report" + fi + IFS=',' read -ra DIRECTORIES_TO_RETAIN <<< "$directories_to_retain" + echo "The following directories will be retained:" + for dir in "${DIRECTORIES_TO_RETAIN[@]}"; do + echo "$dir" + done + # Remove all files from GH_PAGES_DIR, except any DIRECTORIES_TO_RETAIN. + find $GH_PAGES_DIR -mindepth 1 -maxdepth 1 -print0 | while IFS= read -r -d '' file; do + file_to_be_removed="true" + # Check if the file/directory matches any directory to be retained. + for dir in "${DIRECTORIES_TO_RETAIN[@]}"; do + if [[ "$GH_PAGES_DIR/$dir" == "$file" ]]; then + echo "Not removing $file." + file_to_be_removed="false" + fi + done + if [[ "$file_to_be_removed" == "true" ]]; then + echo "Removing $file." + rm -rf "$file" + fi + done ls -l $GH_PAGES_DIR # Copy generated pkgdown documentation to gh-pages branch. cp -a ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }}/docs/. $GH_PAGES_DIR From aebeb5978607e94d59a0ba011ae6d51d267e1efa Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 26 Jun 2024 11:13:01 +0200 Subject: [PATCH 2/5] Update --- .github/workflows/build-check-install.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 788ac8e87..80c9a5167 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -572,7 +572,7 @@ jobs: && github.event_name != 'pull_request' uses: actions/upload-artifact@v4 with: - name: unit-test-report + name: unit-test-report-${{ inputs.concurrency-group }} path: "index.html" - name: Set output โš™๏ธ From 6a01bceb40f4a779d5fbc579d5bed404ef96aa8d Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 26 Jun 2024 11:29:43 +0200 Subject: [PATCH 3/5] Update --- .github/workflows/build-check-install.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 80c9a5167..a903041ee 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -792,7 +792,7 @@ jobs: uses: actions/upload-artifact@v4 with: path: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }}/${{ env.PKGBUILD }} - name: ${{ env.PKGBUILD }} + name: ${{ env.PKGBUILD }}-${{ inputs.concurrency-group }} - name: Upload logs artifact ๐Ÿ—ž๏ธ uses: actions/upload-artifact@v4 @@ -832,7 +832,7 @@ jobs: - name: Download JUnit HTML report as artifact โคต๏ธ uses: actions/download-artifact@v4 with: - name: unit-test-report + name: unit-test-report-${{ inputs.concurrency-group }} path: unit-test-report - name: Upload JUnit HTML report to GitHub pages ๐Ÿ—ž๏ธ @@ -893,7 +893,7 @@ jobs: - name: Download artifact โฌ uses: actions/download-artifact@v4 with: - name: ${{ env.PKGBUILD }} + name: ${{ env.PKGBUILD }}-${{ inputs.concurrency-group }} - name: Check if release exists id: check-if-release-exists From 90f3e0a112592cec308a126278343e629c4d130e Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 26 Jun 2024 12:11:33 +0200 Subject: [PATCH 4/5] Update --- .github/workflows/build-check-install.yaml | 9 +++++---- .github/workflows/pkgdown.yaml | 17 ++++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index a903041ee..8967eb6ab 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -188,10 +188,11 @@ on: default: false unit-test-report-directory: description: | - Directory name on gh-pages branch where the unit test report should be uploaded. - For any additional unit test report directories to be retained by the pkgdown workflow - in the gh-pages branch, they have to be added to the additional-unit-test-report-directories - pkgdown workflow input. + Directory name on gh-pages branch where the unit test report will be uploaded. + If the unit test report directory is different than the default 'unit-test-report', + it has to be added to the additional-unit-test-report-directories pkgdown workflow input. + Additionally, if the non-default unit test report should be shown in the GitHub Pages + documentation drop-down, it has to be added to _pkgdown.yaml. required: false type: string default: "unit-test-report" diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index c11ce3b41..2b181db36 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -113,9 +113,9 @@ on: default: "." additional-unit-test-report-directories: description: | - If there are any additional unit test reports directories generated, they should be listed - as comma-separated directory list. If this input is empty, only coverage-report and - unit-test-report directories will be retained in the generated documentation directory. + If any *additional* unit test report directories are generated by the build-check-install workflow, + they should be listed as comma-separated directory list. If this input is empty, only coverage-report + and unit-test-report directories will be retained in the generated documentation directory. Example: unit-test-report-as-cran,unit-test-report-not-cran required: false @@ -264,9 +264,10 @@ jobs: run: | GH_PAGES_DIR="gh-pages/${{ steps.current-branch-or-tag.outputs.ref-name }}" mkdir -p $GH_PAGES_DIR + echo "Current contents of $GH_PAGES_DIR:" ls -l $GH_PAGES_DIR - # Remove any existing documentation for the git tag, but retain - # coverage report and unit test report which might have already been generated + # Remove any existing documentation for the git tag, but retain coverage report and + # unit test reports which might have already been pushed to the gh-pages branch # by the coverage and build-check-install workflows respectively. if [[ "${{ inputs.additional-unit-test-report-directories }}" != "" ]]; then directories_to_retain="coverage-report,unit-test-report,${{ inputs.additional-unit-test-report-directories }}" @@ -284,18 +285,20 @@ jobs: # Check if the file/directory matches any directory to be retained. for dir in "${DIRECTORIES_TO_RETAIN[@]}"; do if [[ "$GH_PAGES_DIR/$dir" == "$file" ]]; then - echo "Not removing $file." + echo "Not removing $file" file_to_be_removed="false" fi done if [[ "$file_to_be_removed" == "true" ]]; then - echo "Removing $file." + echo "Removing $file" rm -rf "$file" fi done + echo "Current contents of $GH_PAGES_DIR:" ls -l $GH_PAGES_DIR # Copy generated pkgdown documentation to gh-pages branch. cp -a ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }}/docs/. $GH_PAGES_DIR + echo "Current contents of $GH_PAGES_DIR:" ls -l $GH_PAGES_DIR cd gh-pages git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" From 90b2f6cc848e80f3fce4a2d8626724e4fd1c25d4 Mon Sep 17 00:00:00 2001 From: walkowif <59475134+walkowif@users.noreply.github.com> Date: Tue, 2 Jul 2024 12:29:33 +0200 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: cicdguy <26552821+cicdguy@users.noreply.github.com> Signed-off-by: walkowif <59475134+walkowif@users.noreply.github.com> --- .github/workflows/pkgdown.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 2b181db36..d8bef9320 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -269,10 +269,9 @@ jobs: # Remove any existing documentation for the git tag, but retain coverage report and # unit test reports which might have already been pushed to the gh-pages branch # by the coverage and build-check-install workflows respectively. + directories_to_retain="coverage-report,unit-test-report" if [[ "${{ inputs.additional-unit-test-report-directories }}" != "" ]]; then - directories_to_retain="coverage-report,unit-test-report,${{ inputs.additional-unit-test-report-directories }}" - else - directories_to_retain="coverage-report,unit-test-report" + directories_to_retain="${directories_to_retain},${{ inputs.additional-unit-test-report-directories }}" fi IFS=',' read -ra DIRECTORIES_TO_RETAIN <<< "$directories_to_retain" echo "The following directories will be retained:" @@ -294,12 +293,16 @@ jobs: rm -rf "$file" fi done + echo "::group::gh-pages contents" echo "Current contents of $GH_PAGES_DIR:" ls -l $GH_PAGES_DIR + echo "::endgroup::" # Copy generated pkgdown documentation to gh-pages branch. cp -a ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }}/docs/. $GH_PAGES_DIR + echo "::group::gh-pages contents" echo "Current contents of $GH_PAGES_DIR:" ls -l $GH_PAGES_DIR + echo "::endgroup::" cd gh-pages git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]"