Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move CI to github actions #433

Merged
merged 21 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
^docker$
^buildkite$
^images$
^\.github$
figure$
cache$
r-ash marked this conversation as resolved.
Show resolved Hide resolved
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: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {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

- name: Install libssh
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssh-dev

- 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

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
error-on: '"error"'
59 changes: 59 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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 QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to Docker Hub
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to avoid going via docker hub soon and only go via ghcr? You'll need to arrange a new dockerhub account otherwise, and they will definitely consider Avenir commercial

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, expecting we can remove this soon. I'll get deployment working off ghcr and then can remove this

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: Build and push dev containers
uses: docker/build-push-action@v5
if: github.event_name == 'pull_request'
with:
file: "./docker/Dockerfile"
push: true
tags: |
mrcide/naomi:${{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/naomi:latest
mrcide/naomi:${{steps.extract_branch.outputs.branch}}
ghcr.io/${{github.repository}}:latest
ghcr.io/${{github.repository}}:${{steps.extract_branch.outputs.branch}}
53 changes: 53 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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

- name: Install libssh
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssh-dev

- 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
57 changes: 57 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# 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

- name: Install libssh
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssh-dev

- 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: 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
29 changes: 13 additions & 16 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: naomi
Title: Naomi Model for Subnational HIV Estimates
Version: 2.9.23
Version: 2.9.24
Authors@R:
person(given = "Jeff",
family = "Eaton",
Expand All @@ -13,35 +13,36 @@ 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
https://mrc-ide.r-universe.dev,
https://duckdb.r-universe.dev
Imports:
DBI,
Matrix,
Matrix (>= 1.6.5),
R6,
TMB,
assertthat,
brio,
data.tree,
dplyr (>= 1.1.0),
duckdb (== 0.9.1),
duckdb (>= 0.10.0),
eppasm (>= 0.7.1),
gt,
first90 (>= 1.6.1),
forcats,
fs,
ggplot2,
gt,
here,
knitr,
magrittr,
methods,
mvtnorm,
naomi.options (>= 1.2.0),
openxlsx,
plotly,
prettyunits,
qs,
readr (>= 2.0.1),
rlang,
rmarkdown,
sf,
spdep (>= 1.1),
Expand All @@ -59,27 +60,23 @@ Suggests:
DiagrammeR,
covr,
datamodelr,
here,
knitr,
lubridate,
mockery,
mockr,
readxl,
rvest,
scales,
testthat (>= 2.1.0),
tibble,
tidyverse,
viridis
VignetteBuilder: knitr
LinkingTo:
RcppEigen,
TMB
Remotes:
bergant/datamodelr,
mrc-ide/eppasm,
first90=mrc-ide/first90release,
reside-ic/traduire,
mrc-ide/naomi.options,
mrc-ide/mockr,
mrc-ide/testthat.buildkite,
duckdb/[email protected]
bergant/datamodelr
Config/testthat/edition: 3
Config/testthat/parallel: true
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ vignettes/model-workflow.Rmd: vignettes_src/model-workflow.Rmd

vignettes/data-model.Rmd: vignettes_src/data-model.Rmd
cp $^ $@
mkdir vignettes/figure
mkdir -p vignettes/figure
./vignettes/script/create_data_model.R

vignettes/hintr-example.Rmd: vignettes_src/hintr-example.R
Expand All @@ -51,6 +51,7 @@ vignettes:
rm -rf vignettes/figure
rm -rf vignettes_src/outputs
rm -f vignettes/data-model.Rmd
rm -f vignettes/hintr-example.Rmd
rm -f vignettes/model-workflow.Rmd
rm -f vignettes_src/model-workflow.Rmd
make vignettes_install
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

S3method(print,naomi_areas)
export("%>%")
export(add_output_labels)
export(age_bar_plotly)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# naomi 2.9.24

* Migrate to github actions
* Fix R CMD check notes
* Unpin duckdb version

# naomi 2.9.23

* Update Datim UIDs for Ethiopia 2024 boundary division.
Expand Down
5 changes: 3 additions & 2 deletions R/areas.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ create_areas <- function(levels = NULL, hierarchy = NULL, boundaries = NULL,
v
}

print.naomi_areas <- function(areas) {
print(areas$tree, "area_name")
#' @export
print.naomi_areas <- function(x, ...) {
print(x$tree, "area_name")
}


Expand Down
2 changes: 1 addition & 1 deletion R/calibrate.R
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ calibrate_outputs <- function(output,
.expand(naomi_mf$calendar_quarter3, "unaware_plhiv_attend"),
.expand(naomi_mf$calendar_quarter1, "aware_plhiv_attend"),
.expand(naomi_mf$calendar_quarter2, "aware_plhiv_attend"),
.expand(naomi_mf$calendar_quarter3, "aware_plhiv_attend"),
.expand(naomi_mf$calendar_quarter3, "aware_plhiv_attend"),
.expand(naomi_mf$calendar_quarter1, "infections"),
.expand(naomi_mf$calendar_quarter2, "infections"),
.expand(naomi_mf$calendar_quarter3, "infections"),
Expand Down
2 changes: 1 addition & 1 deletion R/car.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ create_edge_list <- function(adj_matrix) {
w <- adj_matrix

## convert W to a sparse matrix if not already sparse.
if(!is(w, "sparseMatrix"))
if(!methods::is(w, "sparseMatrix"))
w <- Matrix(w, sparse = TRUE)

w[upper.tri(w)] <- 0
Expand Down
Loading
Loading