forked from insightsengineering/thevalidatoR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
122 lines (113 loc) · 4.34 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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.Rmd)
required: false
default: "./template.Rmd"
report_rmarkdown_format:
description: |
The file format of the validation report. See `rmarkdown::render`'s
`output_format` parameter for accepted values.
required: false
default: "all"
report_output_prefix:
description: >
The output filename prefix for the validation report. If left blank,
it defaults to the following convention:
`<package name>-<package version>-validation-report`.
required: false
default: ""
additional_tlmgr_packages:
description: |
Additional tex packages to install with tlmgr.
required: false
default: "courier ec"
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"
outputs:
report_output_filename:
description: Filename of the generated report.
value: ${{ steps.report-generator.outputs.output-filename }}
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: Set tlmgr cache folder
if: "contains(inputs.no_cache, 'false')"
id: texlive_version
run: |
echo "TEX_LIVE_VERSION=$(tlmgr --version |tail -1 |awk '{print $NF}')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache R packages
if: "contains(inputs.no_cache, 'false')"
uses: actions/cache@v2
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: Cache Tex packages
if: "contains(inputs.no_cache, 'false')"
uses: actions/cache@v2
with:
path: /home/runner/work/_temp/TinyTeX
key: ${{ inputs.cache_version }}-${{ runner.os }}-${{ steps.texlive_version.outputs.TEX_LIVE_VERSION }}-${{ hashFiles(inputs.report_template_path) }}
restore-keys: ${{ inputs.cache_version }}-${{ runner.os }}-${{ steps.texlive_version.outputs.TEX_LIVE_VERSION }}
- name: Install dependencies
run: |
${GITHUB_ACTION_PATH}/dependencies.R
export PATH=${RUNNER_TEMP}/TinyTeX/bin/x86_64-linux:${PATH}
echo "PATH=${PATH}" >> $GITHUB_ENV
tlmgr path add
tlmgr update --self
[ ! -f "./template.Rmd" ] && cp ${GITHUB_ACTION_PATH}/template.Rmd . || echo "./template.Rmd Already exists"
shell: bash
- name: Install additional tex packages
run: tlmgr install ${{ inputs.additional_tlmgr_packages }}
shell: bash
- name: Run report generator
id: report-generator
run: |
${GITHUB_ACTION_PATH}/report-generator.R
filename=$(basename $(cat /tmp/report_file_path.txt))
echo "output-filename=${filename}" >> $GITHUB_OUTPUT
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 }}
INPUT_REPORT_RMARKDOWN_FORMAT: ${{ inputs.report_rmarkdown_format }}
INPUT_REPORT_OUTPUT_PREFIX: ${{ inputs.report_output_prefix }}
DISABLE_INSTALL_DEV_DEPS: ${{ inputs.disable_install_dev_deps }}