tic.yml 4.62 KB
Newer Older
1
## tic GitHub Actions template: linux-macos-windows-deploy
kapsner's avatar
kapsner committed
2
## revision date: 2022-08-28
3
4
5
6
7
8
9
10
on:
  push:
  pull_request:
  # for now, CRON jobs only run on the default branch of the repo (i.e. usually on master)
  schedule:
    # * is a special character in YAML so you have to quote this string
    - cron: "0 4 * * *"

kapsner's avatar
kapsner committed
11
name: R CMD Check via {tic}
12
13
14
15
16
17
18
19
20
21
22
23

jobs:
  all:
    runs-on: ${{ matrix.config.os }}

    name: ${{ matrix.config.os }} (${{ matrix.config.r }})

    strategy:
      fail-fast: false
      matrix:
        config:
          # use a different tic template type if you do not want to build on all listed platforms
Lorenz Kapsner's avatar
Lorenz Kapsner committed
24
25
26
          - { os: windows-latest, r: "release", pkgdown: "true", latex: "true", java: "true" }
          - { os: macOS-latest, r: "release", pkgdown: "true", latex: "true", java: "true" }
          - { os: ubuntu-latest, r: "release", pkgdown: "true", latex: "true", java: "true" }
Lorenz Kapsner's avatar
Lorenz Kapsner committed
27
          - { os: ubuntu-latest, r: "devel", pkgdown: "true", latex: "true", java: "true" }
28
29

    env:
kapsner's avatar
kapsner committed
30
31
      # make sure to run `tic::use_ghactions_deploy()` to set up deployment
      TIC_DEPLOY_KEY: ${{ secrets.TIC_DEPLOY_KEY }}
32
33
34
35
36
37
38
39
40
      # prevent rgl issues because no X11 display is available
      RGL_USE_NULL: true
      # if you use bookdown or blogdown, replace "PKGDOWN" by the respective
      # capitalized term. This also might need to be done in tic.R
      BUILD_PKGDOWN: ${{ matrix.config.pkgdown }}
      # use GITHUB_TOKEN from GitHub to workaround rate limits in {remotes}
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

    steps:
kapsner's avatar
kapsner committed
41
      - uses: actions/checkout@v4
42

Lorenz Kapsner's avatar
Lorenz Kapsner committed
43
      - uses: r-lib/actions/setup-r@v2
44
45
46
47
        with:
          r-version: ${{ matrix.config.r }}
          Ncpus: 4

Lorenz Kapsner's avatar
Lorenz Kapsner committed
48
      - uses: r-lib/actions/setup-tinytex@v2
49
        if: matrix.config.latex == 'true'
kapsner's avatar
kapsner committed
50
51
52
53
54
55
56
      - run: tlmgr --version

      - name: Install additional LaTeX packages
        run: |
          tlmgr update --self
          tlmgr install babel-german
          tlmgr list --only-installed
57

Lorenz Kapsner's avatar
Lorenz Kapsner committed
58
      - uses: r-lib/actions/setup-pandoc@v2
Lorenz Kapsner's avatar
Lorenz Kapsner committed
59
60
        if: matrix.config.latex == 'true'

kapsner's avatar
kapsner committed
61
      - uses: actions/setup-java@v4
Lorenz Kapsner's avatar
Lorenz Kapsner committed
62
63
        if: matrix.config.java == 'true'
        with:
kapsner's avatar
kapsner committed
64
65
66
67
68
69
          distribution: 'temurin'
          java-version: '11'

      - name: Install sys deps for Ubuntu
        if: runner.os == 'Linux'
        run: sudo apt update && sudo apt install -y libgit2-dev libcurl4-openssl-dev
70
71
72
73
74
75
76

      # set date/week for use in cache creation
      # https://github.community/t5/GitHub-Actions/How-to-set-and-access-a-Workflow-variable/m-p/42970
      # - cache R packages daily
      - name: "[Cache] Prepare daily timestamp for cache"
        if: runner.os != 'Windows'
        id: date
kapsner's avatar
kapsner committed
77
        run: echo "date=$(date '+%d-%m')" >> $GITHUB_OUTPUT
78

kapsner's avatar
kapsner committed
79
      - name: "[Cache] Restore R package cache"
80
        if: runner.os != 'Windows'
kapsner's avatar
kapsner committed
81
        uses: actions/cache/restore@v3
82
83
84
        with:
          path: ${{ env.R_LIBS_USER }}
          key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}}
kapsner's avatar
kapsner committed
85
86
87
88

      - name: "[Stage] Configure R Java"
        if: runner.os != 'Windows' && matrix.config.java == 'true'
        run: "echo export PATH=$PATH > reconf.sh; echo export JAVA_HOME=$JAVA_HOME >> reconf.sh; echo R CMD javareconf >> reconf.sh; sudo bash reconf.sh"
89

kapsner's avatar
kapsner committed
90
91
      - name: "[Stage] Install pak"
        run: Rscript -e "install.packages('pak', repos = 'https://r-lib.github.io/p/pak/stable')"
Lorenz Kapsner's avatar
Lorenz Kapsner committed
92

93
      - name: "[Stage] Install"
kapsner's avatar
kapsner committed
94
95
96
97
98
99
100
101
        run: Rscript -e "install.packages('tic', repos = c('https://ropensci.r-universe.dev', if (grepl('Ubuntu', Sys.info()[['version']])) {sprintf('https://packagemanager.rstudio.com/all/__linux__/%s/latest', system('lsb_release -cs', intern = TRUE))} else {'https://cloud.r-project.org'}))" -e "print(tic::dsl_load())" -e "tic::prepare_all_stages()" -e "tic::before_install()" -e "tic::install()"

      - name: "[Cache] Save R package cache"
        if: runner.os != 'Windows' && always()
        uses: actions/cache/save@v3
        with:
          path: ${{ env.R_LIBS_USER }}
          key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}}
102
103
104
105
106
107
108
109
110

      - name: "[Stage] Script"
        run: Rscript -e 'tic::script()'

      - name: "[Stage] After Success"
        run: Rscript -e "tic::after_success()"

      - name: "[Stage] Upload R CMD check artifacts"
        if: failure()
kapsner's avatar
kapsner committed
111
        uses: actions/upload-artifact@v4
112
113
114
        with:
          name: ${{ runner.os }}-r${{ matrix.config.r }}-results
          path: check
kapsner's avatar
kapsner committed
115
116
117
118
119
120
121
122
123
      - name: "[Stage] Before Deploy"
        run: |
          Rscript -e "tic::before_deploy()"

      - name: "[Stage] Deploy"
        run: Rscript -e "tic::deploy()"

      - name: "[Stage] After Deploy"
        run: Rscript -e "tic::after_deploy()"