generated from pharmaverse/admiraltemplate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use centralized CRAN status check action (#161)
- Loading branch information
Showing
6 changed files
with
6 additions
and
255 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,108 +44,9 @@ jobs: | |
container: | ||
image: rocker/tidyverse:latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
- name: Run CRAN Status Action | ||
uses: insightsengineering/cran-status-action@v1 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get Date | ||
id: today | ||
run: | | ||
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
- name: Get current package name | ||
id: current_package | ||
run: | | ||
package_name=$(grep "Package:" DESCRIPTION | awk '{print $NF}') | ||
echo "package_name=$package_name" >> $GITHUB_OUTPUT | ||
- name: Create orphan branch | ||
id: create_orphan | ||
run: | | ||
git config --global --add safe.directory ${PWD} | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "pharmaverse-bot" | ||
git fetch origin cran_status:cran_status || true | ||
cran_status_branch=$(git branch -a --list cran_status) | ||
# Try to create a new orphan branch if it does not already exist | ||
if [ -z "${cran_status_branch}" ] | ||
then { | ||
echo "🟡 Create cran_status branch" | ||
git checkout --orphan cran_status | ||
mkdir -p /tmp/${{ github.sha }} | ||
cp -r .git /tmp/${{ github.sha }} | ||
cd /tmp/${{ github.sha }} | ||
echo "# CRAN Status" > README.md | ||
git reset | ||
git add --all -f | ||
git commit -m "Initialize orphan cran_status branch" | ||
orphan_exists='false' | ||
git push --set-upstream origin cran_status | ||
} else { | ||
echo "🟢 cran_status branch exists!" | ||
orphan_exists='true' | ||
git checkout | ||
} | ||
fi | ||
echo "orphan_exists=$orphan_exists" >> $GITHUB_OUTPUT | ||
- name: Compute Cran Status md5 codes | ||
uses: pharmaverse/admiralci/.github/actions/cran-status-extract@main | ||
with: | ||
statuses: "${{ inputs.statuses }}" | ||
package: "${{ steps.current_package.outputs.package_name }}" | ||
|
||
- name: Update cran_status branch | ||
id: cran_errors_status | ||
run: | | ||
new_errors=false | ||
cran_status_path="${{ inputs.path }}/cran_errors.csv" | ||
if [ -e ./cran_errors.csv ]; then | ||
current_status_content=$(cat "./cran_errors.csv") | ||
mkdir -p cran_status | ||
# read previous cran status from this branch (ls sort files by alphabetic number) | ||
if [ -z "$(ls -A ./cran_status)" ]; then | ||
# case first writing on the orphan branch (cran_status dir is empty) | ||
last_status_content="FIRST WRITING" | ||
else | ||
last_status_file=$(ls ./cran_status | tail -n 1) | ||
last_status_content=$(cat "./cran_status/$last_status_file") | ||
fi | ||
# check if the status is a new error: | ||
if [ "$current_status_content" != "$last_status_content" ]; then | ||
echo "New errors on the cran status found - package ${{ steps.current_package.outputs.package_name }}" | ||
new_errors=true | ||
cp ./cran_errors.csv "./cran_status/${{ steps.today.outputs.date }}.csv" | ||
else | ||
echo "New errors on the cran status found, but identical to previous ones - package ${{ steps.current_package.outputs.package_name }}" | ||
fi | ||
else | ||
echo "No errors found on the cran status - package ${{ steps.current_package.outputs.package_name }}" | ||
fi | ||
echo "new_errors=$new_errors" >> $GITHUB_OUTPUT | ||
- name: Report Status | ||
if: ${{ steps.cran_errors_status.outputs.new_errors == 'true' }} | ||
uses: peter-evans/create-issue-from-file@v4 | ||
with: | ||
title: "URGENT! Failed CRAN Checks: ${{ steps.today.outputs.date }}" | ||
content-filepath: ./${{ inputs.path }}/cran-status.md | ||
assignees: ${{ inputs.issue-assignees }} | ||
|
||
- name: Clean Repo and add changes | ||
if: ${{ steps.cran_errors_status.outputs.new_errors == 'true' }} | ||
run: | | ||
rm ./cran_errors.csv 2> /dev/null | ||
rm ./cran-status.md 2> /dev/null | ||
git config --global --add safe.directory ${PWD} | ||
git add "./cran_status/${{ steps.today.outputs.date }}.csv" | ||
- name: Commit and push to orphan branch | ||
if: ${{ steps.cran_errors_status.outputs.new_errors == 'true' }} | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: update cran status "${{ steps.today.outputs.date }}" | ||
branch: cran_status | ||
create_branch: false | ||
issue-assignees: "${{ inputs.issue-assignees }}" | ||
path: "${{ inputs.path }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,7 +141,7 @@ jobs: | |
- name: Install package | ||
run: renv::install(".", dependencies = "no-deps") | ||
shell: Rscript {0} | ||
|
||
- name: Add script to fix rdrr.io links for pharmaverse packages | ||
uses: "DamianReeves/[email protected]" | ||
with: | ||
|
@@ -184,7 +184,7 @@ jobs: | |
invisible() | ||
} | ||
setHook("UserHook::admiralci::tweak_page", tweak_rdrr_url) | ||
print("Tweak rdrr.io links for admiral pharmaverse packages.") | ||
|