Skip to content

Commit

Permalink
Merge branch 'master' into mrc-5074
Browse files Browse the repository at this point in the history
  • Loading branch information
r-ash committed Apr 3, 2024
2 parents fba4e53 + 7e3ef21 commit e9d4439
Show file tree
Hide file tree
Showing 35 changed files with 475 additions and 177 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
^tests/testthat/testdata/sensitive$
^buildkite$
^naomi$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
60 changes: 60 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

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

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

# Shorter timeout to prevent mac builders hanging for 6 hours!
timeout-minutes: 90

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
extra-repositories: https://mrc-ide.r-universe.dev

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- name: Start Redis
uses: shogo82148/actions-setup-redis@v1
with:
redis-version: "5.x"

- name: Build test data
run: Rscript ./scripts/build_test_data

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
error-on: '"error"'
63 changes: 63 additions & 0 deletions .github/workflows/R-integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: Integration test

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

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

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

# Shorter timeout to prevent mac builders hanging for 6 hours!
timeout-minutes: 90

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
extra-repositories: https://mrc-ide.r-universe.dev

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::devtools

- name: Start Redis
uses: shogo82148/actions-setup-redis@v1
with:
redis-version: "5.x"

- name: Build test data
run: |
./scripts/build_test_data
- name: Install hintr
run: |
Rscript -e 'devtools::install()'
- name: Run integration tests
run: |
./scripts/test_integration
66 changes: 66 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build Docker Image

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- id: extract_branch
name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GHCR (GitHub Packages)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Clone Naomi
uses: actions/checkout@master
with:
repository: mrc-ide/naomi
## ${{ github.token }} is scoped to the current repository, so we
## need to provide our own PAT
token: ${{ secrets.NAOMI_GH_PAT }}
path: naomi

- name: Build and push dev containers
uses: docker/build-push-action@v5
if: github.event_name == 'pull_request'
with:
context: .
file: "./docker/Dockerfile"
push: true
tags: |
mrcide/hintr:${{steps.extract_branch.outputs.branch}}
ghcr.io/${{github.repository}}:${{steps.extract_branch.outputs.branch}}
- name: Build and push prod containers
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request'
with:
file: "./docker/Dockerfile"
push: true
tags: |
mrcide/hintr:latest
mrcide/hintr:${{steps.extract_branch.outputs.branch}}
ghcr.io/${{github.repository}}:latest
ghcr.io/${{github.repository}}:${{steps.extract_branch.outputs.branch}}
47 changes: 47 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
extra-repositories: https://mrc-ide.r-universe.dev/bin/linux/jammy/4.3

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
60 changes: 60 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
extra-repositories: https://mrc-ide.r-universe.dev

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Start Redis
uses: shogo82148/actions-setup-redis@v1
with:
redis-version: "5.x"

- name: Build test data
run: |
./scripts/build_test_data
- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Additional_repositories: https://mrc-ide.r-universe.dev
Imports:
data.table,
Expand All @@ -22,9 +22,10 @@ Imports:
glue,
ids,
jsonlite (>= 1.2.2),
naomi (>= 2.9.23),
naomi (>= 2.9.24),
naomi.options (>= 1.1.0),
porcelain (>= 0.1.8),
qs,
R6,
readxl,
rrq (>= 0.7.0),
Expand All @@ -36,19 +37,19 @@ Imports:
zip
Suggests:
callr,
cli,
covr,
httr,
jsonvalidate,
mockr,
mockery,
pkgload,
ps,
redux,
ssh,
testthat (>= 2.1.0),
tidyselect,
withr
Remotes:
mrc-ide/geojsonio,
mrc-ide/rrq,
mrc-ide/mockr
mrc-ide/naomi,
Config/testthat/edition: 3
Config/testthat/parallel: true
11 changes: 2 additions & 9 deletions R/adr_metadata.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
adr_metadata <- function(queue) {
function(id) {
tryCatch({
res <- queue$result(id)
if (is_error(res) || is.null(res$path)) {
msg <- res$message
if (is.null(msg)) {
msg <- t_("FAILED_ADR_METADATA")
}
hintr_error(msg, "OUTPUT_GENERATION_FAILED")
}
res <- get_download_result(queue, id, "FAILED_ADR_METADATA")
list(type = scalar(res$metadata$type),
description = scalar(res$metadata$description))
},
error = function(e) {
if (is_porcelain_error(e)) {
stop(e)
} else {
hintr_error(e$message, "FAILED_TO_RETRIEVE_RESULT")
hintr_error(api_error_msg(e), "FAILED_TO_RETRIEVE_RESULT")
}
})
}
Expand Down
Loading

0 comments on commit e9d4439

Please sign in to comment.