Skip to content

Commit

Permalink
Add devel image (#165)
Browse files Browse the repository at this point in the history
* add checks for devel

* fix branch name

* update push job

* re-test

* fix checks

* fix typo

* fix

* fix

* fix

* install rcmdcheck for devel im

* templates: retrieve temp folder

* add checks on existing branches - templates

* debug traces

* fix cp cmd

* fix

* debug traces

* add other debug traces

* update

* add other debug traces

* test other folder

* fix condition branch

* fix checks

* test checks on maintenance versions

* fix

* trigger checks

* try ignore note

* retry

* try another regexp

* retry

* rework rcmdcheck

* fix

* fix

* fix

* fix

* fix

* cleanup

* change r-im-creator tag

* Update check-templates.yml

remove @devel

* add cron job

---------

Co-authored-by: pharmaverse-bot <[email protected]>
  • Loading branch information
dgrassellyb and pharmaverse-bot authored Nov 8, 2023
1 parent b7c8e96 commit 19bfb1d
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
^admiralci.*\.tgz$
^staged_dependencies.yaml$
^README.Rmd$
^.devcontainer
^.devcontainer
13 changes: 9 additions & 4 deletions .github/workflows/check-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,18 @@ jobs:
id: branch
run: |
repo_name=$(basename "${{ github.repository }}")
echo "source-branch=${{ env.source-branch }}_${repo_name}@devel" >> $GITHUB_OUTPUT
source_br="${{ env.source-branch }}_${repo_name}"
source_grep=$(git branch -a | grep $source_br)
if [ -z $source_grep ]; then branch_exists=false; else branch_exists=true; fi
echo "source-branch=$source_br" >> $GITHUB_OUTPUT
echo "branch-exists=$branch_exists" >> $GITHUB_OUTPUT
warn_msg="WARNING:: the branch $source_br already exists in pharmaverseadam, please merge it and delete it, and re-execute this job"
if [ '${{ steps.changes.outputs.diff }}' == 'true' ] && [ '$branch_exists' == 'true' ]; then echo "$warn_msg"; fi
shell: bash {0}


# if diff detected, push changes
- name: Commit and push changes in {{ env.repo }}
if: ${{ inputs.push-templates-data && steps.changes.outputs.diff == 'true' }}
if: ${{ inputs.push-templates-data && steps.changes.outputs.diff == 'true' && steps.branch.outputs.branch-exists == 'false' }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: templates data updates from ${{ github.repository }}
Expand All @@ -382,7 +387,7 @@ jobs:
create_branch: true

- name: Create Pull Request
if: ${{ inputs.push-templates-data && steps.changes.outputs.diff == 'true' }}
if: ${{ inputs.push-templates-data && steps.changes.outputs.diff == 'true' && steps.branch.outputs.branch-exists == 'false' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.PHARMAVERSE_BOT }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/propagate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- renv/**
- .Rprofile
- .devcontainer/*
workflow_dispatch: # give possibility to run it manually

jobs:
integrity:
Expand Down
42 changes: 40 additions & 2 deletions .github/workflows/push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
paths:
- 'renv/profiles/**/renv.lock'
workflow_dispatch: # give possibility to run it manually
schedule:
- cron: '0 0 * * *' # Run every day at midnight UTC

permissions: write-all
env:
Expand Down Expand Up @@ -50,6 +52,7 @@ jobs:
echo "renv=[\"$renv_list\"]" >> $GITHUB_OUTPUT
deploy-image:
if: github.event_name != 'schedule'
needs: [ get_renv_list ]
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -77,10 +80,10 @@ jobs:
run: |
package_name=$(grep "Package:" DESCRIPTION | awk '{print $NF}')
r_version=$(basename $(dirname ${{ matrix.value }})) # TODO: check here if legacy renv (if yes, delete _legacy suffix and add _legacy suffix to docker im?)
echo "r_version=$r_version" >> $GITHUB_OUTPUT
echo "image_name=$package_name-$r_version" >> $GITHUB_OUTPUT
renv=$(echo "${{ matrix.value }}" | tr -d '"')
echo "renv_lock_path=$renv" >> $GITHUB_OUTPUT
echo "r_version=$r_version" >> $GITHUB_OUTPUT
echo "image_name=$package_name-$r_version" >> $GITHUB_OUTPUT
- name: Call deploy docker image action for every renv
uses: insightsengineering/r-image-creator@v1
Expand All @@ -94,5 +97,40 @@ jobs:
repo-user: ${{ github.actor }} # pharmaverse-bot
repo-token: "${{ secrets.GITHUB_TOKEN }}" # ${{ secrets.PHARMAVERSE_BOT }}

deploy-image-devel:
runs-on: ubuntu-latest
# Token permissions
permissions:
contents: read
packages: write

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set image specs
id: image_specs
run: |
package_name=$(grep "Package:" DESCRIPTION | awk '{print $NF}')
echo "image_name=$package_name-devel" >> $GITHUB_OUTPUT
- name: Call deploy docker image action devel
uses: insightsengineering/r-image-creator@v1
with:
image-name: "${{ steps.image_specs.outputs.image_name }}"
tag-latest: true
base-image: "rocker/rstudio:devel"
sysdeps: qpdf,libxt-dev,curl,npm,libicu-dev,libcurl4-openssl-dev,libssl-dev,make,zlib1g-dev,libfontconfig1-dev,libfreetype6-dev,libfribidi-dev,libharfbuzz-dev,libjpeg-dev,libpng-dev,libtiff-dev,pandoc,libxml2-dev,libgit2-dev,libgit2-dev,jq
description-file: "./DESCRIPTION"
repository-owner: ${{ github.repository_owner }}
repo-user: ${{ github.actor }} # pharmaverse-bot
repo-token: "${{ secrets.GITHUB_TOKEN }}" # ${{ secrets.PHARMAVERSE_BOT }}


# refacto todo: image-name, sysdeps on get-renv-list job


# note: in case of 403 error when pushing to ghcr : link current repo to the given package registry - https://github.com/docker/build-push-action/issues/687
# (got to https://github.com/<user name>?tab=packages to go to packages settings) and there https://github.com/users/<user name>/packages/container/admiralci-4.0/settings
27 changes: 25 additions & 2 deletions .github/workflows/r-cmd-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- {r: '4.1', repos: 'https://packagemanager.posit.co/cran/2021-05-03/'}
- {r: '4.2', repos: 'https://packagemanager.posit.co/cran/2022-01-03/'}
- {r: '4.3', repos: 'https://packagemanager.posit.co/cran/__linux__/focal/latest'}
- {r: 'devel', repos: 'https://packagemanager.posit.co/cran/__linux__/focal/latest'} # not needed for devel ?

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -81,11 +82,33 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
#####################c#####################

- name: Check Version
id: check_version
run: |
maintenance_version="F"
description_dat <- readLines("DESCRIPTION")
for (i in seq_along(description_dat)) {
if (grepl("^Version:", description_dat[i])) {
current_version <- sub("^Version: ", "", description_dat[i])
version_parts <- strsplit(current_version, "\\.")[[1]]
# check if maintenance version - if yes, temp update the DESCRIPTION for rcmdchecks
if (length(version_parts) == 4) {
print("Maintenance version detected (format X.Y.Z.M with M >= 9000)")
maintenance_version="T"
}
}
}
cat(sprintf("maintenance_version=%s", maintenance_version), file = Sys.getenv("GITHUB_OUTPUT"), append = TRUE)
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
_R_CHECK_FORCE_SUGGESTS_: false
run: |
if ("${{steps.check_version.outputs.maintenance_version}}" == "T"){
Sys.setenv("_R_CHECK_CRAN_INCOMING_SKIP_LARGE_VERSION_" = TRUE)
}
if (!requireNamespace("rcmdcheck", quietly = TRUE)) install.packages("rcmdcheck")
options(crayon.enabled = TRUE)
check_error_on <- "${{ inputs.error-on }}"
Expand All @@ -103,5 +126,5 @@ jobs:
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
name: r${{ matrix.config.r }}-results
path: check

0 comments on commit 19bfb1d

Please sign in to comment.