refactor: remove redundant field resets from transition functions (…
#479
This file contains hidden or 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
| # 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: | |
| - master | |
| - main | |
| pull_request: | |
| branches: | |
| - master | |
| - main | |
| workflow_dispatch: | |
| name: test-coverage | |
| jobs: | |
| test-coverage: | |
| runs-on: ubuntu-latest | |
| if: >- | |
| ${{ | |
| ( | |
| github.event_name != 'push' || | |
| ( | |
| !contains(github.event.head_commit.message, '[skip-check]') && | |
| !contains(github.event.head_commit.message, '[ci skip]') | |
| ) | |
| ) && | |
| ( | |
| github.event_name != 'pull_request' || | |
| ( | |
| !contains(github.event.pull_request.title, '[ci skip]') && | |
| !contains(github.event.pull_request.body, '[ci skip]') | |
| ) | |
| ) | |
| }} | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| RGL_USE_NULL: true | |
| NOT_CRAN: true | |
| TESTTHAT_CPUS: 1 | |
| _EPLUSR_RUN_INTEGRATION_TESTS_: true | |
| R_KEEP_PKG_SOURCE: true | |
| COVR_COVRIGNORE: ".github/workflows/.covrignore" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| use-public-rspm: true | |
| - uses: r-lib/actions/setup-pandoc@v2 | |
| - uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| extra-packages: any::covr, any::pkgload, any::xml2, any::DT, any::htmltools | |
| needs: coverage | |
| - name: Locate DuckDB extension cache | |
| id: duckdb-ext-cache | |
| run: | | |
| home <- tools::R_user_dir("duckdb", "data") | |
| dir <- file.path(home, "extensions") | |
| dir.create(dir, recursive = TRUE, showWarnings = FALSE) | |
| out <- Sys.getenv("GITHUB_OUTPUT") | |
| cat("path=", dir, "\n", file = out, append = TRUE, sep = "") | |
| cat("version=", as.character(utils::packageVersion("duckdb")), "\n", file = out, append = TRUE, sep = "") | |
| # DuckDB otherwise uses a per-session temp directory that covr cannot share. | |
| cat("DUCKDB_R_HOME=", home, "\n", file = Sys.getenv("GITHUB_ENV"), append = TRUE, sep = "") | |
| shell: Rscript {0} | |
| - name: Restore DuckDB extension cache | |
| id: cache-duckdb-ext | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ${{ steps.duckdb-ext-cache.outputs.path }} | |
| key: ${{ runner.os }}-${{ runner.arch }}-duckdb-ext-${{ steps.duckdb-ext-cache.outputs.version }}-sqlite-v1 | |
| - name: Restore EnergyPlus cache | |
| id: cache-eplus | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ~/.local/EnergyPlus-* | |
| key: ${{ runner.os }}-energyplus-${{ hashFiles('R/constants.R') }}-latest-22.2-9.6 | |
| - name: Prepare EnergyPlus | |
| run: | | |
| pkgload::load_all(".", quiet = TRUE, export_all = FALSE) | |
| latest <- get("LATEST_EPLUS_VER", asNamespace("eplusr")) | |
| versions <- c(latest, "22.2", "9.6") | |
| for (ver in versions) { | |
| if (!eplusr::is_avail_eplus(ver)) eplusr::install_eplus(ver, local = TRUE) | |
| stopifnot(eplusr::is_avail_eplus(ver)) | |
| message("EnergyPlus ", ver, ": ", eplusr::eplus_config(ver)$dir) | |
| } | |
| shell: Rscript {0} | |
| - name: Install DuckDB SQLite extension | |
| run: | | |
| pkgload::load_all(".", quiet = TRUE, export_all = FALSE) | |
| eplusr::install_duckdb_sqlite() | |
| shell: Rscript {0} | |
| - name: Save DuckDB extension cache | |
| if: steps.cache-duckdb-ext.outputs.cache-hit != 'true' | |
| continue-on-error: true | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ${{ steps.duckdb-ext-cache.outputs.path }} | |
| key: ${{ steps.cache-duckdb-ext.outputs.cache-primary-key }} | |
| - name: Save EnergyPlus cache | |
| if: steps.cache-eplus.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ~/.local/EnergyPlus-* | |
| key: ${{ steps.cache-eplus.outputs.cache-primary-key }} | |
| - name: Test coverage | |
| run: | | |
| dir.create("coverage", showWarnings = FALSE) | |
| cov <- covr::package_coverage( | |
| path = ".", | |
| type = "tests", | |
| quiet = FALSE, | |
| clean = FALSE | |
| ) | |
| print(cov) | |
| vals <- vapply(cov, function(x) x$value, numeric(1)) | |
| if (!any(vals > 0)) { | |
| stop("covr returned all-zero coverage; tests likely did not run") | |
| } | |
| saveRDS(cov, "coverage/coverage.rds") | |
| covr::to_cobertura(cov, "coverage/cobertura.xml") | |
| covr::report(cov, file = "coverage/index.html", browse = FALSE) | |
| shell: Rscript {0} | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-artifacts | |
| path: coverage/ | |
| - uses: codecov/codecov-action@v7 | |
| if: always() && hashFiles('coverage/cobertura.xml') != '' | |
| with: | |
| files: coverage/cobertura.xml | |
| flags: full-tests | |
| name: eplusr-full-tests | |
| fail_ci_if_error: false | |
| verbose: true | |
| token: ${{ secrets.CODECOV_TOKEN }} |