Skip to content

Commit

Permalink
Use centralized CRAN status check action (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
cicdguy authored Oct 30, 2023
1 parent 710e632 commit b235aa8
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 255 deletions.
12 changes: 0 additions & 12 deletions .github/actions/cran-status-extract/Dockerfile

This file was deleted.

25 changes: 0 additions & 25 deletions .github/actions/cran-status-extract/action.yml

This file was deleted.

111 changes: 0 additions & 111 deletions .github/actions/cran-status-extract/check-status.R

This file was deleted.

2 changes: 0 additions & 2 deletions .github/actions/cran-status-extract/entrypoint.sh

This file was deleted.

107 changes: 4 additions & 103 deletions .github/workflows/cran-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
invisible()
}
setHook("UserHook::admiralci::tweak_page", tweak_rdrr_url)
print("Tweak rdrr.io links for admiral pharmaverse packages.")
Expand Down

0 comments on commit b235aa8

Please sign in to comment.