Skip to content

Commit

Permalink
Refactor the deployment setup and reorganise the repo (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmlft authored Nov 12, 2024
1 parent 045272c commit 0ce930f
Show file tree
Hide file tree
Showing 136 changed files with 2,995 additions and 1,857 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/renv
**/.Rprofile
12 changes: 12 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ENV=test
DATA_VOLUME_PATH=./data/test_data

# For preprocessing
PREPROCESS_DB_NAME= # name of the source database
PREPROCESS_HOST= # host address for the source database
PREPROCESS_PORT= # port on which to connect to the source database
PREPROCESS_DB_USERNAME= # username for the source database
PREPROCESS_DB_PASSWORD= # password for the source database

# For testing
TEST_DB_PATH=./data-raw/test_db/eunomia
11 changes: 10 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches: [main, master]

name: R-CMD-check.yaml
name: R-CMD-check

permissions: read-all

Expand All @@ -18,9 +18,14 @@ concurrency:
jobs:
R-CMD-check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package_dir: [app, preprocessing]
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

Expand All @@ -29,12 +34,16 @@ jobs:
use-public-rspm: true

- uses: r-lib/actions/setup-renv@v2
with:
working-directory: ${{ matrix.package_dir }}

- name: Install rcmdcheck
run: install.packages("rcmdcheck")
shell: Rscript {0}
working-directory: ${{ matrix.package_dir }}

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
working-directory: ${{ matrix.package_dir }}
20 changes: 14 additions & 6 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@ name: Build Docker Image
on:
push:
branches: ["main"]
paths: ["deploy/**"]
paths: ["docker-compose.yml", "app/Dockerfile", "preprocessing/Dockerfile"]
pull_request:
branches: ["main"]
paths: ["deploy/**"]
paths: ["docker-compose.yml", "app/Dockerfile", "preprocessing/Dockerfile"]
workflow_dispatch:

# Only run actions on the most recent push to a branch
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref }}"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image: [omopcat, preprocess]

steps:
- uses: actions/checkout@v4
- name: Add dummy .Renviron file
run: touch deploy/.Renviron
- name: Build the Docker image
run: docker compose build
working-directory: deploy/
run: |
cp .env.sample .env
docker compose build ${{ matrix.image }}
10 changes: 9 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches: [main, master]

name: lint.yaml
name: lint

permissions: read-all

Expand All @@ -18,6 +18,10 @@ concurrency:
jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package_dir: [app, preprocessing]
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
Expand All @@ -28,15 +32,19 @@ jobs:
use-public-rspm: true

- uses: r-lib/actions/setup-renv@v2
with:
working-directory: ${{ matrix.package_dir }}

- name: Install lintr
run: install.packages("lintr")
shell: Rscript {0}
working-directory: ${{ matrix.package_dir }}

- name: Lint
run: |
pkgload::load_all()
lintr::lint_package()
shell: Rscript {0}
working-directory: ${{ matrix.package_dir }}
env:
LINTR_ERROR_ON_LINT: true
91 changes: 0 additions & 91 deletions .github/workflows/pr-commands.yaml

This file was deleted.

12 changes: 11 additions & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ on:
pull_request:
branches: [main, master]

name: test-coverage.yaml
name: test-coverage

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package_dir: [app, preprocessing]
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -24,10 +28,13 @@ jobs:
use-public-rspm: true

- uses: r-lib/actions/setup-renv@v2
with:
working-directory: ${{ matrix.package_dir }}

- name: Install dependencies
run: install.packages("covr", "xml2")
shell: Rscript {0}
working-directory: ${{ matrix.package_dir }}

- name: Test coverage
run: |
Expand All @@ -38,6 +45,7 @@ jobs:
)
covr::to_cobertura(cov)
shell: Rscript {0}
working-directory: ${{ matrix.package_dir }}

- uses: codecov/codecov-action@v4
with:
Expand All @@ -46,13 +54,15 @@ jobs:
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{ matrix.package_dir }}

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

- name: Upload test results
if: failure()
Expand Down
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ repos:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
- id: roxygenize
args: [--root=./app]
additional_dependencies:
- bslib
- config
- DT
- fs
- ggplot2
- golem
- shiny
Expand All @@ -35,14 +37,16 @@ repos:
# codemeta must be above use-tidy-description when both are used
# - id: codemeta-description-updated
- id: use-tidy-description
args: [--root=./app]
# - id: lintr # disabling lintr hook as it doesn't seem to correctly load the package
# see also https://github.com/lorenzwalthert/precommit/issues/440
- id: parsable-R
- id: no-browser-statement
- id: no-print-statement
- id: no-debug-statement
- id: deps-in-desc
exclude: ^scripts/
args: [--root=./app]
exclude: "^scripts/|^app/dev/"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand All @@ -52,11 +56,6 @@ repos:
files: '^\.Rbuildignore$'
- id: end-of-file-fixer
exclude: '\.Rd'
- repo: https://github.com/pre-commit-ci/pre-commit-ci-config
rev: v1.6.1
hooks:
# Only required when https://pre-commit.ci is used for config validation
- id: check-pre-commit-ci-config
- repo: local
hooks:
- id: forbid-to-commit
Expand Down
Loading

0 comments on commit 0ce930f

Please sign in to comment.