Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to have multiple unit test reports in the pkgdown documentation #245

Merged
merged 7 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions .github/workflows/build-check-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ on:
required: false
type: boolean
default: false
unit-test-report-directory:
description: |
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"

concurrency:
group: r-cmd-${{ inputs.concurrency-group }}-${{ github.event.pull_request.number || github.ref }}
Expand Down Expand Up @@ -563,7 +573,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 ⚙️
Expand Down Expand Up @@ -783,7 +793,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
Expand Down Expand Up @@ -823,7 +833,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 🗞️
Expand All @@ -832,7 +842,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 +852,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 +862,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 All @@ -884,7 +894,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
Expand Down
44 changes: 41 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 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
type: string
default: ""

concurrency:
group: docs-${{ github.event.pull_request.number || github.ref }}
Expand Down Expand Up @@ -254,13 +264,41 @@ 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 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 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 }}"
else
directories_to_retain="coverage-report,unit-test-report"
fi
walkowif marked this conversation as resolved.
Show resolved Hide resolved
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
echo "Current contents of $GH_PAGES_DIR:"
ls -l $GH_PAGES_DIR
walkowif marked this conversation as resolved.
Show resolved Hide resolved
# 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
walkowif marked this conversation as resolved.
Show resolved Hide resolved
cd gh-pages
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
Expand Down
Loading