An R package template with built-in GitHub Actions-based CI/CD workflows.
You could initialize this repository in one of two ways:
-
Clone this repository:
git clone https://github.com/insightsengineering/coursera.cicd.lab.git cd coursera.cicd.lab
-
Run the initializer script:
./init.sh
-
Click here to generate a copy of this template directly within GitHub.
-
Clone the repository from your account/organization.
-
Run the initializer script:
./init.sh
All CI/CD jobs are defined in the .github/workflows directory in the form of GitHub Action workflows. These can be modified per your requirements, but are designed and implemented to follow best practices and to ensure the highest quality standards for your package.
All workflows originating from this repository can be repurposed by other R package GitHub repositories.
๐ For more information including detailed description and screenshots of workflows, please refer to the Workflows documentation.
This repository contains an example pre-commit configuration.
pre-commit is a tool that uses Git hooks to identify and resolve simple issues before submission for code review. Git hooks run on every commit to automatically point out and solve issues such as missing semicolons, trailing whitespaces, code formatting and spell checks.
-
Install the
pre-commit
framework. Use the official installation guide. -
Install R package
precommit
R -e 'install.packages("precommit")'
-
Run the
use_precommit()
function to generate an example pre-commit configuration called.pre-commit-config.yaml
:[ ! -f ".pre-commit-config.yaml" ] && R -e 'precommit::use_precommit()'
-
Install the git hooks script:
pre-commit install
-
From this moment on, all scripts from
.pre-commit-config.yaml
will run before everygit commit
command. If you want to run them manually without committing you can use commandpre-commit run --all-files
. For more information, please refer to the official pre-commit documentation.
NOTE: Frequently run
pre-commit autoupdate
to update all hooks in the.pre-commit-config.yaml
configuration file.
$ git add .
$ git commit -m "Add pre-commit configuration"
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
style-files..............................................................Passed
roxygenize...........................................(no files to check)Skipped
use-tidy-description.....................................................Passed
spell-check..............................................................Failed
- hook id: spell-check
- exit code: 1
- files were modified by this hook
The following spelling errors were found:
WORD FOUND IN
commiting README.md:77
indentify README.md:49
informatoin README.md:77
All spelling errors found were copied to inst/WORDLIST assuming they were not spelling errors and will be ignored in the future. Please review the above list and for each word that is an actual typo:
- fix it in the source code.
- remove it again manually from inst/WORDLIST to make sure it's not
ignored in the future.
Then, try committing again.
Error: Spell check failed
Execution halted
lintr....................................................................Passed
readme-rmd-rendered......................................................Passed
parsable-R...............................................................Passed
no-browser-statement.....................................................Passed
deps-in-desc.............................................................Passed
prettier.................................................................Failed
- hook id: prettier
- files were modified by this hook
.pre-commit-config.yaml
README.md
Check for added large files..............................................Passed
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook
Fixing .pre-commit-config.yaml
Fixing README.md
Check Yaml...............................................................Passed
Don't commit to branch...................................................Passed
Mixed line ending........................................................Passed
Don't commit common R artifacts......................(no files to check)Skipped