From 537cbd2cf965ddcc6ab89ad4bc4018690fd0edba Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 26 Jun 2024 10:37:25 +0200 Subject: [PATCH] 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