|
| 1 | +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples |
| 2 | +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help |
1 | 3 | on:
|
2 | 4 | push:
|
3 |
| - branches: |
4 |
| - - main |
5 |
| - - master |
| 5 | + branches: [main, master] |
6 | 6 | pull_request:
|
7 |
| - branches: |
8 |
| - - main |
9 |
| - - master |
| 7 | + branches: [main, master] |
10 | 8 |
|
11 |
| -name: test-coverage |
| 9 | +name: test-coverage.yaml |
| 10 | + |
| 11 | +permissions: read-all |
12 | 12 |
|
13 | 13 | jobs:
|
14 | 14 | test-coverage:
|
15 |
| - runs-on: macOS-latest |
| 15 | + runs-on: ubuntu-latest |
16 | 16 | env:
|
17 | 17 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
| 18 | + |
18 | 19 | steps:
|
19 |
| - - uses: actions/checkout@v2 |
| 20 | + - uses: actions/checkout@v4 |
20 | 21 |
|
21 | 22 | - uses: r-lib/actions/setup-r@v2
|
| 23 | + with: |
| 24 | + use-public-rspm: true |
22 | 25 |
|
23 |
| - - uses: r-lib/actions/setup-pandoc@v2 |
24 |
| - |
25 |
| - - name: Query dependencies |
26 |
| - run: | |
27 |
| - install.packages('remotes') |
28 |
| - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) |
29 |
| - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") |
30 |
| - shell: Rscript {0} |
31 |
| - |
32 |
| - - name: Restore R package cache |
33 |
| - uses: actions/cache@v2 |
| 26 | + - uses: r-lib/actions/setup-r-dependencies@v2 |
34 | 27 | with:
|
35 |
| - path: ${{ env.R_LIBS_USER }} |
36 |
| - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} |
37 |
| - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- |
| 28 | + extra-packages: | |
| 29 | + any::covr |
| 30 | + any::xml2 |
| 31 | + any::remotes |
| 32 | + needs: coverage |
38 | 33 |
|
39 |
| - - name: Install dependencies |
| 34 | + - name: Install system dependencies |
| 35 | + if: runner.os == 'Linux' |
| 36 | + shell: bash |
40 | 37 | run: |
|
41 |
| - install.packages(c("remotes")) |
42 |
| - remotes::install_deps(dependencies = TRUE) |
43 |
| - remotes::install_cran("covr") |
| 38 | + . /etc/os-release |
| 39 | + while read -r cmd |
| 40 | + do |
| 41 | + echo "$cmd" |
| 42 | + sudo $cmd |
| 43 | + done < <(Rscript -e "writeLines(remotes::system_requirements('$ID-$VERSION_ID'))") |
| 44 | +
|
| 45 | + - name: Install package + deps |
| 46 | + run: remotes::install_local(dependencies = TRUE, force = TRUE) |
44 | 47 | shell: Rscript {0}
|
45 | 48 |
|
46 |
| - ### |
47 |
| - - name: Install Miniconda |
| 49 | + - name: Install greta deps |
48 | 50 | run: |
|
49 |
| - install.packages(c("remotes", "keras")) |
50 |
| - reticulate::install_miniconda() |
| 51 | + library(greta) |
| 52 | + greta::install_greta_deps(timeout = 50) |
51 | 53 | shell: Rscript {0}
|
52 | 54 |
|
53 |
| - - name: Set options for conda binary for macOS |
54 |
| - if: runner.os == 'macOS' |
55 |
| - run: | |
56 |
| - echo "options(reticulate.conda_binary = reticulate:::miniconda_conda())" >> .Rprofile |
| 55 | + - name: Situation Report on greta install |
| 56 | + run: greta::greta_sitrep() |
| 57 | + shell: Rscript {0} |
57 | 58 |
|
58 |
| -# Perhaps here is where we can install / change the environment that we are |
59 |
| -# installing into? Can we call our own greta install functions here? |
60 |
| - - name: Install TensorFlow |
| 59 | + - name: Test coverage |
61 | 60 | run: |
|
62 |
| - reticulate::conda_create(envname = "greta-env",python_version = "3.7") |
63 |
| - reticulate::conda_install(envname = "greta-env", packages = c("numpy==1.16.4", "tensorflow-probability==0.7.0", "tensorflow==1.14.0")) |
| 61 | + cov <- covr::package_coverage( |
| 62 | + quiet = FALSE, |
| 63 | + clean = FALSE, |
| 64 | + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") |
| 65 | + ) |
| 66 | + covr::to_cobertura(cov) |
64 | 67 | shell: Rscript {0}
|
65 | 68 |
|
66 |
| - - name: Python + TF details |
| 69 | + - uses: codecov/codecov-action@v4 |
| 70 | + with: |
| 71 | + fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} |
| 72 | + file: ./cobertura.xml |
| 73 | + plugin: noop |
| 74 | + disable_search: true |
| 75 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 76 | + |
| 77 | + - name: Show testthat output |
| 78 | + if: always() |
67 | 79 | run: |
|
68 |
| - Rscript -e 'tensorflow::tf_config()' |
69 |
| - Rscript -e 'tensorflow::tf_version()' |
70 |
| - Rscript -e 'reticulate::py_module_available("tensorflow_probability")' |
71 |
| - Rscript -e 'reticulate::py_config()' |
72 |
| - ### |
| 80 | + ## -------------------------------------------------------------------- |
| 81 | + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true |
| 82 | + shell: bash |
73 | 83 |
|
74 |
| - - name: Test coverage |
75 |
| - run: covr::codecov() |
76 |
| - shell: Rscript {0} |
| 84 | + - name: Upload test results |
| 85 | + if: failure() |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: coverage-test-failures |
| 89 | + path: ${{ runner.temp }}/package |
0 commit comments