-
Notifications
You must be signed in to change notification settings - Fork 5
/
action.yml
95 lines (89 loc) · 3.75 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: R Package Validation Report
author: Roche
description: |
A Github Action that generates a validation report for an R package.
inputs:
report_pkg_dir:
description: Path to package's root.
required: false
default: "."
report_template_path:
description: |
File path of the R markdown template to use for the report.
The default template is available [here.](./template.qmd)
required: false
default: "./template.qmd"
no_cache:
description: "Disable github action R dependency caching"
required: false
default: "false"
cache_version:
description: "Version of the cache. To clean cache bump this version."
required: false
default: "v1"
disable_install_dev_deps:
description: |
Disable installation of dev dependencies while
building the report.
required: false
default: "false"
branding: # https://feathericons.com/
icon: "award"
color: "blue"
runs:
using: "composite"
steps:
- name: Get R version
id: r_version
run: echo "R_VERSION=$(R --version | head -1 | awk '{print $3}')" >> $GITHUB_OUTPUT
shell: bash
- name: Set R Library home on Linux
run: |
mkdir -p ${RUNNER_TEMP}/Library
echo ".libPaths(c('${RUNNER_TEMP}/Library', .libPaths()))" > ~/.Rprofile
cat ~/.Rprofile
shell: bash
- name: Cache R packages
if: "contains(inputs.no_cache, 'false')"
uses: actions/cache@v4
with:
path: /home/runner/work/_temp/Library
key: ${{ inputs.cache_version }}-${{ runner.os }}-${{ steps.r_version.outputs.R_VERSION }}-${{ hashFiles('DESCRIPTION') }}
restore-keys: ${{ inputs.cache_version }}-${{ runner.os }}-${{ steps.r_version.outputs.R_VERSION }}
- name: Install dependencies
run: |
${GITHUB_ACTION_PATH}/dependencies.R
[ ! -f "./template.qmd" ] && cp ${GITHUB_ACTION_PATH}/template.qmd . || echo "./template.qmd already exists"
MIN_QUARTO_VERSION="1.5.29"
if [[ "$(echo -e "$(quarto --version)\n${MIN_QUARTO_VERSION}" | sort -V | head -1)" == "${MIN_QUARTO_VERSION}" ]]; then
echo "✅ Quarto CLI version sufficient (>= ${MIN_QUARTO_VERSION})"
echo "Quarto CLI version: $(quarto --version)"
else
echo "❌ Quarto CLI version insufficient (< ${MIN_QUARTO_VERSION})"
apt-get update
apt-get install -qy wget jq
# Install newer version of Quarto CLI.
# This gets the latest version number (v1.5 up to v1.9) of Quarto from GitHub releases.
# It assumes that such version number (v1.5 up to v1.9) exists within the last 100 released Quarto versions.
export QUARTO_VERSION="$(curl -L -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/quarto-dev/quarto-cli/releases?per_page=100 \
2>/dev/null | \
jq -r 'map(select(.tag_name | test("^v1.[5-9]"))) | .[0].name[1:]')"
echo "Downloading and installing latest Quarto CLI version ${QUARTO_VERSION}"
wget https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb
dpkg -i quarto-${QUARTO_VERSION}-linux-amd64.deb
echo "New Quarto CLI version: $(quarto --version)"
fi
shell: bash
- name: Run report generator
id: report-generator
run: |
${GITHUB_ACTION_PATH}/report-generator.R
shell: bash
env:
# Composite action doesn't set inputs as env vars.
# We need to do this manually...
INPUT_REPORT_PKG_DIR: ${{ inputs.report_pkg_dir }}
INPUT_REPORT_TEMPLATE_PATH: ${{ inputs.report_template_path }}
DISABLE_INSTALL_DEV_DEPS: ${{ inputs.disable_install_dev_deps }}