a b/.github/workflows/check.yml
1
2
on:
3
  push:
4
    branches: master
5
  pull_request:
6
    branches: master
7
name: check
8
9
env:
10
  GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
11
  R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
12
  WARNINGS_ARE_ERRORS: 1
13
  _R_CHECK_CRAN_INCOMING_REMOTE_: false
14
  _R_CHECK_TESTS_NLINES_: 0  # disable limiting of output lines
15
  _R_CHECK_CRAN_INCOMING_: false
16
  _R_CHECK_FORCE_SUGGESTS_: false
17
18
jobs:
19
  check:
20
    defaults:
21
      run:
22
        shell: bash
23
    runs-on: ${{ matrix.os }}
24
    strategy:
25
      fail-fast: false  # continue runs even when a parallel run failed
26
      matrix:
27
        # run on ubuntu, macos, windows. 20.04 is more recent than ubuntu-latest, currently.
28
        os: [macos-latest, windows-latest, ubuntu-latest]
29
        action: [check]
30
        r: [release]
31
        include:
32
          # additionally run r-devel, but only on ubuntu, and an old R version on an old ubuntu
33
          - os: ubuntu-latest
34
            action: check
35
            r: devel
36
          - os: ubuntu-20.04
37
            action: check
38
            r: '4.1'
39
          - os: ubuntu-latest
40
            action: coverage
41
            r: release
42
          - os: ubuntu-latest
43
            action: notensorflow
44
            r: release
45
46
    steps:
47
      - uses: actions/checkout@v4
48
      - uses: r-lib/actions/setup-r@v2
49
        id: install-r
50
        with:
51
          r-version: ${{ matrix.r }}
52
      - if: runner.os == 'Linux'
53
        name: apt-get update
54
        run: sudo apt-get update
55
      - name: Install curl for Ubuntu  
56
        # necessary for pkgdown & covr, so we do that on ubuntu-latest / R release only
57
        if: ${{ matrix.r == 'release' && matrix.os == 'ubuntu-latest' }}
58
        run: sudo apt-get install libcurl4-openssl-dev libharfbuzz-dev libfribidi-dev
59
      - uses: r-lib/actions/setup-pandoc@v2
60
      - uses: r-lib/actions/setup-tinytex@v2-branch
61
      - name: Create Cache Key
62
        shell: Rscript {0}
63
        run: |
64
          if (!require("remotes", quietly = TRUE)) install.packages("remotes")
65
          writeLines(capture.output(print(remotes::dev_package_deps())), ".github/deps.txt")
66
      - uses: actions/cache@v4
67
        with:
68
          path: ${{ env.R_LIBS_USER }}
69
          key: ${{ matrix.os }}-${{ steps.install-r.outputs.installed-r-version }}-${{ hashFiles('.github/deps.txt') }}
70
      - shell: Rscript {0}
71
        name: install necessary build env packages
72
        run: for (req in c("remotes", "roxygen2", "covr", "pkgdown")) if (!require(req, quietly = TRUE)) install.packages(req)
73
      - if: runner.os == 'Linux'
74
        name: install system requirements
75
        run: |
76
          while read -r depinst ; do
77
            echo "> $depinst"
78
            eval sudo $depinst
79
          done < <( Rscript -e "writeLines(remotes::system_requirements('ubuntu', '$( . /etc/os-release ; echo $VERSION_ID )'))")
80
      - shell: Rscript {0}
81
        name: install package dependencies
82
        run: | 
83
          remotes::install_deps(dependencies = TRUE)
84
      - name: Install Miniconda
85
        shell: Rscript {0}
86
        run: |
87
          reticulate::install_miniconda()
88
      - name: Mac OS Miniconda Setup
89
        run: |
90
          echo "options(reticulate.conda_binary = reticulate:::miniconda_conda())" >> .Rprofile
91
      - if: matrix.action != 'notensorflow'
92
        name: Install TF
93
        shell: Rscript {0}
94
        run: |
95
          reticulate::conda_create('r-reticulate', packages = c('python==3.10'))
96
          keras::install_keras(envname = 'r-reticulate')
97
      - name: Session Info
98
        shell: Rscript {0}
99
        run: |
100
          options(width = 200)
101
          installed.packages()[, c("Package", "Version", "Built")]
102
          sessionInfo()
103
          tensorflow::tf_config()
104
          tensorflow::tf_version()
105
          reticulate::py_config()
106
      - name: Document
107
        shell: Rscript {0}
108
        run: |
109
          roxygen2::roxygenise()
110
          system("attic/clean_man.sh")
111
      - if: runner.os == 'windows'
112
        name: Install tinytex packages
113
        shell: Rscript {0}
114
        run: |
115
          library(tinytex)
116
          tlmgr_version()
117
          tlmgr_update()
118
          tlmgr_install('collection-latexrecommended')
119
          tlmgr_install('collection-fontsrecommended')
120
          tlmgr(c('list', '--only-installed'))
121
      - name: Build
122
        if: ${{ matrix.action != 'coverage' }}
123
        working-directory: ..
124
        run: 'R CMD build */'
125
      - name: Check
126
        if: ${{ matrix.action != 'coverage' }}
127
        working-directory: ..
128
        run: 'R CMD check --as-cran --run-donttest *.tar.gz'
129
      - name: Coverage
130
        if: ${{ matrix.action == 'coverage' }}
131
        shell: Rscript {0}
132
        run: covr::codecov(quiet = FALSE, type = "tests")
133
      - name: install
134
        if: ${{ matrix.action != 'coverage' && matrix.os == 'ubuntu-20.04' && matrix.r == 'release' }}
135
        working-directory: ..
136
        run: 'R CMD INSTALL *.tar.gz'
137
      - name: Build Docs
138
        if: ${{ matrix.action != 'coverage' && matrix.os == 'ubuntu-20.04' && matrix.r == 'release' }}
139
        shell: Rscript {0}
140
        run: |
141
          pkgdown::build_site()
142
          roxygen2::roxygenise()
143
          tools::buildVignettes(dir = ".")
144
      - name: Deploy Docs
145
        if: ${{ matrix.action != 'coverage' && matrix.os == 'ubuntu-20.04' && matrix.r == 'release' && github.ref == 'refs/heads/master' }}
146
        run: |
147
          git config --local user.name "github-actions[bot]"
148
          git config --local user.email "mb706@users.noreply.github.com"
149
          git checkout --orphan gh-pages
150
          git --work-tree=docs add --all
151
          git --work-tree=docs commit -m "gh-pages"
152
          git push origin HEAD:gh-pages --force
153
      - name: Install Log
154
        if: ${{ failure() }}
155
        working-directory: ..
156
        run: 'cat *.Rcheck/00install.out'
157
      - name: Check Log
158
        if: ${{ failure() }}
159
        working-directory: ..
160
        run: 'cat *.Rcheck/00check.log'
161
      - name: Latex Log
162
        if: ${{ failure() }}
163
        working-directory: ..
164
        run: 'cat *.Rcheck/Rdlatex.log'
165