hubverse-org / hubAdmin

Utilities for administering hubverse Infectious Disease Modeling Hubs
https://hubverse-org.github.io/hubAdmin/
Other
1 stars 2 forks source link

Add function to produce a report from `validate_hub_config()` and `view_config_val_errors()` on CI #31

Closed zkamvar closed 3 weeks ago

zkamvar commented 1 month ago

This originally stems from https://github.com/hubverse-org/hubverse-actions/issues/9 where I and @annakrystalli implemented a fix in https://github.com/hubverse-org/hubverse-actions/pull/20 that involves more than 20 lines of R code inside a GitHub workflow.

Given that these lines of code are exclusive to the domain of R and this package, it would make more sense for a function to be written from these lines of code.

The function should do the following:

  1. Take in a vector of hubs and a path to an output file
  2. for each hub: i. run validate_hub_config() and, if necessary, view_config_val_errors() ii. append a report to the output file iii. return github error on failure
  3. return TRUE if all configuration files are valid

This way, we would be able to reduce the maintenance burden on the validate-hub-config workflow files, which is especially important given that they are distributed and not centrally controlled (and fixing bugs in this context is not easy: https://github.com/zkamvar/2022-10-20-workflow-bug).

From here, the workflow could look something like this after this is implemented:

      - name: Run validations
        id: validate
        run: |
          hub_path <- Sys.getenv("HUB_PATH")
          diff <- file.path(hub_path, "diff.md")
          hubAdmin::ci_validate_hub_config(hub_path, diff)
        shell: Rscript {0}
      - name: "Comment on PR"
        id: comment-diff
        if: ${{ always() && github.event_name != 'workflow_dispatch' }}
        uses: carpentries/actions/comment-diff@main
        with:
          pr: ${{ env.PR_NUMBER }}
          path: ${{ env.HUB_PATH }}/diff.md