Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
walkowif committed Jun 26, 2024
1 parent 9993cb3 commit 537cbd2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/build-check-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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: >
Expand All @@ -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: >
Expand All @@ -852,15 +861,15 @@ 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'
uses: peaceiris/actions-gh-pages@v4
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
Expand Down
41 changes: 38 additions & 3 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 537cbd2

Please sign in to comment.