-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ttscience/devel
CI/CD and overall API structure
- Loading branch information
Showing
19 changed files
with
2,069 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
^renv$ | ||
^renv\.lock$ | ||
^\.github$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
source("renv/activate.R") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 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: R-CMD-check | ||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: ubuntu-latest | ||
|
||
name: Ubuntu (latest) | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- name: Build image | ||
run: docker build -t unbiased --build-arg github_sha=${{ github.sha }} . | ||
|
||
- name: Run tests | ||
run: docker compose -f "docker-compose.test.yaml" up --abort-on-container-exit --exit-code-from tests --attach tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,27 @@ | ||
FROM alpine | ||
CMD ["echo", "Hello TTSI!..."] | ||
FROM rocker/r-ver:4.3.1 | ||
|
||
WORKDIR /src/unbiased | ||
|
||
# Install system dependencies | ||
RUN apt update && apt-get install -y --no-install-recommends \ | ||
# httpuv | ||
libz-dev \ | ||
# sodium | ||
libsodium-dev | ||
|
||
ENV RENV_CONFIG_SANDBOX_ENABLED=FALSE | ||
|
||
COPY ./renv ./renv | ||
COPY .Rprofile . | ||
COPY renv.lock . | ||
|
||
RUN R -e 'renv::restore()' | ||
|
||
COPY api/ ./api | ||
|
||
EXPOSE 3838 | ||
|
||
ARG github_sha | ||
ENV GITHUB_SHA=${github_sha} | ||
|
||
CMD ["R", "-e", "plumber::plumb(dir = 'api') |> plumber::pr_run(host = '0.0.0.0', port = 3838)"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#* Github commit SHA | ||
#* | ||
#* Each release of the API is based on some Github commit. This endpoint allows | ||
#* the user to easily check the SHA of the deployed API version. | ||
#* | ||
#* @get /sha | ||
#* @serializer unboxedJSON | ||
function() { | ||
Sys.getenv("GITHUB_SHA", unset = "") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#* @plumber | ||
function(api) { | ||
rand_simple <- plumber::pr("randomize-simple.R") | ||
meta <- plumber::pr("meta.R") | ||
|
||
api |> | ||
plumber::pr_mount("/simple", rand_simple) |> | ||
plumber::pr_mount("/meta", meta) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#* Return hello world | ||
#* | ||
#* @get /hello | ||
#* @serializer unboxedJSON | ||
function() { | ||
call_hello_world() | ||
} | ||
|
||
call_hello_world <- function() { | ||
"Hello TTSI!" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: "3.9" | ||
services: | ||
api: | ||
image: unbiased | ||
container_name: unbiased_api | ||
networks: | ||
- test_net | ||
tests: | ||
image: unbiased | ||
container_name: unbiased_tests | ||
depends_on: | ||
- api | ||
environment: | ||
- CI=true | ||
networks: | ||
- test_net | ||
volumes: | ||
- type: bind | ||
source: ./tests | ||
target: /src/unbiased/tests | ||
command: Rscript tests/testthat.R | ||
|
||
networks: | ||
test_net: |
Oops, something went wrong.