Skip to content

Build site.

Build site. #149

Workflow file for this run

---
name: CI
# yamllint disable-line rule:truthy
on:
push:
branches:
- develop
workflow_dispatch:
repository_dispatch:
concurrency:
group: ci
cancel-in-progress: true
jobs:
lint:
name: Apply lintr in all R and Rmd files
runs-on: ubuntu-latest
# runs-on: self-hosted
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RENV_PATHS_ROOT: ~/.local/share/renv
steps:
- name: Checking out shallow repository
uses: actions/checkout@v2
- run: git branch
- name: Setting up R installation
uses: r-lib/actions/setup-r@v2
- name: Cache R packages
uses: actions/cache@v2.1.4
id: cache-packages
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}-targets-v2
restore-keys: |
${{ runner.os }}-renv-
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install other dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgit2-dev libharfbuzz-dev libcurl4-openssl-dev \
libfribidi-dev libzmq3-dev libmagick++-dev
- name: Install dependencies
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
Sys.unsetenv("GITHUB_PAT")
renv::restore()
shell: Rscript {0}
- name: Lint
run: |
library(lintr)
for (i in c("analysis", "R", "scripts", "review", "thesis", "output")) {
print(lint_dir(i, linters = with_defaults(
open_curly_linter = NULL, T_and_F_symbol_linter,
assignment_linter, closed_curly_linter = NULL, commas_linter, commented_code_linter = NULL,
cyclocomp_linter(50), object_name_linter(styles = "snake_case"), object_length_linter(30),
equals_na_linter, function_left_parentheses_linter, infix_spaces_linter,
line_length_linter(500), no_tab_linter, object_usage_linter = NULL, paren_brace_linter,
absolute_path_linter(lax = TRUE), nonportable_path_linter = NULL, pipe_continuation_linter,
semicolon_terminator_linter(semicolon = "trailing"), seq_linter, single_quotes_linter,
spaces_inside_linter, spaces_left_parentheses_linter, trailing_blank_lines_linter,
trailing_whitespace_linter, undesirable_function_linter, undesirable_operator_linter,
unneeded_concatenation_linter
), exclusions = list("R/RcppExports.R")))
}
shell: Rscript {0}
targets:
name: Run targets pipeline
needs: lint
runs-on: ubuntu-latest
# runs-on: self-hosted
if: "contains(github.event.head_commit.message, 'targets')"
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RENV_PATHS_ROOT: ~/.local/share/renv
steps:
- name: Checking out shallow repository
uses: actions/checkout@v2
- run: git branch
- name: Setting up R installation
uses: r-lib/actions/setup-r@v2
- name: Setting up pandoc and pandoc-citeproc
uses: r-lib/actions/setup-pandoc@v2
- name: Cache R packages
uses: actions/cache@v2.1.4
id: cache-packages
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}-targets-v2
restore-keys: |
${{ runner.os }}-renv-
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install other dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgit2-dev libharfbuzz-dev libcurl4-openssl-dev \
libfribidi-dev libzmq3-dev libmagick++-dev
- name: Install dependencies
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
Sys.unsetenv("GITHUB_PAT")
renv::install(".")
renv::restore()
shell: Rscript {0}
- name: Check if previous runs exist
id: runs-exist
run: git ls-remote --exit-code --heads origin targets-runs
continue-on-error: true
- name: Checking out shallow previous run
if: steps.runs-exist.outcome == 'success'
uses: actions/checkout@v2
with:
ref: targets-runs
path: .targets-runs
- name: Restore output files from the previous run
if: steps.runs-exist.outcome == 'success'
run: |
for (dest in scan(".targets-runs/.targets-files", what = character())) {
source <- file.path(".targets-runs", dest)
if (!file.exists(dirname(dest))) dir.create(dirname(dest), recursive = TRUE)
if (file.exists(source)) file.rename(source, dest)
}
shell: Rscript {0}
- name: Run targets pipeline
run: renv::run('run.R')
shell: Rscript {0}
continue-on-error: true # if the pipeline fails, the workspace is saved for inspection.
- name: Identify files that the targets pipeline produced
id: check-new-files
run: |
git ls-files -mo -x renv -x inst -x src > .targets-files
([ -s .targets-files ] && echo "New files produced" && cat .targets-files && echo "::set-output name=newfiles::true") || (echo "Nothing to do" && echo "::set-output name=newfiles::false")
- name: Update the current repository without the objects
if: steps.check-new-files.outputs.newfiles == 'true'
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "actions@github.com"
git add --all -- ':!renv'
git commit -am "Update current branch"
git push --quiet
continue-on-error: true
- name: Create the runs branch if it does not already exist
if: steps.check-new-files.outputs.newfiles == 'true' && steps.runs-exist.outcome != 'success'
run: git checkout --orphan targets-runs
continue-on-error: true # if the pipeline fails, the workspace is saved for inspection.
- name: Put the worktree in the runs branch if the latter already exists
if: steps.check-new-files.outputs.newfiles == 'true' && steps.runs-exist.outcome == 'success'
run: |
rm -r .git
mv .targets-runs/.git .
rm -r .targets-runs
continue-on-error: true # if the pipeline fails, the workspace is saved for inspection.
- name: Upload latest run to the runs branch
if: steps.check-new-files.outputs.newfiles == 'true'
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "actions@github.com"
rm -r .github/workflows
git add --all -- ':!renv'
git add -f .targets-files
git add -f _targets
git commit -am "Run pipeline"
git push origin targets-runs
continue-on-error: true # if the pipeline fails, the workspace is saved for inspection.
- name: Prepare failure artifact
if: failure()
run: rm -rf .git .github .targets-files .targets-runs
- name: Post failure artifact
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r-targets-results
path: .
workflowr:
name: Runs Workflowr versioning
runs-on: ubuntu-latest
# runs-on: self-hosted
if: "contains(github.event.head_commit.message, 'workflowr')"
needs:
- lint
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RENV_PATHS_ROOT: ~/.local/share/renv
steps:
- name: Checking out deep repository
uses: actions/checkout@v2
with:
fetch-depth: 0 ## all history
ref: ${{ github.event.workflow_run.head_branch }}
- run: git branch
- run: echo ${{ github.event.head_commit.message }}
- name: Setting up R installation
uses: r-lib/actions/setup-r@v2
- name: Setting up pandoc and pandoc-citeproc
uses: r-lib/actions/setup-pandoc@v2
- name: Setting up tinytex
uses: r-lib/actions/setup-tinytex@v2
- name: Install additional LaTeX packages
run: |
tlmgr --version
tlmgr install svg subfig
tlmgr list --only-installed
- name: Cache R packages
uses: actions/cache@v2.1.4
id: cache-packages
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}-targets-v2
restore-keys: |
${{ runner.os }}-renv-
- name: Query dependencies
run: |
install.packages('remotes')
install.packages('yaml')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install other dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgit2-dev libharfbuzz-dev libcurl4-openssl-dev \
libfribidi-dev libzmq3-dev libmagick++-dev
- name: Install dependencies
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
Sys.unsetenv("GITHUB_PAT")
renv::restore()
shell: Rscript {0}
# - name: pull database
# run: |
# chmod 755 run.R && ./run.R -r FALSE
# shell: bash
- name: Knit thesisdown
run: |
bookdown::render_book("thesis", output_format="all")
shell: Rscript {0}
- name: Configure git and stage changes
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "actions@github.com"
git add --all -- ':!renv'
git commit -am "Update thesisdown"
- name: Build workflowr that creates the commit
run: workflowr::wflow_publish(all = TRUE, update = TRUE, verbose = TRUE)
shell: Rscript {0}
- name: Push changes
run: |
git push