diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile new file mode 100644 index 0000000..05b3c4d --- /dev/null +++ b/.devcontainer/Containerfile @@ -0,0 +1,40 @@ +FROM docker.io/rocker/r-ver:4.4.1 + +# Will copy the package to the container preserving the directory structure +RUN mkdir -p pkg + +COPY ./DESCRIPTION pkg/ + +# Installing missing dependencies (removing pandoc-citeproc install) +RUN apt-get update && apt-get install -y --no-install-recommends \ + libcurl4-openssl-dev +RUN install2.r pak +# dependencies = TRUE means we install `suggests` too +RUN Rscript -e 'pak::local_install_deps("pkg", upgrade = FALSE, dependencies = TRUE)' +# The cmdstan version will need to be incrementally updated +# Must also manually bump cmdstan version `.github/workflows` when updating +RUN Rscript -e 'cmdstanr::install_cmdstan(version="2.36.0")' +# This requires access to the Azure Container Registry +# FROM ghcr.io/cdcgov/cfa-epinow2-pipeline:${TAG} + +# Will copy the package to the container preserving the directory structure +COPY . pkg/ + +# Install the full package while leaving the tar.gz file in the +# container for later use. +RUN R CMD build --no-build-vignettes --no-manual pkg && \ + R CMD INSTALL CFAEpiNow2Pipeline_*.tar.gz + +# Ensure the package is working properly +ARG CHECK_PKG=true +RUN if [ "$CHECK_PKG" = "true" ]; then \ + R CMD check --no-build-vignettes --no-manual CFAEpiNow2Pipeline_*.tar.gz; \ + else \ + echo "Skipping package check (CHECK_PKG=$CHECK_PKG)"; \ + fi + +ARG DEVELOPMENT=false +COPY ./extra.sh extra.sh +RUN chmod +x extra.sh && ./extra.sh && rm -rf extra.sh pkg/ + +CMD ["bash"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..c528a01 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,40 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/cpp +{ + "name": "epinow2-pipeline", + "build": { + "dockerfile": "../Dockerfile", + "args": { + "CHECK_PKG": "false", + "DEVELOPMENT": "true" + } + }, + "customizations": { + "vscode": { + "extensions": [ + "reditorsupport.r", + "rdebugger.r-debugger", + "quarto.quarto", + "tianyishi.rmarkdown" + ] + } + }, + "mounts": [ + // Mount the .vscode configuration into the container + "source=${localWorkspaceFolder}/.devcontainer/.vscode,target=/workspaces/${localWorkspaceFolderBasename}/.vscode,type=bind,consistency=cached" + ] + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "gcc -v", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/extra.sh b/.devcontainer/extra.sh new file mode 100644 index 0000000..e5790b8 --- /dev/null +++ b/.devcontainer/extra.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# If the development mode is true, then install the extra packages +if [ "$DEVELOPMENT" = "true" ]; then + echo "Development mode is enabled"; + + # Setting up dependencies + apt-get update && apt-get install \ + libharfbuzz-dev libfribidi-dev libfontconfig1-dev \ + libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev \ + --no-install-recommends -y && \ + install2.r --error devtools roxygen2 testthat languageserver && \ + + # Installing the httpgd package (requires libcairo) + apt-get install -y --no-install-recommends libcairo2-dev && \ + installGithub.r nx10/httpgd; + + # Installing pre-commit and uv + apt-get install pipx -y --no-install-recommends + echo 'PATH=/root/.local/bin:$PATH' >> ~/.bashrc + source ~/.bashrc + pipx install uv + pipx install pre-commit + pipx inject pre-commit pre-commit-uv +else + echo "Development mode is disabled"; +fi diff --git a/.github/workflows/containers-and-az-pool.yaml b/.github/workflows/containers-and-az-pool.yaml index dac0e41..3f25adb 100644 --- a/.github/workflows/containers-and-az-pool.yaml +++ b/.github/workflows/containers-and-az-pool.yaml @@ -94,6 +94,10 @@ jobs: needs: build-pipeline-image uses: ./.github/workflows/test-documentation.yaml + pkgdown: + needs: build-pipeline-image + uses: ./.github/workflows/pkgdown.yaml + acr-import: needs: build-pipeline-image runs-on: ubuntu-latest diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 5cc4cfb..37cb5dd 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,19 +1,43 @@ # 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: + workflow_call: name: pkgdown website jobs: + get-image-name: + runs-on: ubuntu-latest + outputs: + IMAGE: ${{ steps.image-name.outputs.image_name }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Extract branch name + id: branch-name + run: | + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + + - name: Figure out tag (either latest if it is main or the branch name) + id: image-tag + run: | + if [ "${{ steps.branch-name.outputs.branch }}" = "main" ]; then + echo "tag=latest" >> $GITHUB_OUTPUT + else + echo "tag=${{ steps.branch-name.outputs.branch }}" >> $GITHUB_OUTPUT + fi + + - name: Build Docker Image String + id: image-name + run: echo "image_name=ghcr.io/cdcgov/cfa-epinow2-pipeline:${{ steps.image-tag.outputs.tag }}" >> $GITHUB_OUTPUT + pkgdown: runs-on: ubuntu-latest + needs: get-image-name + container: + image: ${{ needs.get-image-name.outputs.IMAGE }} # Only restrict concurrency for non-PR jobs concurrency: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} @@ -22,24 +46,30 @@ jobs: permissions: contents: write pull-requests: write + steps: - uses: actions/checkout@v5 - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - r-version: "4.4.3" + # Setting up gh CLI (cached) + - name: Setup GH CLI + uses: cli/gh-extension-precompile@v2 - - uses: r-lib/actions/setup-r-dependencies@v2 + # Installs python using a cached version + - uses: actions/setup-python@v5 with: - extra-packages: any::pkgdown, local::. - needs: website + python-version: '3.13' + + # Installing pkgdown (won't be cached) + - name: Install pkgdown + run: | + install2.r pkgdown - name: Build site - run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} + run: | + pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) - name: Save artifact if: ${{ github.event_name == 'pull_request' }} diff --git a/DESCRIPTION b/DESCRIPTION index 1af7446..bc722d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -56,5 +56,5 @@ Additional_repositories: https://stan-dev.r-universe.dev URL: https://cdcgov.github.io/cfa-epinow2-pipeline/ Depends: - R (>= 3.50) + R (>= 3.5.0) LazyData: true diff --git a/Makefile b/Makefile index 7252cd4..4cc0908 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,11 @@ REGISTRY=cfaprdbatchcr.azurecr.io/ IMAGE_NAME=cfa-epinow2-pipeline BRANCH=$(shell git branch --show-current) CONFIG_CONTAINER=rt-epinow2-config + +ifndef CNTR_MGR CNTR_MGR=docker +endif + ifeq ($(BRANCH), main) TAG=latest else diff --git a/NEWS.md b/NEWS.md index 4a35f86..d458b92 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # CFAEpiNow2Pipeline v0.2.0 ## Features + * Adjust run trigger for time change * Move first run earlier in the day * Removing duplicative r-cmd-check.yaml file (already checking in Dockerfile)