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

Coverage and devops #42

Merged
merged 28 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
10 changes: 9 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ RUN apt update && apt-get install -y --no-install-recommends \
# sodium
libsodium-dev \
# RPostgres
libpq-dev libssl-dev postgresql-client
libpq-dev libssl-dev postgresql-client \
# R_X11
libxt-dev

RUN pip install watchdog[watchmedo]

ENV RENV_CONFIG_SANDBOX_ENABLED=FALSE

# Install database migration tool
RUN curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | apt-key add - && \
echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ focal main" > /etc/apt/sources.list.d/migrate.list && \
apt-get update && \
apt-get install -y migrate
4 changes: 1 addition & 3 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ services:
- "5454:80"

db:
build:
context: ..
dockerfile: Dockerfile.postgres
image: ghcr.io/ttscience/postgres-temporal-tables/postgres-temporal-tables:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
Expand Down
36 changes: 0 additions & 36 deletions .github/workflows/R-CMD-check.yaml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/document.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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:
paths: ["R/**"]

name: Document

jobs:
document:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::roxygen2
needs: roxygen2

- name: Document
run: roxygen2::roxygenise()
shell: Rscript {0}

- name: Commit and push changes
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add man/\* NAMESPACE DESCRIPTION
git commit -m "Update documentation" || echo "No changes to commit"
git pull --ff-only
git push origin
32 changes: 32 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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, devel]
pull_request:
branches: [main, devel]

name: lint

jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

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

- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
79 changes: 79 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 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, devel]
pull_request:
branches: [main, devel]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
POSTGRES_DB: postgres
POSTGRES_HOST: 127.0.0.1
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres

services:
postgres:
image: ghcr.io/ttscience/postgres-temporal-tables/postgres-temporal-tables:latest
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

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

- name: Install migrate
run: |
curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | \
sudo apt-key add - && \
echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ focal main" | \
sudo tee /etc/apt/sources.list.d/migrate.list && \
sudo apt-get update && \
sudo apt-get install -y migrate

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ RdMacros: mathjaxr
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
URL: https://ttscience.github.io/unbiased/
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ RUN apt update && apt-get install -y --no-install-recommends \
# sodium
libsodium-dev \
# RPostgres
libpq-dev libssl-dev postgresql-client
libpq-dev libssl-dev postgresql-client \
curl gnupg2

# Install database migration tool
RUN curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | apt-key add - && \
echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ focal main" > /etc/apt/sources.list.d/migrate.list && \
apt-get update && \
apt-get install -y migrate

ENV RENV_CONFIG_SANDBOX_ENABLED=FALSE

Expand All @@ -33,5 +40,4 @@ EXPOSE 3838
ARG github_sha
ENV GITHUB_SHA=${github_sha}

CMD ["R", "-e", "unbiased::run_unbiased()"]

CMD ["R", "-e", "unbiased::run_unbiased()"]
15 changes: 0 additions & 15 deletions Dockerfile.postgres

This file was deleted.

4 changes: 1 addition & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Generated by roxygen2: do not edit by hand

export(list_studies)
export(create_db_connection_pool)
export(randomize_minimisation_pocock)
export(randomize_simple)
export(read_study_details)
export(run_unbiased)
export(study_exists)
import(checkmate)
import(dplyr)
import(mathjaxr)
Loading
Loading