diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 29e9a186d..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: unit-tests - -on: - workflow_dispatch: - push: - branches: - - main - - dev - pull_request: - branches: - - main - - dev - - breaking-improvments - -jobs: - unit-tests: - runs-on: ubuntu-20.04 - container: - image: hopkinsidd/flepimop:latest-dev - options: --user root - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - lfs: true - - name: Set up Rprofile - run: | - cp build/docker/Docker.Rprofile $HOME/.Rprofile - cp /home/app/.bashrc $HOME/.bashrc - shell: bash - - name: Install the gempyor package - run: | - source /var/python/3.10/virtualenv/bin/activate - python -m pip install --upgrade pip - python -m pip install "flepimop/gempyor_pkg[test]" - shell: bash - - name: Install local R packages - run: Rscript build/local_install.R - shell: bash - - name: Run gempyor tests - run: | - source /var/python/3.10/virtualenv/bin/activate - cd flepimop/gempyor_pkg - pytest -s - shell: bash - - name: Run gempyor-cli integration tests from examples - run: | - source /var/python/3.10/virtualenv/bin/activate - cd examples - pytest -s - shell: bash - - name: Run flepicommon tests - run: | - setwd("flepimop/R_packages/flepicommon") - devtools::test(stop_on_failure=TRUE) - shell: Rscript {0} - - name: Run inference tests - run: | - setwd("flepimop/R_packages/inference") - devtools::test(stop_on_failure=TRUE) - shell: Rscript {0} -# - name: Run integration tests -# env: -# CENSUS_API_KEY: ${{ secrets.CENSUS_API_KEY }} -# run: | -# Rscript build/local_install.R -# cd test -# source /var/python/3.10/virtualenv/bin/activate -# pytest run_tests.py -# shell: bash diff --git a/.github/workflows/flepicommon-ci.yml b/.github/workflows/flepicommon-ci.yml new file mode 100644 index 000000000..9f8abc089 --- /dev/null +++ b/.github/workflows/flepicommon-ci.yml @@ -0,0 +1,79 @@ +name: flepicommon-ci + +on: + workflow_dispatch: + push: + paths: + - flepimop/R_packages/flepicommon/**/* + branches: + - main + pull_request: + paths: + - flepimop/R_packages/flepicommon/**/* + branches: + - main + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + R-version: ["4.3.3"] + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + sparse-checkout: | + * + !documentation/ + sparse-checkout-cone-mode: false + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.R-version }} + update-rtools: true + - name: Install System Dependencies + run: sudo apt install libcurl4-openssl-dev libharfbuzz-dev libfribidi-dev libtiff5-dev libudunits2-dev libgdal-dev libgeos-dev libproj-dev + - name: Determine R Library Location + run: | + R_LIBPATH=$( R -s -e "cat(.libPaths()[1L])" | xargs ) + echo "R_LIBPATH=$R_LIBPATH" >> $GITHUB_ENV + R_LIBPATH_CKSUM=$( echo "$R_LIBPATH" | cksum | cut -d ' ' -f 1 ) + echo "R_LIBPATH_CKSUM=$R_LIBPATH_CKSUM" >> $GITHUB_ENV + CACHE_DATE=$( date -d "last Sunday" +%Y%m%d ) + echo "CACHE_DATE=$CACHE_DATE" >> $GITHUB_ENV + - name: R Library Cache + uses: actions/cache@v4 + with: + key: flepicommon-rlibs-${{ runner.os }}-${{ matrix.R-version }}-${{ hashFiles('flepimop/R_packages/flepicommon/DESCRIPTION', 'flepimop/R_packages/flepicommon/NAMESPACE') }}-${{ env.R_LIBPATH_CKSUM }}-${{ env.CACHE_DATE }} + path: ${{ env.R_LIBPATH }} + - name: Install R Dependencies + if: steps.r-library-cache.outputs.cache-hit != 'true' + run: | + install.packages( + "devtools", + repos = "https://cloud.r-project.org", + ) + library(devtools) + devtools::install_deps( + pkg = "flepimop/R_packages/flepicommon", + dependencies = TRUE + ) + install.packages("covidcast", repos = "https://cloud.r-project.org") + shell: Rscript {0} + - name: Install The flepicommon Package + run: | + devtools::install( + pkg = "flepimop/R_packages/flepicommon", + args = c(getOption("devtools.install.args"), "--install-tests"), + quick = TRUE, + dependencies = TRUE, + force = TRUE + ) + shell: Rscript {0} + - name: Run Tests + run: | + library(testthat) + test_package("flepicommon") + shell: Rscript {0} diff --git a/.github/workflows/gempyor-ci.yml b/.github/workflows/gempyor-ci.yml new file mode 100644 index 000000000..e2637f1af --- /dev/null +++ b/.github/workflows/gempyor-ci.yml @@ -0,0 +1,51 @@ +name: gempyor-ci + +on: + workflow_dispatch: + push: + paths: + - examples/**/* + - flepimop/gempyor_pkg/**/* + branches: + - main + pull_request: + paths: + - examples/**/* + - flepimop/gempyor_pkg/**/* + branches: + - main + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11"] + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + sparse-checkout: | + * + !documentation/ + sparse-checkout-cone-mode: false + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install gempyor + run: | + python -m pip install --upgrade pip + python -m pip install "flepimop/gempyor_pkg[test]" + shell: bash + - name: Run gempyor tests + run: | + cd flepimop/gempyor_pkg + pytest --exitfirst + shell: bash + - name: Run gempyor-cli integration tests from examples + run: | + cd examples + pytest --exitfirst + shell: bash diff --git a/.github/workflows/inference-ci.yml b/.github/workflows/inference-ci.yml new file mode 100644 index 000000000..d80a2e735 --- /dev/null +++ b/.github/workflows/inference-ci.yml @@ -0,0 +1,112 @@ +name: inference-ci + +on: + workflow_dispatch: + workflow_run: + workflows: ['flepicommon-ci', 'gempyor-ci'] + types: + - completed + push: + paths: + - flepimop/R_packages/inference/**/* + branches: + - main + pull_request: + paths: + - flepimop/R_packages/inference/**/* + branches: + - main + +jobs: + tests: + runs-on: ubuntu-latest + if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} + strategy: + matrix: + R-version: ["4.3.3"] + python-version: ["3.10", "3.11"] + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + sparse-checkout: | + * + !documentation/ + sparse-checkout-cone-mode: false + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install gempyor + run: | + python -m pip install --upgrade pip + python -m pip install "flepimop/gempyor_pkg[test]" + shell: bash + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.R-version }} + update-rtools: true + - name: Install System Dependencies + run: sudo apt install libcurl4-openssl-dev libharfbuzz-dev libfribidi-dev libtiff5-dev libudunits2-dev libgdal-dev libgeos-dev libproj-dev + - name: Determine R Library Location + run: | + R_LIBPATH=$( R -s -e "cat(.libPaths()[1L])" | xargs ) + echo "R_LIBPATH=$R_LIBPATH" >> $GITHUB_ENV + R_LIBPATH_CKSUM=$( echo "$R_LIBPATH" | cksum | cut -d ' ' -f 1 ) + echo "R_LIBPATH_CKSUM=$R_LIBPATH_CKSUM" >> $GITHUB_ENV + CACHE_DATE=$( date -d "last Sunday" +%Y%m%d ) + echo "CACHE_DATE=$CACHE_DATE" >> $GITHUB_ENV + - name: R Library Cache + uses: actions/cache@v4 + with: + key: inference-rlibs-${{ runner.os }}-${{ matrix.R-version }}-${{ hashFiles('flepimop/R_packages/flepicommon/DESCRIPTION', 'flepimop/R_packages/flepicommon/NAMESPACE', 'flepimop/R_packages/inference/DESCRIPTION', 'flepimop/R_packages/inference/NAMESPACE') }}-${{ env.R_LIBPATH_CKSUM }}-${{ env.CACHE_DATE }} + path: ${{ env.R_LIBPATH }} + - name: Install R Dependencies For flepicommon + if: steps.r-library-cache.outputs.cache-hit != 'true' + run: | + install.packages( + "devtools", + repos = "https://cloud.r-project.org", + ) + library(devtools) + devtools::install_deps( + pkg = "flepimop/R_packages/flepicommon", + dependencies = TRUE + ) + install.packages("covidcast", repos = "https://cloud.r-project.org") + shell: Rscript {0} + - name: Install The flepicommon Package + run: | + devtools::install( + pkg = "flepimop/R_packages/flepicommon", + quick = TRUE, + dependencies = TRUE, + force = TRUE + ) + shell: Rscript {0} + - name: Install R Dependencies For inference + if: steps.r-library-cache.outputs.cache-hit != 'true' + run: | + devtools::install_deps( + pkg = "flepimop/R_packages/inference", + dependencies = TRUE + ) + install.packages("covidcast", repos = "https://cloud.r-project.org") + shell: Rscript {0} + - name: Install The inference Package + run: | + devtools::install( + pkg = "flepimop/R_packages/inference", + args = c(getOption("devtools.install.args"), "--install-tests"), + quick = TRUE, + dependencies = TRUE, + force = TRUE + ) + shell: Rscript {0} + - name: Run Tests + run: | + library(testthat) + test_package("inference") + shell: Rscript {0}